299 lines
9.7 KiB
JavaScript
299 lines
9.7 KiB
JavaScript
import {
|
|
SETTINGS_SCHEMA
|
|
} from "./chunk-RF5LOU35.js";
|
|
import {
|
|
useTypedSelector
|
|
} from "./chunk-HE4XRQCP.js";
|
|
import {
|
|
getTimezones,
|
|
useGetReleaseSettingsQuery,
|
|
useUpdateReleaseSettingsMutation
|
|
} from "./chunk-C4NW23D7.js";
|
|
import "./chunk-QF6GPHA4.js";
|
|
import "./chunk-JRLAXHTE.js";
|
|
import "./chunk-E4IFZ6ZT.js";
|
|
import "./chunk-QLEKUQKW.js";
|
|
import "./chunk-4J3VOWQV.js";
|
|
import "./chunk-PFI4R5WA.js";
|
|
import "./chunk-B3BGMYGX.js";
|
|
import "./chunk-W6ICJ5TB.js";
|
|
import "./chunk-IHYIPMY2.js";
|
|
import "./chunk-UWHSN2C7.js";
|
|
import "./chunk-ERK7O2GM.js";
|
|
import "./chunk-FCIM6RNO.js";
|
|
import "./chunk-J33IXKN4.js";
|
|
import "./chunk-NP53ZCXD.js";
|
|
import "./chunk-MBK4V2X7.js";
|
|
import "./chunk-5ESYXDTN.js";
|
|
import "./chunk-K65KIEAL.js";
|
|
import "./chunk-B7ZLODDO.js";
|
|
import "./chunk-PW7XKCYO.js";
|
|
import "./chunk-RMBEU7DO.js";
|
|
import "./chunk-RI2W2UZ6.js";
|
|
import "./chunk-IY256CNP.js";
|
|
import "./chunk-IFOFBKTA.js";
|
|
import "./chunk-XLSIZGJF.js";
|
|
import "./chunk-EGNP2T5O.js";
|
|
import "./chunk-GSN7U3BK.js";
|
|
import "./chunk-T3B5F2LV.js";
|
|
import "./chunk-YXDCVYVT.js";
|
|
import "./chunk-QIJGNK42.js";
|
|
import "./chunk-7PUJSL55.js";
|
|
import "./chunk-C2ZJTFO7.js";
|
|
import "./chunk-C75BZXCZ.js";
|
|
import "./chunk-APGTER6B.js";
|
|
import "./chunk-ZM6TT53G.js";
|
|
import "./chunk-6AXVGFVQ.js";
|
|
import {
|
|
Form,
|
|
useField
|
|
} from "./chunk-BFLP6DBI.js";
|
|
import {
|
|
useRBAC
|
|
} from "./chunk-CMLQV3Z2.js";
|
|
import "./chunk-IGCTEXRF.js";
|
|
import {
|
|
Layouts
|
|
} from "./chunk-TIVRAWTC.js";
|
|
import "./chunk-PQINNV4N.js";
|
|
import "./chunk-VYSYYPOB.js";
|
|
import {
|
|
Page,
|
|
useAPIErrorHandler
|
|
} from "./chunk-5CAWUBTQ.js";
|
|
import "./chunk-W2TBR6J3.js";
|
|
import "./chunk-QEGMJR7H.js";
|
|
import {
|
|
isFetchError
|
|
} from "./chunk-LCL5TIBZ.js";
|
|
import "./chunk-WOQNBAGN.js";
|
|
import "./chunk-BHLYCXQ7.js";
|
|
import "./chunk-76QM3EFM.js";
|
|
import "./chunk-CE4VABH2.js";
|
|
import "./chunk-5VODLFKF.js";
|
|
import {
|
|
useNotification
|
|
} from "./chunk-N55RVBRV.js";
|
|
import {
|
|
Button,
|
|
Combobox,
|
|
Field,
|
|
Flex,
|
|
Grid,
|
|
Option,
|
|
Typography,
|
|
useIntl
|
|
} from "./chunk-7XB6XSWQ.js";
|
|
import "./chunk-5ZC4PE57.js";
|
|
import "./chunk-TUXTO2Z5.js";
|
|
import "./chunk-FOD4ENRR.js";
|
|
import {
|
|
ForwardRef$4F
|
|
} from "./chunk-WRD5KPDH.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-NIAJZ5MX.js";
|
|
import "./chunk-ACIMPXWY.js";
|
|
import "./chunk-MADUDGYZ.js";
|
|
import {
|
|
__toESM
|
|
} from "./chunk-PLDDJCW6.js";
|
|
|
|
// node_modules/@strapi/content-releases/dist/admin/pages/ReleasesSettingsPage.mjs
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var ReleasesSettingsPage = () => {
|
|
const { formatMessage } = useIntl();
|
|
const { formatAPIError } = useAPIErrorHandler();
|
|
const { toggleNotification } = useNotification();
|
|
const { data, isLoading: isLoadingSettings } = useGetReleaseSettingsQuery();
|
|
const [updateReleaseSettings, { isLoading: isSubmittingForm }] = useUpdateReleaseSettingsMutation();
|
|
const permissions = useTypedSelector((state) => {
|
|
var _a;
|
|
return (_a = state.admin_app.permissions["settings"]) == null ? void 0 : _a["releases"];
|
|
});
|
|
const { allowedActions: { canUpdate } } = useRBAC(permissions);
|
|
const { timezoneList } = getTimezones(/* @__PURE__ */ new Date());
|
|
const handleSubmit = async (body) => {
|
|
const { defaultTimezone } = body;
|
|
const isBodyTimezoneValid = timezoneList.some((timezone) => timezone.value === defaultTimezone);
|
|
const newBody = !defaultTimezone || !isBodyTimezoneValid ? {
|
|
defaultTimezone: null
|
|
} : {
|
|
...body
|
|
};
|
|
try {
|
|
const response = await updateReleaseSettings(newBody);
|
|
if ("data" in response) {
|
|
toggleNotification({
|
|
type: "success",
|
|
message: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.setting.default-timezone-notification-success",
|
|
defaultMessage: "Default timezone updated."
|
|
})
|
|
});
|
|
} else if (isFetchError(response.error)) {
|
|
toggleNotification({
|
|
type: "danger",
|
|
message: formatAPIError(response.error)
|
|
});
|
|
} else {
|
|
toggleNotification({
|
|
type: "danger",
|
|
message: formatMessage({
|
|
id: "notification.error",
|
|
defaultMessage: "An error occurred"
|
|
})
|
|
});
|
|
}
|
|
} catch (error) {
|
|
toggleNotification({
|
|
type: "danger",
|
|
message: formatMessage({
|
|
id: "notification.error",
|
|
defaultMessage: "An error occurred"
|
|
})
|
|
});
|
|
}
|
|
};
|
|
if (isLoadingSettings) {
|
|
return (0, import_jsx_runtime.jsx)(Page.Loading, {});
|
|
}
|
|
return (0, import_jsx_runtime.jsxs)(Layouts.Root, {
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Page.Title, {
|
|
children: formatMessage({
|
|
id: "Settings.PageTitle",
|
|
defaultMessage: "Settings - {name}"
|
|
}, {
|
|
name: "Releases"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Page.Main, {
|
|
"aria-busy": isLoadingSettings,
|
|
tabIndex: -1,
|
|
children: (0, import_jsx_runtime.jsx)(Form, {
|
|
method: "PUT",
|
|
initialValues: {
|
|
defaultTimezone: data == null ? void 0 : data.data.defaultTimezone
|
|
},
|
|
onSubmit: handleSubmit,
|
|
validationSchema: SETTINGS_SCHEMA,
|
|
children: ({ modified, isSubmitting }) => {
|
|
return (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Layouts.Header, {
|
|
primaryAction: canUpdate ? (0, import_jsx_runtime.jsx)(Button, {
|
|
disabled: !modified || isSubmittingForm,
|
|
loading: isSubmitting,
|
|
startIcon: (0, import_jsx_runtime.jsx)(ForwardRef$4F, {}),
|
|
type: "submit",
|
|
children: formatMessage({
|
|
id: "global.save",
|
|
defaultMessage: "Save"
|
|
})
|
|
}) : null,
|
|
title: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.title",
|
|
defaultMessage: "Releases"
|
|
}),
|
|
subtitle: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.description",
|
|
defaultMessage: "Create and manage content updates"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Layouts.Content, {
|
|
children: (0, import_jsx_runtime.jsxs)(Flex, {
|
|
direction: "column",
|
|
background: "neutral0",
|
|
alignItems: "stretch",
|
|
padding: 6,
|
|
gap: 6,
|
|
shadow: "filterShadow",
|
|
hasRadius: true,
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Typography, {
|
|
variant: "delta",
|
|
tag: "h2",
|
|
children: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.preferences.title",
|
|
defaultMessage: "Preferences"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Grid.Root, {
|
|
children: (0, import_jsx_runtime.jsx)(Grid.Item, {
|
|
col: 6,
|
|
s: 12,
|
|
direction: "column",
|
|
alignItems: "stretch",
|
|
children: (0, import_jsx_runtime.jsx)(TimezoneDropdown, {})
|
|
})
|
|
})
|
|
]
|
|
})
|
|
})
|
|
]
|
|
});
|
|
}
|
|
})
|
|
})
|
|
]
|
|
});
|
|
};
|
|
var TimezoneDropdown = () => {
|
|
const permissions = useTypedSelector((state) => {
|
|
var _a;
|
|
return (_a = state.admin_app.permissions["settings"]) == null ? void 0 : _a["releases"];
|
|
});
|
|
const { allowedActions: { canUpdate } } = useRBAC(permissions);
|
|
const { formatMessage } = useIntl();
|
|
const { timezoneList } = getTimezones(/* @__PURE__ */ new Date());
|
|
const field = useField("defaultTimezone");
|
|
return (0, import_jsx_runtime.jsxs)(Field.Root, {
|
|
name: "defaultTimezone",
|
|
hint: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.timezone.hint",
|
|
defaultMessage: "The timezone of every release can still be changed individually. "
|
|
}),
|
|
error: field.error,
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Field.Label, {
|
|
children: formatMessage({
|
|
id: "content-releases.pages.Settings.releases.timezone.label",
|
|
defaultMessage: "Default timezone"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Combobox, {
|
|
autocomplete: {
|
|
type: "list",
|
|
filter: "contains"
|
|
},
|
|
onChange: (value) => field.onChange("defaultTimezone", value),
|
|
onTextValueChange: (value) => field.onChange("defaultTimezone", value),
|
|
onClear: () => field.onChange("defaultTimezone", ""),
|
|
value: field.value,
|
|
disabled: !canUpdate,
|
|
children: timezoneList.map((timezone) => (0, import_jsx_runtime.jsx)(Option, {
|
|
value: timezone.value,
|
|
children: timezone.value.replace(/&/, " ")
|
|
}, timezone.value))
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Field.Hint, {}),
|
|
(0, import_jsx_runtime.jsx)(Field.Error, {})
|
|
]
|
|
});
|
|
};
|
|
var ProtectedReleasesSettingsPage = () => {
|
|
const permissions = useTypedSelector((state) => {
|
|
var _a, _b;
|
|
return (_b = (_a = state.admin_app.permissions["settings"]) == null ? void 0 : _a["releases"]) == null ? void 0 : _b.read;
|
|
});
|
|
return (0, import_jsx_runtime.jsx)(Page.Protect, {
|
|
permissions,
|
|
children: (0, import_jsx_runtime.jsx)(ReleasesSettingsPage, {})
|
|
});
|
|
};
|
|
export {
|
|
ProtectedReleasesSettingsPage
|
|
};
|
|
//# sourceMappingURL=ReleasesSettingsPage-CZCSJTDR.js.map
|