authorgravatar for abdulazeez44@gmail.comAbdul Azeez <abdulazeez44@gmail.com> 2026-09-03 02:54:24+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-02 17:24:24-04:00
log5a9b56291f82b9269346053594d8b5dfca736976
tree4121f4e473d8debdec13ae58385db3e6a99abb31
parent46b5c66406b9942589d7e9132beeafda2434f113
signature Signed by PGP key B5690EEEBB952194

fix(web): warn when shared settings have no target environment (#9207)


1 files changed, 14 insertions(+), 7 deletions(-)

apps/web/src/hooks/useSettings.ts+14-7
...@@ -377,24 +377,31 @@ function useUpdateSettingsTarget(environmentId: EnvironmentId | null) {...@@ -377,24 +377,31 @@ function useUpdateSettingsTarget(environmentId: EnvironmentId | null) {
377377
378 if (Object.keys(serverPatch).length > 0) {378 if (Object.keys(serverPatch).length > 0) {
379 const { sharedPatch, localPatch } = splitSharedServerPatch(serverPatch);379 const { sharedPatch, localPatch } = splitSharedServerPatch(serverPatch);
380 if (environmentId && Object.keys(localPatch).length > 0) {380 // Dropping the write silently leaves the control looking saved.
381 void persistServerSettings({381 const warnUnsaved = () =>
382 environmentId,
383 input: { patch: localPatch },
384 });
385 } else {
386 // Dropping the write silently leaves the control looking saved.
387 toastManager.add({382 toastManager.add({
388 type: "warning",383 type: "warning",
389 title: "Setting not saved",384 title: "Setting not saved",
390 description: PRIMARY_SETTINGS_UNAVAILABLE_MESSAGE,385 description: PRIMARY_SETTINGS_UNAVAILABLE_MESSAGE,
391 });386 });
387 if (Object.keys(localPatch).length > 0) {
388 if (environmentId) {
389 void persistServerSettings({
390 environmentId,
391 input: { patch: localPatch },
392 });
393 } else {
394 warnUnsaved();
395 }
392 }396 }
393 if (Object.keys(sharedPatch).length > 0) {397 if (Object.keys(sharedPatch).length > 0) {
394 const targets = new Set(connectedEnvironmentIds);398 const targets = new Set(connectedEnvironmentIds);
395 if (environmentId) {399 if (environmentId) {
396 targets.add(environmentId);400 targets.add(environmentId);
397 }401 }
402 if (targets.size === 0) {
403 warnUnsaved();
404 }
398 for (const targetId of targets) {405 for (const targetId of targets) {
399 void persistServerSettings({406 void persistServerSettings({
400 environmentId: targetId,407 environmentId: targetId,