Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 43 additions & 15 deletions apps/web/src/components/settings/SourceControlConfigForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,33 @@ export function SourceControlConfigForm({
}),
);
const clearConfig = useMutation(
trpc.sourceControl.clearGitHubConfig.mutationOptions({
onSuccess: async () => {
trpc.sourceControl.clearConfig.mutationOptions({
onSuccess: async (result) => {
await queryClient.invalidateQueries({
queryKey: trpc.sourceControl.configStatus.queryKey(),
});
await queryClient.invalidateQueries({
queryKey: trpc.sourceControl.repositories.queryKey(),
});
await queryClient.invalidateQueries({
queryKey: trpc.github.installations.queryKey(),
});
if (provider === 'github') {
await queryClient.invalidateQueries({
queryKey: trpc.github.installations.queryKey(),
});
}
if (provider === 'ado') {
await queryClient.invalidateQueries({
queryKey: trpc.linkedAccounts.ado.queryKey(),
});
}
setValues({});
setEditingSavedValues({});
setRemoveDialogOpen(false);
toast.success('GitHub configuration removed.');
toast.success(
`${providerStatus?.label ?? 'Source-control'} configuration removed.`,
);
for (const warning of result.warnings) {
toast.warning(warning.message);
}
},
onError: (error) => {
toast.error(error.message);
Expand Down Expand Up @@ -308,9 +320,23 @@ export function SourceControlConfigForm({
}
return nextValue.length > 0;
});
const hasSavedValues =
provider === 'github' &&
providerStatus.fields.some((field) => field.savedSatisfied);
const hasSavedValues = providerStatus.fields.some(
(field) => field.savedSatisfied,
);
const hasPersistedAdoLinkedAccount = providerStatus.fields.some(
(field) =>
field.envVarName === 'ADO_LINKED_ACCOUNT_ID' &&
field.savedSatisfied &&
Boolean(field.savedValue?.trim()),
);
const providerRemovalDetail =
provider === 'github'
? 'Existing GitHub App installations and repositories will be disconnected.'
: provider === 'ado'
? hasPersistedAdoLinkedAccount
? 'The configured delegated Azure DevOps account will be unlinked, and existing repositories will be disconnected.'
: 'Existing Azure DevOps repositories will be disconnected.'
: `The encrypted ${providerStatus.label} OAuth connection will be deleted, and existing repositories will be disconnected.`;
const publicOrigin =
typeof window === 'undefined'
? 'https://your-deployment-url'
Expand Down Expand Up @@ -619,12 +645,14 @@ export function SourceControlConfigForm({
<Dialog open={removeDialogOpen} onOpenChange={setRemoveDialogOpen}>
<DialogContent size="sm">
<DialogHeader>
<DialogTitle>Remove GitHub configuration?</DialogTitle>
<DialogTitle>
Remove {providerStatus.label} configuration?
</DialogTitle>
<DialogDescription>
Saved GitHub credentials will be removed from the database.
Process environment variables are not affected. Existing GitHub
repositories will be disconnected so you can create or configure
another GitHub App.
Saved {providerStatus.label} configuration will be removed from
the database. Process environment variables are not affected.{' '}
{providerRemovalDetail} Roomote will attempt to remove external
hooks first. Cleanup failures will be reported after removal.
</DialogDescription>
</DialogHeader>
<DialogFooter>
Expand All @@ -639,7 +667,7 @@ export function SourceControlConfigForm({
<Button
type="button"
variant="destructive"
onClick={() => clearConfig.mutate()}
onClick={() => clearConfig.mutate({ provider })}
disabled={clearConfig.isPending}
>
<Trash2 />
Expand Down
Loading
Loading