Skip to content

Commit

Permalink
Integration UI complete
Browse files Browse the repository at this point in the history
  • Loading branch information
vibhanshub committed Dec 27, 2023
1 parent 86448fe commit d032c12
Showing 1 changed file with 53 additions and 35 deletions.
88 changes: 53 additions & 35 deletions integrations/va-auth0/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,50 +58,68 @@ const helloWorldBlock = createComponent<Auth0Props, Auth0State, Auth0Action, Aut
action: async (element, action, context) => {
switch (action.action) {
case 'save.config':
// await saveConfig();
// eslint-disable-next-line no-console
console.log('action save.config element.state.client_id', element.state.client_id);
const { api, environment } = context;
const spaceInstallation = environment.spaceInstallation;

const configurationBody = {
...spaceInstallation.configuration,
client_id: element.state.client_id,
client_secret: element.state.client_secret,
issuer_base_url: element.state.issuer_base_url,
};

const res = await api.integrations.updateIntegrationSpaceInstallation(
spaceInstallation.integration,
spaceInstallation.installation,
spaceInstallation.space,
{
configuration: {
...configurationBody,
},
}
);
// eslint-disable-next-line no-console
console.log('res', res);
return element;
}
},
render: async (element, context) => {
// eslint-disable-next-line no-console
console.log(
'disabled?',
element.dynamicState('client_id'),
!element.state.client_id ||
!element.state.issuer_base_url ||
!element.state.client_secret
);
const showButton =
element.state.client_id && element.state.issuer_base_url && element.state.client_secret;
const VACallbackURL = `${context.environment.spaceInstallation?.urls?.publicEndpoint}/visitor-auth/response`;
return (
<block>
<textinput state="client_id" placeholder="Enter Client Id" />
<textinput state="issuer_base_url" placeholder="Enter Issuer Base URL" />
<textinput state="client_secret" placeholder="Enter Client Secret" />
{true ? (
<input
label=""
hint=""
element={
<button
style="primary"
disabled={
!element.state.client_id ||
!element.state.client_secret ||
!element.state.issuer_base_url
}
label="Configure"
tooltip="Save configuration"
onPress={{
action: 'save.config',
client_id: element.dynamicState('client_id'),
client_secret: element.dynamicState('client_secret'),
issuer_base_url: element.dynamicState('issuer_base_url'),
}}
/>
}
/>
<input
label=""
hint=""
element={
<button
style="primary"
disabled={false}
label="Vibby"
tooltip="Save configuration Vib"
onPress={{
action: 'save.config',
// client_id: element.dynamicState('client_id'),
// client_secret: element.dynamicState('client_secret'),
// issuer_base_url: element.dynamicState('issuer_base_url'),
}}
/>
}
/>
{!element.state.client_id ||
!element.state.client_secret ||
!element.state.issuer_base_url ? (
<hint>
<text style="bold">Enter values for the fields above and hit Save</text>
</hint>
) : null}
<divider size="medium" />
<text>Enter the following URL as an allowed callback URL in Auth0:</text>
<text>{VACallbackURL}</text>
</block>
);
},
Expand Down Expand Up @@ -267,7 +285,7 @@ export default createIntegration({
const installationURL = environment.spaceInstallation?.urls?.publicEndpoint;
const issuerBaseUrl = environment.spaceInstallation?.configuration.issuer_base_url;
const clientId = environment.spaceInstallation?.configuration.client_id;
const location = '';
const location = event.location ? event.location : '';

try {
return Response.redirect(
Expand Down

0 comments on commit d032c12

Please sign in to comment.