Skip to content

Commit 4f8cd30

Browse files
committed
Confirm integration disconnects
1 parent c2c2ef7 commit 4f8cd30

1 file changed

Lines changed: 53 additions & 6 deletions

File tree

src/renderer/features/settings/components/IntegrationsCard.tsx

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,35 @@ const IntegrationsCard: React.FC = () => {
6363
} = useIntegrationsContext();
6464

6565
const showIntegrationSetup = useShowModal('integrationSetupModal');
66+
const showConfirmDisconnect = useShowModal('confirmActionModal');
6667

6768
const isCliManaged = authenticated && tokenSource === 'cli';
6869

6970
useEffect(() => {
7071
void checkStatus();
7172
}, [checkStatus]);
7273

74+
const confirmDisconnect = ({
75+
name,
76+
credential,
77+
onDisconnect,
78+
}: {
79+
name: string;
80+
credential?: string;
81+
onDisconnect: () => void | Promise<void>;
82+
}) => {
83+
showConfirmDisconnect({
84+
title: `Disconnect ${name}`,
85+
description: credential
86+
? `This will delete the saved ${name} ${credential} and disconnect ${name}.`
87+
: `This will disconnect ${name}.`,
88+
confirmLabel: 'Disconnect',
89+
onSuccess: () => {
90+
void onDisconnect();
91+
},
92+
});
93+
};
94+
7395
const integrations = [
7496
{
7597
id: 'github',
@@ -80,7 +102,7 @@ const IntegrationsCard: React.FC = () => {
80102
loading: isLoading || githubLoading,
81103
onConnect: handleGithubConnect,
82104
onCancel: cancelGithubConnect,
83-
onDisconnect: logout,
105+
onDisconnect: () => confirmDisconnect({ name: 'GitHub', onDisconnect: logout }),
84106
disabledTooltip: isCliManaged
85107
? 'Run `gh auth logout` in your terminal to disconnect'
86108
: undefined,
@@ -96,7 +118,12 @@ const IntegrationsCard: React.FC = () => {
96118
connected: !!isLinearConnected,
97119
loading: isLinearLoading,
98120
onConnect: () => showIntegrationSetup({ integration: 'linear' }),
99-
onDisconnect: disconnectLinear,
121+
onDisconnect: () =>
122+
confirmDisconnect({
123+
name: 'Linear',
124+
credential: 'API key',
125+
onDisconnect: disconnectLinear,
126+
}),
100127
},
101128
{
102129
id: 'jira',
@@ -109,7 +136,12 @@ const IntegrationsCard: React.FC = () => {
109136
connected: !!isJiraConnected,
110137
loading: isJiraLoading,
111138
onConnect: () => showIntegrationSetup({ integration: 'jira' }),
112-
onDisconnect: disconnectJira,
139+
onDisconnect: () =>
140+
confirmDisconnect({
141+
name: 'Jira',
142+
credential: 'credentials',
143+
onDisconnect: disconnectJira,
144+
}),
113145
},
114146
{
115147
id: 'gitlab',
@@ -122,7 +154,12 @@ const IntegrationsCard: React.FC = () => {
122154
connected: !!isGitlabConnected,
123155
loading: isGitlabLoading,
124156
onConnect: () => showIntegrationSetup({ integration: 'gitlab' }),
125-
onDisconnect: disconnectGitlab,
157+
onDisconnect: () =>
158+
confirmDisconnect({
159+
name: 'GitLab',
160+
credential: 'credentials',
161+
onDisconnect: disconnectGitlab,
162+
}),
126163
},
127164
{
128165
id: 'plain',
@@ -132,7 +169,12 @@ const IntegrationsCard: React.FC = () => {
132169
connected: !!isPlainConnected,
133170
loading: isPlainLoading,
134171
onConnect: () => showIntegrationSetup({ integration: 'plain' }),
135-
onDisconnect: disconnectPlain,
172+
onDisconnect: () =>
173+
confirmDisconnect({
174+
name: 'Plain',
175+
credential: 'API key',
176+
onDisconnect: disconnectPlain,
177+
}),
136178
},
137179
{
138180
id: 'forgejo',
@@ -145,7 +187,12 @@ const IntegrationsCard: React.FC = () => {
145187
connected: !!isForgejoConnected,
146188
loading: isForgejoLoading,
147189
onConnect: () => showIntegrationSetup({ integration: 'forgejo' }),
148-
onDisconnect: disconnectForgejo,
190+
onDisconnect: () =>
191+
confirmDisconnect({
192+
name: 'Forgejo',
193+
credential: 'credentials',
194+
onDisconnect: disconnectForgejo,
195+
}),
149196
},
150197
];
151198

0 commit comments

Comments
 (0)