@@ -58,50 +58,68 @@ const helloWorldBlock = createComponent<Auth0Props, Auth0State, Auth0Action, Aut
58
58
action : async ( element , action , context ) => {
59
59
switch ( action . action ) {
60
60
case 'save.config' :
61
- // await saveConfig();
61
+ // eslint-disable-next-line no-console
62
+ console . log ( 'action save.config element.state.client_id' , element . state . client_id ) ;
63
+ const { api, environment } = context ;
64
+ const spaceInstallation = environment . spaceInstallation ;
65
+
66
+ const configurationBody = {
67
+ ...spaceInstallation . configuration ,
68
+ client_id : element . state . client_id ,
69
+ client_secret : element . state . client_secret ,
70
+ issuer_base_url : element . state . issuer_base_url ,
71
+ } ;
72
+
73
+ const res = await api . integrations . updateIntegrationSpaceInstallation (
74
+ spaceInstallation . integration ,
75
+ spaceInstallation . installation ,
76
+ spaceInstallation . space ,
77
+ {
78
+ configuration : {
79
+ ...configurationBody ,
80
+ } ,
81
+ }
82
+ ) ;
83
+ // eslint-disable-next-line no-console
84
+ console . log ( 'res' , res ) ;
62
85
return element ;
63
86
}
64
87
} ,
65
88
render : async ( element , context ) => {
66
- // eslint-disable-next-line no-console
67
- console . log (
68
- 'disabled?' ,
69
- element . dynamicState ( 'client_id' ) ,
70
- ! element . state . client_id ||
71
- ! element . state . issuer_base_url ||
72
- ! element . state . client_secret
73
- ) ;
74
- const showButton =
75
- element . state . client_id && element . state . issuer_base_url && element . state . client_secret ;
89
+ const VACallbackURL = `${ context . environment . spaceInstallation ?. urls ?. publicEndpoint } /visitor-auth/response` ;
76
90
return (
77
91
< block >
78
92
< textinput state = "client_id" placeholder = "Enter Client Id" />
79
93
< textinput state = "issuer_base_url" placeholder = "Enter Issuer Base URL" />
80
94
< textinput state = "client_secret" placeholder = "Enter Client Secret" />
81
- { true ? (
82
- < input
83
- label = ""
84
- hint = ""
85
- element = {
86
- < button
87
- style = "primary"
88
- disabled = {
89
- ! element . state . client_id ||
90
- ! element . state . client_secret ||
91
- ! element . state . issuer_base_url
92
- }
93
- label = "Configure"
94
- tooltip = "Save configuration"
95
- onPress = { {
96
- action : 'save.config' ,
97
- client_id : element . dynamicState ( 'client_id' ) ,
98
- client_secret : element . dynamicState ( 'client_secret' ) ,
99
- issuer_base_url : element . dynamicState ( 'issuer_base_url' ) ,
100
- } }
101
- />
102
- }
103
- />
95
+ < input
96
+ label = ""
97
+ hint = ""
98
+ element = {
99
+ < button
100
+ style = "primary"
101
+ disabled = { false }
102
+ label = "Vibby"
103
+ tooltip = "Save configuration Vib"
104
+ onPress = { {
105
+ action : 'save.config' ,
106
+ // client_id: element.dynamicState('client_id'),
107
+ // client_secret: element.dynamicState('client_secret'),
108
+ // issuer_base_url: element.dynamicState('issuer_base_url'),
109
+ } }
110
+ />
111
+ }
112
+ />
113
+ { ! element . state . client_id ||
114
+ ! element . state . client_secret ||
115
+ ! element . state . issuer_base_url ? (
116
+ < hint >
117
+ < text style = "bold" > Enter values for the fields above and hit Save</ text >
118
+ </ hint >
104
119
) : null }
120
+ < divider size = "medium" />
121
+ < text > Enter the following URL as an allowed callback URL in Auth0:</ text >
122
+ < text > { VACallbackURL } </ text >
105
123
</ block >
106
124
) ;
107
125
} ,
@@ -267,7 +285,7 @@ export default createIntegration({
267
285
const installationURL = environment . spaceInstallation ?. urls ?. publicEndpoint ;
268
286
const issuerBaseUrl = environment . spaceInstallation ?. configuration . issuer_base_url ;
269
287
const clientId = environment . spaceInstallation ?. configuration . client_id ;
270
- const location = '' ;
288
+ const location = event . location ? event . location : '' ;
271
289
272
290
try {
273
291
return Response . redirect (
0 commit comments