@@ -5,21 +5,36 @@ import MiqFormRenderer from '@@ddf';
5
5
import createSchema from './visual-settings-form.schema' ;
6
6
7
7
const VisualSettingsForm = ( { recordId } ) => {
8
- const [ { initialValues, timezoneOptions, isLoading } , setState ] = useState ( { isLoading : true } ) ;
8
+ const [ {
9
+ initialValues, shortcuts, timezoneOptions, isLoading,
10
+ } , setState ] = useState ( { isLoading : true } ) ;
9
11
10
12
useEffect ( ( ) => {
11
- API . get ( '/api' ) . then ( ( { timezones } ) => {
12
- const timezoneOptions = [ ] ;
13
- timezones . forEach ( ( timezone ) => {
14
- timezoneOptions . push ( { value : timezone . name , label : timezone . description } ) ;
13
+ API . get ( '/api/shortcuts?expand=resources&attributes=description,url' ) . then ( ( { resources } ) => {
14
+ const shortcuts = [ ] ;
15
+
16
+ resources . forEach ( ( shortcut ) => {
17
+ shortcuts . push ( { value : shortcut . url , label : shortcut . description } ) ;
18
+ } ) ;
19
+
20
+ return shortcuts ;
21
+ } ) . then ( ( shortcuts ) => {
22
+ API . get ( '/api' ) . then ( ( { timezones } ) => {
23
+ const timezoneOptions = [ ] ;
24
+
25
+ timezones . forEach ( ( timezone ) => {
26
+ timezoneOptions . push ( { value : timezone . name , label : timezone . description } ) ;
27
+ } ) ;
28
+
29
+ return timezoneOptions ;
30
+ } ) . then ( ( timezoneOptions ) => {
31
+ API . get ( `/api/users/${ recordId } ?attributes=settings` ) . then ( ( { settings } ) => setState ( {
32
+ initialValues : settings ,
33
+ shortcuts,
34
+ timezoneOptions,
35
+ isLoading : false ,
36
+ } ) ) ;
15
37
} ) ;
16
- return timezoneOptions ;
17
- } ) . then ( ( timezoneOptions ) => {
18
- API . get ( `/api/users/${ recordId } ?attributes=settings` ) . then ( ( { settings } ) => setState ( {
19
- initialValues : settings ,
20
- timezoneOptions,
21
- isLoading : false ,
22
- } ) ) ;
23
38
} ) ;
24
39
} , [ recordId ] ) ;
25
40
@@ -42,7 +57,7 @@ const VisualSettingsForm = ({ recordId }) => {
42
57
}
43
58
return (
44
59
< MiqFormRenderer
45
- schema = { createSchema ( timezoneOptions ) }
60
+ schema = { createSchema ( shortcuts , timezoneOptions ) }
46
61
initialValues = { initialValues }
47
62
onSubmit = { onSubmit }
48
63
canReset
0 commit comments