mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix(cli): keep the workspace color when settings are synced from git (#11144)
* fix(cli): keep the workspace color when settings are synced from git Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(cli): name the sync direction consistently in the identity-field comments Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(cli): apply the workspace color from settings.yaml only when the file sets one Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
8b4f6220dc
commit
129c045595
@@ -2542,6 +2542,21 @@ export function preservePendingScriptLocks(
|
||||
}
|
||||
}
|
||||
|
||||
// `sync push` never applies the workspace's display name from settings.yaml and
|
||||
// applies its color only when the local file carries one (see
|
||||
// pushWorkspaceSettings), so on a push the fields it would not apply must
|
||||
// compare equal, or the row is listed on every run.
|
||||
const isWorkspaceSettingsFile = (p: string) =>
|
||||
/^settings(\.[^./\\]+)?\.(yaml|json)$/.test(p);
|
||||
function stripUnappliedSettingsFields(local: any, remote: any) {
|
||||
delete local?.name;
|
||||
delete remote?.name;
|
||||
if (local?.color == null) {
|
||||
delete local?.color;
|
||||
delete remote?.color;
|
||||
}
|
||||
}
|
||||
|
||||
export async function compareDynFSElement(
|
||||
els1: DynFSElement,
|
||||
els2: DynFSElement | undefined,
|
||||
@@ -2757,6 +2772,9 @@ export async function compareDynFSElement(
|
||||
delete parsedV?.enabled;
|
||||
delete parsedM2?.enabled;
|
||||
}
|
||||
if (isEls1Remote === false && isWorkspaceSettingsFile(k)) {
|
||||
stripUnappliedSettingsFields(parsedV, parsedM2);
|
||||
}
|
||||
if (deepEqual(parsedV, parsedM2)) {
|
||||
continue;
|
||||
}
|
||||
@@ -2771,6 +2789,9 @@ export async function compareDynFSElement(
|
||||
delete before?.enabled;
|
||||
delete after?.enabled;
|
||||
}
|
||||
if (isEls1Remote === false && isWorkspaceSettingsFile(k)) {
|
||||
stripUnappliedSettingsFields(after, before);
|
||||
}
|
||||
if (deepEqual(before, after)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -214,9 +214,15 @@ export async function pushWorkspaceSettings(
|
||||
}
|
||||
|
||||
// Exclude fields that are never applied here: slack_team_id/slack_name are OAuth-only,
|
||||
// and name is not applied on pull (see below), so a name-only diff stays a no-op.
|
||||
// and name is never applied (see below), so a name-only diff stays a no-op. color is
|
||||
// applied only when the file carries it, so an unset one leaves the comparison too.
|
||||
const { slack_team_id: _lst, slack_name: _lsn, name: _ln, ...comparableLocal } = localSettings;
|
||||
const { slack_team_id: _rst, slack_name: _rsn, name: _rn, ...comparableRemote } = settings;
|
||||
const colorManaged = localSettings.color != null;
|
||||
if (!colorManaged) {
|
||||
delete comparableLocal.color;
|
||||
delete comparableRemote.color;
|
||||
}
|
||||
if (isSuperset(comparableLocal, comparableRemote)) {
|
||||
log.debug(`Workspace settings are up to date`);
|
||||
return;
|
||||
@@ -351,10 +357,9 @@ export async function pushWorkspaceSettings(
|
||||
});
|
||||
}
|
||||
|
||||
// Workspace display name is intentionally not applied on pull: settings.yaml is shared
|
||||
// across a repo's branches, so applying it would let one workspace's name overwrite
|
||||
// another's when both sync the same repo. It stays in the file (written on push), but a
|
||||
// live workspace is only renamed by its owner.
|
||||
// Workspace display name is intentionally never applied by `sync push`: settings.yaml is
|
||||
// shared across a repo's branches, so applying it would let one workspace's name overwrite
|
||||
// another's when both sync the same repo. `sync pull` still records it.
|
||||
|
||||
if (localSettings.mute_critical_alerts != settings.mute_critical_alerts) {
|
||||
log.debug(`Updating mute critical alerts...`);
|
||||
@@ -366,7 +371,9 @@ export async function pushWorkspaceSettings(
|
||||
});
|
||||
}
|
||||
|
||||
if (localSettings.color != settings.color) {
|
||||
// A color is applied only when the file carries one: `sync pull` omits the key for a
|
||||
// workspace without a color, so an unset key means "not managed by git", never "clear".
|
||||
if (colorManaged && localSettings.color != settings.color) {
|
||||
log.debug(`Updating workspace color...`);
|
||||
await wmill.changeWorkspaceColor({
|
||||
workspace,
|
||||
|
||||
Reference in New Issue
Block a user