Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

feat: get creating, updating, deleting Integrations working #240

Merged
merged 1 commit into from
Mar 11, 2023

Conversation

tomkit
Copy link
Contributor

@tomkit tomkit commented Mar 10, 2023

  • Prisma migration for Integration: adds is_enabled and makes config optional
  • Use Nextjs useSWR's mutate to fetch and make updates
  • Get creating, updating, deleting Integrations working
  • Update openapi spec for creating/updating integrations

SWR related reading for using mutating local and remote state:

Other:

  • Remove extra /dashboard page, use root instead for dashboard
  • Use Card for MetricCard rather than Grid
  • Rename Active tab to Installed
  • Rename Application 1 to Your application
  • others

@vercel
Copy link

vercel bot commented Mar 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
supaglue-docs ⬜️ Ignored (Inspect) Mar 11, 2023 at 0:35AM (UTC)

action={
<Switch
checked={enabled}
checked={integration?.isEnabled}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-drive

subheader={
<Stack direction="column">
<Typography>{name}</Typography>
<Typography fontSize={12}>{status === 'auth-only' ? status : category.toUpperCase()}</Typography>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add in integration category

const updatedIntegrations = [...existingIntegrations, newIntegration];

mutate(updatedIntegrations, false);
mutateIntegration(createRemoteIntegration(newIntegration), false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the pattern from the linked SWR reading for now

label: 'Active',
value: 'active',
label: 'Installed',
value: 'installed',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming to Installed since you can have existing but disabled integrations

<Typography variant="body2" noWrap>
<Card variant="outlined" className="h-32">
<Stack>
<CardHeader avatar={icon} subheader={title} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make use of mui's CardHeader, CardContent so you get responsive for free

</FormControl>
</Box>
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used on sync log page

</Grid>
</CardContent>
</Card>
</Box>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from the dashboard page

oauth_client_secret: 941b846a-5a8c-48b8-b0e1-41b6d4bc4f1a
- sync:
- period_ms: 60000
- remote_provider_app_id: my_app_id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@tomkit tomkit force-pushed the integration_changes branch 4 times, most recently from 92d5053 to 9e4779c Compare March 10, 2023 23:24
export const APPLICATION_ID = 'a4398523-03a2-42dd-9681-c91e3e2efaf4';

// TODO: use Supaglue TS client
export async function updateRemoteIntegration(data: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data can be typed

// TODO: get this on the server-side from the session
export const APPLICATION_ID = 'a4398523-03a2-42dd-9681-c91e3e2efaf4';

// TODO: use Supaglue TS client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this file can be DRYed

}}
>
Cancel
</Button>{' '}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove {' '}

const newIntegration = {
...integration,
config: {
providerAppId: '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line necessary? Does it get overridden by the next line?

oauthScopes: oauthScopes.split(','),
},
sync: {
periodMs: 60 * 60 * 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 1x/hour what we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now

{providerToIcon(integrationCardInfo.providerName)}
<Typography variant="subtitle1">{integrationCardInfo.name}</Typography>
<Stack direction="row" className="items-center justify-center gap-2">
{providerToIcon(integrationCardInfo.providerName, 35)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICON_SIZE?


const { trigger } = useSWRMutation('/mgmt/v1/integrations', sendRequest);
const { mutate: mutateIntegration } = useIntegration(integration?.id);
const { integrations: existingIntegrations = [], mutate } = useIntegrations();

useEffect(() => {
setClientId(integration?.config?.oauth?.credentials?.oauthClientId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like integration is already passed in as a prop -- why do we need to do this?

@tomkit tomkit force-pushed the integration_changes branch 5 times, most recently from dfb81b1 to 841ac81 Compare March 11, 2023 00:27
@tomkit tomkit changed the title feat: get creating, updating, deleting Integrations working-ish feat: get creating, updating, deleting Integrations workin Mar 11, 2023
@tomkit tomkit changed the title feat: get creating, updating, deleting Integrations workin feat: get creating, updating, deleting Integrations working Mar 11, 2023
@tomkit tomkit merged commit f3cc980 into main Mar 11, 2023
@tomkit tomkit deleted the integration_changes branch March 11, 2023 00:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants