Add hidePoweredByOneUptimeBranding feature

This commit is contained in:
Simon Larsen 2023-11-21 12:35:43 +00:00
parent 5ce3a5d876
commit cf0a76ce71
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
5 changed files with 108 additions and 9 deletions

View File

@ -231,6 +231,7 @@ export default class StatusPageAPI extends BaseAPI<
copyrightText: true,
customCSS: true,
customJavaScript: true,
hidePoweredByOneUptimeBranding: true,
headerHTML: true,
footerHTML: true,
enableSubscribers: true,

View File

@ -49,7 +49,7 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
title: 'Settings',
to: RouteUtil.populateRouteParams(
RouteMap[
PageMap.STATUS_PAGE_VIEW_AUTHENTICATION_SETTINGS
PageMap.STATUS_PAGE_VIEW_AUTHENTICATION_SETTINGS
] as Route,
{ modelId }
),
@ -196,6 +196,44 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
modelId: modelId,
}}
/>
<CardModelDetail<StatusPage>
name="Status Page > Settings"
cardProps={{
title: 'Powered By OneUptime Branding',
description: 'Show or hide the Powered By OneUptime Branding',
}}
editButtonText="Edit Settings"
isEditable={true}
formFields={[
{
field: {
hidePoweredByOneUptimeBranding: true,
},
title: 'Hide Powered By OneUptime Branding',
fieldType: FormFieldSchemaType.Toggle,
required: false,
placeholder: 'No',
}
]}
modelDetailProps={{
showDetailsInNumberOfColumns: 1,
modelType: StatusPage,
id: 'model-detail-status-page',
fields: [
{
field: {
hidePoweredByOneUptimeBranding: true,
},
fieldType: FieldType.Boolean,
title: 'Hide Powered By OneUptime Branding',
}
],
modelId: modelId,
}}
/>
</ModelPage>
);
};

View File

@ -1338,4 +1338,43 @@ export default class StatusPage extends BaseModel {
nullable: true,
})
public overviewPageDescription?: string = undefined;
@ColumnAccessControl({
create: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.CanCreateProjectStatusPage,
],
read: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.CanReadProjectStatusPage,
],
update: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.CanEditProjectStatusPage,
],
})
@TableColumn({
isDefaultValueColumn: true,
type: TableColumnType.Boolean,
title: 'Hide Powered By OneUptime Branding',
description: 'Hide Powered By OneUptime Branding?',
})
@Column({
type: ColumnType.Boolean,
default: false,
})
@ColumnBillingAccessControl({
read: PlanSelect.Free,
update: PlanSelect.Scale,
create: PlanSelect.Free,
})
public hidePoweredByOneUptimeBranding?: boolean = undefined;
}

View File

@ -7,23 +7,31 @@ export interface ComponentProps {
copyright?: string | undefined;
links: Array<Link>;
className?: string | undefined;
hidePoweredByOneUptimeBranding?: boolean | undefined;
}
const StatusPageFooter: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
const links = [
...props.links,
];
if (!props.hidePoweredByOneUptimeBranding) {
links.push({
title: 'Powered by OneUptime',
to: URL.fromString('https://oneuptime.com'),
openInNewTab: true,
});
}
return (
<Footer
className={props.className}
copyright={props.copyright}
links={[
...props.links,
{
title: 'Powered by OneUptime',
to: URL.fromString('https://oneuptime.com'),
openInNewTab: true,
},
]}
links={links}
/>
);
};

View File

@ -59,6 +59,9 @@ const DashboardMasterPage: FunctionComponent<ComponentProps> = (
const [headerHtml, setHeaderHtml] = useState<null | string>(null);
const [footerHtml, setFooterHTML] = useState<null | string>(null);
const [hidePoweredByOneUptimeBranding, setHidePoweredByOneUptimeBranding] =
useState<boolean>(false);
useEffect(() => {
// if there is an SSO token. We need to save that to localstorage.
@ -199,6 +202,15 @@ const DashboardMasterPage: FunctionComponent<ComponentProps> = (
response.data || {},
'statusPage.headerHTML'
) as string | null;
const hidePoweredByOneUptimeBranding: boolean | null = JSONFunctions.getJSONValueInPath(
response.data || {},
'statusPage.hidePoweredByOneUptimeBranding'
) as boolean | null;
setHidePoweredByOneUptimeBranding(Boolean(hidePoweredByOneUptimeBranding));
const footHTML: string | null = JSONFunctions.getJSONValueInPath(
response.data || {},
'statusPage.footerHTML'
@ -307,6 +319,7 @@ const DashboardMasterPage: FunctionComponent<ComponentProps> = (
{props.children}
{!footerHtml ? (
<Footer
hidePoweredByOneUptimeBranding={hidePoweredByOneUptimeBranding}
className="mx-auto w-full py-5 px-0 md:flex md:items-center md:justify-between lg:px-0"
copyright={
(JSONFunctions.getJSONValueInPath(