Skip to content
TypeScript

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

Abdul Azeez5a9b56291f82
diff --git a/apps/web/src/hooks/useSettings.ts b/apps/web/src/hooks/useSettings.ts
index a04c514fb45..6eb571f70aa 100644
--- a/apps/web/src/hooks/useSettings.ts
+++ b/apps/web/src/hooks/useSettings.ts
@@ -377,24 +377,31 @@ function useUpdateSettingsTarget(environmentId: EnvironmentId | null) {
if (Object.keys(serverPatch).length > 0) {
const { sharedPatch, localPatch } = splitSharedServerPatch(serverPatch);
- if (environmentId && Object.keys(localPatch).length > 0) {
- void persistServerSettings({
- environmentId,
- input: { patch: localPatch },
- });
- } else {
- // Dropping the write silently leaves the control looking saved.
+ // Dropping the write silently leaves the control looking saved.
+ const warnUnsaved = () =>
toastManager.add({
type: "warning",
title: "Setting not saved",
description: PRIMARY_SETTINGS_UNAVAILABLE_MESSAGE,
});
+ if (Object.keys(localPatch).length > 0) {
+ if (environmentId) {
+ void persistServerSettings({
+ environmentId,
+ input: { patch: localPatch },
+ });
+ } else {
+ warnUnsaved();
+ }
}
if (Object.keys(sharedPatch).length > 0) {
const targets = new Set(connectedEnvironmentIds);
if (environmentId) {
targets.add(environmentId);
}
+ if (targets.size === 0) {
+ warnUnsaved();
+ }
for (const targetId of targets) {
void persistServerSettings({
environmentId: targetId,