1
1
import React , { useCallback } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import { HotKeys } from 'react-hotkeys' ;
4
- import { Tab , Button } from 'semantic-ui-react' ;
4
+ import { Tab , Button , Input } from 'semantic-ui-react' ;
5
5
import Icon from '@mdi/react' ;
6
6
import { mdiFloppy , mdiDelete } from '@mdi/js' ;
7
7
@@ -14,11 +14,11 @@ const keyMap = {
14
14
15
15
function RulePanel ( { rule} ) {
16
16
const api = useApi ( ) ;
17
- const { id, committing, committed} = rule ;
17
+ const { id, data , committing, committed} = rule ;
18
18
const confirm = useConfirm ( ) ;
19
19
const commit = useCallback ( ( ) => api . rule . commit ( id ) , [ id ] ) ;
20
20
const delete_ = useCallback ( ( ) => confirm ( ( ) => api . rule . delete ( id ) ) , [ id ] ) ;
21
- // const onNameChange = useCallback(name => api.rule.update(id, {name}), [id]);
21
+ const onNameChange = useCallback ( event => api . rule . update ( id , { name : event . target . value } ) , [ id ] ) ;
22
22
const RuleTabs = UserscriptTabs ;
23
23
24
24
return (
@@ -34,6 +34,13 @@ function RulePanel({rule}) {
34
34
save : commit
35
35
} }
36
36
>
37
+ < div className = "hm rule name" >
38
+ < Input
39
+ placeholder = "(untitled)"
40
+ defaultValue = { data . name || '' }
41
+ onInput = { onNameChange }
42
+ />
43
+ </ div >
37
44
< Tab . View >
38
45
{
39
46
RuleTabs ( { rule} ) . props . children
0 commit comments