try(dashboard): slack integration window does not work (test 1)

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-10-03 09:56:01 +02:00
parent ea27ca1e0a
commit 30f16c5be6
2 changed files with 13 additions and 6 deletions

View File

@@ -250,7 +250,10 @@ export async function slackWebhook(
}), }),
); );
reply.send({ success: true }); return reply
.status(200)
.header('Content-Type', 'text/html')
.send('<h1>Slack integration added. You can close this window now.</h1>');
} catch (err) { } catch (err) {
request.log.error(err); request.log.error(err);
return reply return reply

View File

@@ -19,11 +19,12 @@ export function SlackIntegrationForm({
defaultValues?: RouterOutputs['integration']['get']; defaultValues?: RouterOutputs['integration']['get'];
onSuccess: () => void; onSuccess: () => void;
}) { }) {
const popup = useRef<Window | null>(null);
const { organizationId } = useAppParams(); const { organizationId } = useAppParams();
useWS(`/live/integrations/slack?organizationId=${organizationId}`, (res) => { useWS(`/live/integrations/slack?organizationId=${organizationId}`, (res) => {
if (popup.current) { // @ts-expect-error
popup.current.close(); if (window.slackPopup && typeof window.slackPopup.close === 'function') {
// @ts-expect-error
window.slackPopup.close();
} }
onSuccess(); onSuccess();
}); });
@@ -42,14 +43,17 @@ export function SlackIntegrationForm({
const height = 800; const height = 800;
const left = window.screenX + (window.outerWidth - width) / 2; const left = window.screenX + (window.outerWidth - width) / 2;
const top = window.screenY + (window.outerHeight - height) / 2.5; const top = window.screenY + (window.outerHeight - height) / 2.5;
popup.current = window.open( // @ts-expect-error
window.slackPopup = window.open(
url, url,
'', '',
`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${width}, height=${height}, top=${top}, left=${left}`, `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${width}, height=${height}, top=${top}, left=${left}`,
); );
// The popup might have been blocked, so we redirect the user to the URL instead // The popup might have been blocked, so we redirect the user to the URL instead
if (!popup.current) { //
// @ts-expect-error
if (!window.slackPopup) {
window.location.href = url; window.location.href = url;
} }
}, },