@@ -5,16 +5,14 @@ import { alert, useIntl } from 'services'
55
66import { useConfiguration } from 'contexts'
77
8- import { Tabs , Tab , Input , Checkbox , Button , PairInputList , Icon , Radio } from 'components'
8+ import { Tabs , Button } from 'components'
99import Card , { CardTitle , CardText , CardActions } from 'components/Card'
1010
11- import { onListChangeActions } from 'helpers/onListChange'
12-
13- import { TagsEditor } from './components'
14-
1511import { reducer , serializeTags , synonymsToList , listToSynonyms } from './helpers'
1612
17- import { REGENERATE_SLACK_COMMAND_KEY , UPDATE_CONFIGURATION } from './queries'
13+ import { UPDATE_CONFIGURATION } from './queries'
14+
15+ import { General , Tags , Synonyms , Integrations } from './scenes'
1816
1917import './Settings.scss'
2018
@@ -31,11 +29,9 @@ const Settings = ({ configuration: conf }) => {
3129 const configuration = useConfiguration ( )
3230
3331 const [ loading , setLoading ] = useState ( false )
34- const [ slackHookLoading , setSlackHookLoading ] = useState ( false )
3532
3633 const [ state , dispatch ] = useReducer ( reducer , initState ( conf ) )
3734
38- const [ mutateSlackCommandKey ] = useMutation ( REGENERATE_SLACK_COMMAND_KEY )
3935 const [ mutate ] = useMutation ( UPDATE_CONFIGURATION )
4036
4137 useEffect ( ( ) => {
@@ -45,20 +41,6 @@ const Settings = ({ configuration: conf }) => {
4541 } )
4642 } , [ conf ] )
4743
48- const generateSlackHook = ( ) => {
49- setSlackHookLoading ( true )
50-
51- mutateSlackCommandKey ( )
52- . then ( ( { data } ) =>
53- dispatch ( {
54- type : 'change_slack_commandkey' ,
55- data : data . regenerateSlackCommandKey . slackCommandKey
56- } )
57- )
58- . catch ( alert . pushDefaultError )
59- . finally ( ( ) => setSlackHookLoading ( false ) )
60- }
61-
6244 const onSave = ( ) => {
6345 setLoading ( true )
6446 mutate ( {
@@ -99,116 +81,10 @@ const Settings = ({ configuration: conf }) => {
9981 </ CardTitle >
10082 < CardText >
10183 < Tabs >
102- < Tab label = { intl ( 'settings.general.tab' ) } >
103- < h2 > { intl ( 'settings.general.title.title' ) } </ h2 >
104- < br />
105- < div className = "inline-input" >
106- < Icon material = "home" />
107- < Input
108- value = { state . title }
109- onChange = { e => dispatch ( { type : 'change_title' , data : e . target . value } ) }
110- placeholder = { intl ( 'settings.general.title.placeholder' ) }
111- disabled = { loading }
112- />
113- </ div >
114- < br />
115- < hr />
116- < h2 > { intl ( 'settings.general.domains.title' ) } </ h2 >
117- < br />
118- < div className = "inline-input" >
119- < Icon material = "domain" />
120- < Input
121- style = { { flex : 1 } }
122- value = { state . authorizedDomains }
123- onChange = { e => dispatch ( { type : 'change_domains' , data : e . target . value } ) }
124- placeholder = { intl ( 'settings.general.domains.placeholder' ) }
125- disabled = { loading }
126- />
127- </ div >
128- < br />
129- < hr />
130- < h2 > { intl ( 'settings.general.bug_reporting.title' ) } </ h2 >
131- < br />
132- < div style = { { marginLeft : '1rem' } } >
133- < Radio . Group
134- name = "bug_reporting"
135- selected = { state . bugReporting }
136- onChange = { data => dispatch ( { type : 'change_bug_reporting' , data } ) }
137- disabled = { loading }
138- >
139- < Radio label = { intl ( 'settings.general.bug_reporting.mail' ) } value = "MAIL" />
140- < Radio label = { intl ( 'settings.general.bug_reporting.github' ) } value = "GITHUB" />
141- </ Radio . Group >
142- </ div >
143- </ Tab >
144- < Tab label = { intl ( 'settings.tags.tab' ) } >
145- < TagsEditor categories = { state . tagCategories } onChange = { onTagsChange } />
146- </ Tab >
147- < Tab label = { intl ( 'settings.synonyms.tab' ) } >
148- < PairInputList
149- pairs = { state . synonyms }
150- options = { {
151- icons : { line : 'loop' , value : 'list' } ,
152- labels : intl ( 'settings.synonyms.labels' )
153- } }
154- actions = { onListChangeActions ( 'synonyms' , dispatch ) }
155- disabled = { loading }
156- />
157- </ Tab >
158- < Tab label = { intl ( 'settings.integrations.tab' ) } >
159- < h2 > { intl ( 'settings.integrations.workplace.title' ) } </ h2 >
160- < br />
161- < div style = { { marginLeft : '1rem' } } >
162- < Checkbox
163- label = { intl ( 'settings.integrations.workplace.label' ) }
164- checked = { state . workplaceSharing }
165- onChange = { e =>
166- dispatch ( {
167- type : 'toggle_workplace' ,
168- data : e . target . checked
169- } )
170- }
171- disabled = { loading }
172- />
173- </ div >
174- < br />
175- < hr />
176- < h2 > { intl ( 'settings.integrations.slack.title' ) } </ h2 >
177- < br />
178- < div className = "inline-input" style = { { marginTop : '1em' } } >
179- < i style = { { marginLeft : '1em' } } > { intl ( 'settings.integrations.slack.channel' ) } </ i >
180- < Input
181- value = { state . slackChannelHook || '' }
182- style = { { flex : 1 , marginRight : '1rem' } }
183- onChange = { e =>
184- dispatch ( { type : 'change_slack_channelhook' , data : e . target . value } )
185- }
186- />
187- </ div >
188- < div className = "inline-input" style = { { marginTop : '1em' } } >
189- < i style = { { marginLeft : '1em' } } > { intl ( 'settings.integrations.slack.command' ) } </ i >
190- < Input
191- value = {
192- state . slackCommandKey
193- ? `https://${ window . location . host } /rest/integration/slack/${ state . slackCommandKey } `
194- : ''
195- }
196- disabled
197- small
198- style = { { flex : 1 , marginLeft : '1rem' , marginRight : '1rem' } }
199- />
200- < Button
201- label = {
202- ( state . slackCommandKey
203- ? intl ( 'settings.integrations.slack.regenerate' )
204- : intl ( 'settings.integrations.slack.generate' ) ) + ' URL'
205- }
206- link
207- loading = { slackHookLoading }
208- onClick = { generateSlackHook }
209- />
210- </ div >
211- </ Tab >
84+ < General state = { state } dispatch = { dispatch } loading = { loading } />
85+ < Tags state = { state } onTagsChange = { onTagsChange } />
86+ < Synonyms state = { state } dispatch = { dispatch } loading = { loading } />
87+ < Integrations state = { state } dispatch = { dispatch } loading = { loading } />
21288 </ Tabs >
21389 </ CardText >
21490 < CardActions >
0 commit comments