fix: Fix error handler token injection (#2598)

* fix: Fix error handler token injection

* Add frontend
This commit is contained in:
Guillaume Bouvignies
2023-11-09 11:58:45 +01:00
committed by GitHub
parent 198e282566
commit aefa43dcaf
6 changed files with 24 additions and 29 deletions
@@ -218,7 +218,8 @@
<span class="w-full flex mb-3">
<Toggle
disabled={!$enterpriseLicense || !isEditable}
checked={handlerPath === slackHandlerScriptPath}
checked={handlerPath?.startsWith('hub/') &&
handlerPath?.endsWith('/workspace-or-schedule-error-handler-slack')}
options={{ right: slackToggleText }}
on:change={async (e) => {
handlerPath = e.detail ? slackHandlerScriptPath : undefined
@@ -238,7 +239,7 @@
class="text-xs"
/>
{/if}
{#if handlerPath === slackHandlerScriptPath && enterpriseLicense}
{#if enterpriseLicense && handlerPath?.startsWith('hub/') && handlerPath?.endsWith('/workspace-or-schedule-error-handler-slack')}
{#if !workspaceConnectedToSlack}
<Alert type="error" title="Workspace not connected to Slack">
<div class="flex flex-row gap-x-1 w-full items-center">
@@ -92,7 +92,10 @@
errorHandlerPath = splitted.slice(1)?.join('/')
errorHandlerExtraArgs = defaultErrorHandlerMaybe['errorHandlerExtraArgs']
errorHandlerCustomInitialPath = errorHandlerPath
if (errorHandlerPath === slackErrorHandler) {
if (
errorHandlerPath.startsWith('hub/') &&
errorHandlerPath.endsWith('/workspace-or-schedule-error-handler-slack')
) {
errorHandlerSelected = 'slack'
} else {
errorHandlerSelected = 'custom'
@@ -229,7 +232,12 @@
failedTimes = s.on_failure_times ?? 1
failedExact = s.on_failure_exact ?? false
errorHandlerExtraArgs = s.on_failure_extra_args ?? {}
if (errorHandlerPath !== slackErrorHandler) {
if (
errorHandlerPath.startsWith('hub/') &&
errorHandlerPath.endsWith('/workspace-or-schedule-error-handler-slack')
) {
errorHandlerSelected = 'slack'
} else {
errorHandlerSelected = 'custom'
}
} else {
@@ -172,7 +172,9 @@
errorHandlerSelected = 'custom'
} else {
errorHandlerSelected =
emptyString(errorHandlerScriptPath) || errorHandlerScriptPath === slackErrorHandler
emptyString(errorHandlerScriptPath) ||
(errorHandlerScriptPath.startsWith('hub/') &&
errorHandlerScriptPath.endsWith('/workspace-or-schedule-error-handler-slack'))
? 'slack'
: 'custom'
}