Skip to content

Commit 16fd0d8

Browse files
committed
Set github alert
1 parent 72eadb8 commit 16fd0d8

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

frontend/src/integrations/github/components/github-connect.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
</template>
44

55
<script setup>
6-
import { defineProps, computed } from 'vue';
6+
import { computed } from 'vue';
77
import config from '@/config';
8+
import ConfirmDialog from '@/shared/dialog/confirm-dialog';
9+
import { useRouter } from 'vue-router';
810
911
defineProps({
1012
integration: {
@@ -13,11 +15,38 @@ defineProps({
1315
},
1416
});
1517
18+
const router = useRouter();
19+
1620
// We have 3 GitHub apps: test, test-local and prod
1721
// Getting the proper URL from config file
1822
const githubConnectUrl = computed(() => config.gitHubInstallationUrl);
1923
const connect = () => {
20-
window.open(githubConnectUrl.value, '_self');
24+
ConfirmDialog({
25+
type: 'notification',
26+
title:
27+
'Are you the admin of your GitHub organization?',
28+
titleClass: 'text-lg pt-2',
29+
message:
30+
`Only GitHub users with admin permissions are able to connect crowd.dev's GitHub integration.
31+
If you are an organization member, you will need an approval from the GitHub workspace admin. <a href="https://docs.crowd.dev/docs/github-integration" target="_blank">Read more</a>`,
32+
icon: 'ri-information-line',
33+
confirmButtonText: 'I\'m the GitHub organization admin',
34+
cancelButtonText: 'Invite organization admin to this workspace',
35+
verticalCancelButtonClass: 'btn btn--md btn--primary w-full',
36+
verticalConfirmButtonClass: 'btn btn--md btn--bordered w-full !mb-2',
37+
vertical: true,
38+
distinguishCancelAndClose: true,
39+
autofocus: false,
40+
messageClass: 'text-xs !leading-5 !mt-1',
41+
}).then(() => {
42+
window.open(githubConnectUrl.value, '_self');
43+
}).catch((action) => {
44+
if (action === 'cancel') {
45+
router.push({
46+
name: 'settings',
47+
});
48+
}
49+
});
2150
};
2251
2352
</script>

frontend/src/shared/dialog/confirm-dialog.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export default ({
1717
confirmButtonText = 'Discard',
1818
confirmButtonClass = 'btn btn--md btn--primary',
1919
icon = 'ri-error-warning-line',
20+
distinguishCancelAndClose = false,
21+
autofocus = true,
22+
titleClass,
23+
messageClass,
24+
verticalCancelButtonClass,
25+
verticalConfirmButtonClass,
2026
}) => {
2127
let iconColorClass = 'text-yellow-600';
2228
let iconBgColorClass = 'bg-yellow-100';
@@ -59,7 +65,7 @@ export default ({
5965
h('div', [
6066
h('p', {
6167
innerHTML: message,
62-
class: 'text-gray-500 text-sm',
68+
class: `text-gray-500 text-sm ${messageClass}`,
6369
}),
6470
highlightedInfo
6571
? h(
@@ -133,7 +139,7 @@ export default ({
133139
),
134140
h('h6', {
135141
innerHTML: title,
136-
class: 'text-black mb-3',
142+
class: `text-black mb-3 ${titleClass}`,
137143
}),
138144
badgeContent
139145
? h('div', {
@@ -144,7 +150,7 @@ export default ({
144150
: undefined,
145151
h('p', {
146152
innerHTML: message,
147-
class: 'text-gray-500 text-sm',
153+
class: `text-gray-500 text-sm ${messageClass}`,
148154
}),
149155
highlightedInfo
150156
? h(
@@ -181,9 +187,11 @@ export default ({
181187
showCancelButton,
182188
customClass: overrideCustomClass,
183189
confirmButtonText,
184-
confirmButtonClass: overrideConfirmButtonClass,
190+
confirmButtonClass: verticalConfirmButtonClass || overrideConfirmButtonClass,
185191
cancelButtonText,
186-
cancelButtonClass: overrideCancelButtonClass,
192+
cancelButtonClass: verticalCancelButtonClass || overrideCancelButtonClass,
193+
distinguishCancelAndClose,
194+
autofocus,
187195
});
188196
}
189197

@@ -197,5 +205,7 @@ export default ({
197205
cancelButtonClass,
198206
confirmButtonText,
199207
confirmButtonClass,
208+
distinguishCancelAndClose,
209+
autofocus,
200210
});
201211
};

0 commit comments

Comments
 (0)