Refactor StatusPageAPI to allow subscribers to choose event types

This commit is contained in:
Simon Larsen 2024-10-28 12:53:26 +00:00
parent 33604bba3c
commit 2ad7face9a
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
2 changed files with 33 additions and 1 deletions

View File

@ -251,6 +251,7 @@ export default class StatusPageAPI extends BaseAPI<
enableSmsSubscribers: true,
isPublicStatusPage: true,
allowSubscribersToChooseResources: true,
allowSubscribersToChooseEventTypes: true,
requireSsoForLogin: true,
coverImageFile: {
file: true,

View File

@ -43,10 +43,16 @@ const App: () => JSX.Element = () => {
const [isPreview, setIsPreview] = useState<boolean>(false);
const [enableEmailSubscribers, setenableEmailSubscribers] =
useState<boolean>(true);
const [
const [
allowSubscribersToChooseResources,
setAllowSubscribersToChooseResources,
] = useState<boolean>(false);
const [allowSubscriberToChooseEventTypes, setAllowSubscriberToChooseEventTypes] =
useState<boolean>(false);
const [enableSMSSubscribers, setenableSMSSubscribers] =
useState<boolean>(false);
const [statusPageName, setStatusPageName] = useState<string>("");
@ -130,7 +136,14 @@ const App: () => JSX.Element = () => {
"statusPage.allowSubscribersToChooseResources",
) as boolean;
const allowSubscribersToChooseEventTypes: boolean =
JSONFunctions.getJSONValueInPath(
masterpage || {},
"statusPage.allowSubscribersToChooseEventTypes"
) as boolean;
setAllowSubscribersToChooseResources(allowSubscribersToChooseResources);
setAllowSubscriberToChooseEventTypes(allowSubscribersToChooseEventTypes);
setenableSMSSubscribers(enableSMSSubscribers);
setenableEmailSubscribers(enableEmailSubscribers);
@ -310,6 +323,9 @@ const App: () => JSX.Element = () => {
allowSubscribersToChooseResources={
allowSubscribersToChooseResources
}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
onLoadComplete={() => {
onPageLoadComplete();
}}
@ -330,6 +346,9 @@ const App: () => JSX.Element = () => {
allowSubscribersToChooseResources={
allowSubscribersToChooseResources
}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
enableEmailSubscribers={enableEmailSubscribers}
enableSMSSubscribers={enableSMSSubscribers}
/>
@ -347,6 +366,9 @@ const App: () => JSX.Element = () => {
allowSubscribersToChooseResources={
allowSubscribersToChooseResources
}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
enableEmailSubscribers={enableEmailSubscribers}
enableSMSSubscribers={enableSMSSubscribers}
/>
@ -378,6 +400,9 @@ const App: () => JSX.Element = () => {
allowSubscribersToChooseResources={
allowSubscribersToChooseResources
}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
enableEmailSubscribers={enableEmailSubscribers}
enableSMSSubscribers={enableSMSSubscribers}
/>
@ -395,6 +420,9 @@ const App: () => JSX.Element = () => {
allowSubscribersToChooseResources={
allowSubscribersToChooseResources
}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
enableEmailSubscribers={enableEmailSubscribers}
enableSMSSubscribers={enableSMSSubscribers}
/>
@ -408,6 +436,9 @@ const App: () => JSX.Element = () => {
onLoadComplete={() => {
onPageLoadComplete();
}}
allowSubscribersToChooseEventTypes={
allowSubscriberToChooseEventTypes
}
pageRoute={RouteMap[PageMap.PREVIEW_SUBSCRIBE_SMS] as Route}
allowSubscribersToChooseResources={
allowSubscribersToChooseResources