mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
fix: Refactor code for improved readability and maintainability in various components
This commit is contained in:
parent
387dbf332e
commit
5ebdb1ef7d
6 changed files with 70 additions and 63 deletions
|
|
@ -3,7 +3,10 @@ import ResourceUtil, { ModelDocumentation } from "../Utils/Resources";
|
|||
import PageNotFoundServiceHandler from "./PageNotFound";
|
||||
import { AppApiRoute } from "Common/ServiceRoute";
|
||||
import { ColumnAccessControl } from "Common/Types/BaseDatabase/AccessControl";
|
||||
import { getTableColumns, TableColumnMetadata } from "Common/Types/Database/TableColumn";
|
||||
import {
|
||||
getTableColumns,
|
||||
TableColumnMetadata,
|
||||
} from "Common/Types/Database/TableColumn";
|
||||
import Dictionary from "Common/Types/Dictionary";
|
||||
import ObjectID from "Common/Types/ObjectID";
|
||||
import Permission, {
|
||||
|
|
@ -56,7 +59,9 @@ export default class ServiceHandler {
|
|||
page = "model";
|
||||
|
||||
// Get table columns for current resource
|
||||
const tableColumns: Dictionary<TableColumnMetadata> = getTableColumns(currentResource.model);
|
||||
const tableColumns: Dictionary<TableColumnMetadata> = getTableColumns(
|
||||
currentResource.model,
|
||||
);
|
||||
|
||||
// Filter out columns with no access
|
||||
for (const key in tableColumns) {
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ export default class MonitorTemplateUtil {
|
|||
replaced =
|
||||
replaced !== undefined && replaced !== null ? `${replaced}` : "";
|
||||
|
||||
logger.debug(`Original Value: ${data.value}`);
|
||||
logger.debug(`Replaced Value: ${replaced}`);
|
||||
logger.debug(`Original Value: ${data.value}`);
|
||||
logger.debug(`Replaced Value: ${replaced}`);
|
||||
|
||||
return replaced;
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ export default class VMUtil {
|
|||
);
|
||||
|
||||
let valueToReplaceInPlace: string;
|
||||
|
||||
|
||||
// Properly serialize objects to JSON strings
|
||||
if (typeof foundValue === "object" && foundValue !== null) {
|
||||
valueToReplaceInPlace = JSON.stringify(foundValue, null, 2);
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ const MonitorCriteriaAlertForm: FunctionComponent<ComponentProps> = (
|
|||
},
|
||||
description: (
|
||||
<p>
|
||||
You can use dynamic templates here. <Link
|
||||
You can use dynamic templates here.{" "}
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
for more information.
|
||||
</p>
|
||||
|
|
@ -78,16 +78,14 @@ const MonitorCriteriaAlertForm: FunctionComponent<ComponentProps> = (
|
|||
placeholder: "Description",
|
||||
description: (
|
||||
<p>
|
||||
You can use dynamic templates here.
|
||||
You can use dynamic templates here.
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
|
||||
</p>
|
||||
),
|
||||
},
|
||||
|
|
@ -138,13 +136,13 @@ const MonitorCriteriaAlertForm: FunctionComponent<ComponentProps> = (
|
|||
stepId: "alert-details",
|
||||
description: (
|
||||
<p>
|
||||
You can use dynamic templates here.<Link
|
||||
You can use dynamic templates here.
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
</p>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ const MonitorCriteriaIncidentForm: FunctionComponent<ComponentProps> = (
|
|||
},
|
||||
description: (
|
||||
<p>
|
||||
You can use dynamic templates here. <Link
|
||||
You can use dynamic templates here.{" "}
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
</p>
|
||||
),
|
||||
|
|
@ -76,13 +76,13 @@ const MonitorCriteriaIncidentForm: FunctionComponent<ComponentProps> = (
|
|||
placeholder: "Description",
|
||||
description: (
|
||||
<p>
|
||||
You can use dynamic templates here. <Link
|
||||
You can use dynamic templates here.{" "}
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
</p>
|
||||
),
|
||||
|
|
@ -133,13 +133,13 @@ const MonitorCriteriaIncidentForm: FunctionComponent<ComponentProps> = (
|
|||
description: (
|
||||
<p>
|
||||
Notes for on-call engineer to resolve this incident. You can use
|
||||
dynamic templates here. <Link
|
||||
dynamic templates here.{" "}
|
||||
<Link
|
||||
to={new Route("/docs/monitor/incident-alert-templating")}
|
||||
openInNewTab={true}
|
||||
className="underline text-blue-600"
|
||||
>
|
||||
Please refer to the
|
||||
documentation for more information.
|
||||
Please refer to the documentation for more information.
|
||||
</Link>
|
||||
</p>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -110,8 +110,6 @@ const ProbePage: FunctionComponent<PageComponentProps> = (): ReactElement => {
|
|||
hideOnMobile={true}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ModelTable<Probe>
|
||||
modelType={Probe}
|
||||
query={{
|
||||
|
|
@ -357,51 +355,57 @@ const ProbePage: FunctionComponent<PageComponentProps> = (): ReactElement => {
|
|||
</>
|
||||
|
||||
<CardModelDetail
|
||||
name="Global Probe Settings"
|
||||
cardProps={{
|
||||
title: "Global Probe Settings",
|
||||
name="Global Probe Settings"
|
||||
cardProps={{
|
||||
title: "Global Probe Settings",
|
||||
description:
|
||||
"Configure settings related to the automatic addition of Global Probes to new monitors.",
|
||||
}}
|
||||
isEditable={true}
|
||||
editButtonText="Edit Settings"
|
||||
formFields={[
|
||||
{
|
||||
field: {
|
||||
doNotAddGlobalProbesByDefaultOnNewMonitors: true,
|
||||
},
|
||||
title: "Disable Global Probes on New Monitors",
|
||||
description:
|
||||
"Configure settings related to the automatic addition of Global Probes to new monitors.",
|
||||
}}
|
||||
isEditable={true}
|
||||
editButtonText="Edit Settings"
|
||||
formFields={[
|
||||
"Toggle to enable or disable the automatic addition of Global Probes to new monitors.",
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
},
|
||||
]}
|
||||
modelDetailProps={{
|
||||
modelType: Project,
|
||||
id: "global-probe-auto-add",
|
||||
fields: [
|
||||
{
|
||||
field: {
|
||||
doNotAddGlobalProbesByDefaultOnNewMonitors: true,
|
||||
},
|
||||
title: "Disable Global Probes on New Monitors",
|
||||
fieldType: FieldType.Boolean,
|
||||
title: "Global Probes on New Monitors",
|
||||
description:
|
||||
"Toggle to enable or disable the automatic addition of Global Probes to new monitors.",
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
},
|
||||
]}
|
||||
modelDetailProps={{
|
||||
modelType: Project,
|
||||
id: "global-probe-auto-add",
|
||||
fields: [
|
||||
{
|
||||
field: {
|
||||
doNotAddGlobalProbesByDefaultOnNewMonitors: true,
|
||||
},
|
||||
fieldType: FieldType.Boolean,
|
||||
title: "Global Probes on New Monitors",
|
||||
description:
|
||||
"Toggle to enable or disable the automatic addition of Global Probes to new monitors.",
|
||||
placeholder: "New Monitors will have Global Probes by default",
|
||||
getElement: (item: Project): ReactElement => {
|
||||
return item.doNotAddGlobalProbesByDefaultOnNewMonitors ? (
|
||||
<span>Global probes disabled for new monitors. New monitors will not have Global Probes assigned by default.</span>
|
||||
) : (
|
||||
<span>Global probes enabled for new monitors. New monitors will have Global Probes assigned by default.</span>
|
||||
);
|
||||
}
|
||||
placeholder: "New Monitors will have Global Probes by default",
|
||||
getElement: (item: Project): ReactElement => {
|
||||
return item.doNotAddGlobalProbesByDefaultOnNewMonitors ? (
|
||||
<span>
|
||||
Global probes disabled for new monitors. New monitors will
|
||||
not have Global Probes assigned by default.
|
||||
</span>
|
||||
) : (
|
||||
<span>
|
||||
Global probes enabled for new monitors. New monitors will
|
||||
have Global Probes assigned by default.
|
||||
</span>
|
||||
);
|
||||
},
|
||||
],
|
||||
modelId: ProjectUtil.getCurrentProjectId()!,
|
||||
}}
|
||||
/>
|
||||
},
|
||||
],
|
||||
modelId: ProjectUtil.getCurrentProjectId()!,
|
||||
}}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue