feat: add slack connection fields to workspace settings export/import (#8287)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Petric
2026-03-09 17:39:03 -04:00
committed by GitHub
parent 6c5533bc60
commit 39e77ecd00
3 changed files with 67 additions and 2 deletions

View File

@@ -53,6 +53,9 @@ export interface SimplifiedSettings {
mute_critical_alerts?: boolean;
color?: string;
operator_settings?: any;
slack_team_id?: string;
slack_name?: string;
slack_command_script?: string;
}
// Legacy settings interface for reading old settings.yaml files
@@ -77,6 +80,9 @@ interface LegacySimplifiedSettings {
mute_critical_alerts?: boolean;
color?: string;
operator_settings?: any;
slack_team_id?: string;
slack_name?: string;
slack_command_script?: string;
}
// Helper to convert legacy flat settings to new grouped format
@@ -94,6 +100,9 @@ export function migrateToGroupedFormat(settings: any): SimplifiedSettings {
if (settings.mute_critical_alerts !== undefined) result.mute_critical_alerts = settings.mute_critical_alerts;
if (settings.color !== undefined) result.color = settings.color;
if (settings.operator_settings !== undefined) result.operator_settings = settings.operator_settings;
if (settings.slack_team_id !== undefined) result.slack_team_id = settings.slack_team_id;
if (settings.slack_name !== undefined) result.slack_name = settings.slack_name;
if (settings.slack_command_script !== undefined) result.slack_command_script = settings.slack_command_script;
// Handle auto_invite: check if already grouped or needs migration
if (settings.auto_invite && typeof settings.auto_invite === "object") {
@@ -183,12 +192,18 @@ export async function pushWorkspaceSettings(
mute_critical_alerts: remoteSettings.mute_critical_alerts,
color: remoteSettings.color,
operator_settings: remoteSettings.operator_settings,
slack_team_id: remoteSettings.slack_team_id,
slack_name: remoteSettings.slack_name,
slack_command_script: remoteSettings.slack_command_script,
};
} catch (err) {
throw new Error(`Failed to get workspace settings: ${err}`);
}
if (isSuperset(localSettings, settings)) {
// Exclude read-only fields from comparison (slack_team_id and slack_name are set via OAuth only)
const { slack_team_id: _lst, slack_name: _lsn, ...comparableLocal } = localSettings;
const { slack_team_id: _rst, slack_name: _rsn, ...comparableRemote } = settings;
if (isSuperset(comparableLocal, comparableRemote)) {
log.debug(`Workspace settings are up to date`);
return;
}
@@ -366,6 +381,16 @@ export async function pushWorkspaceSettings(
requestBody: localSettings.operator_settings,
});
}
if (localSettings.slack_command_script != settings.slack_command_script) {
log.debug(`Updating slack command script...`);
await wmill.editSlackCommand({
workspace,
requestBody: {
slack_command_script: localSettings.slack_command_script,
},
});
}
}
export async function pushWorkspaceKey(