mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Add disableCreate prop to MonitorTable component
This commit is contained in:
@@ -538,7 +538,7 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
// notify owners that no probe is enabled.
|
||||
|
||||
this.notifyOwnersWhenNoProbeIsEnabled({
|
||||
await this.notifyOwnersWhenNoProbeIsEnabled({
|
||||
monitorId: monitorId,
|
||||
isNoProbesEnabled: true,
|
||||
});
|
||||
@@ -556,7 +556,7 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
// notify owners that probes are now enabled.
|
||||
|
||||
this.notifyOwnersWhenNoProbeIsEnabled({
|
||||
await this.notifyOwnersWhenNoProbeIsEnabled({
|
||||
monitorId: monitorId,
|
||||
isNoProbesEnabled: false,
|
||||
});
|
||||
@@ -566,12 +566,15 @@ export class Service extends DatabaseService<Model> {
|
||||
(monitorProbe: MonitorProbe) => {
|
||||
return (
|
||||
monitorProbe.probe?.connectionStatus ===
|
||||
ProbeConnectionStatus.Disconnected
|
||||
ProbeConnectionStatus.Disconnected && monitorProbe.isEnabled
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (disconnectedProbes.length === probesForMonitor.length) {
|
||||
if (
|
||||
disconnectedProbes.length === enabledProbes.length &&
|
||||
enabledProbes.length > 0
|
||||
) {
|
||||
if (!monitor.isAllProbesDisconnectedFromThisMonitor) {
|
||||
// all probes are disconnected.
|
||||
await this.updateOneById({
|
||||
@@ -584,7 +587,7 @@ export class Service extends DatabaseService<Model> {
|
||||
},
|
||||
});
|
||||
|
||||
this.notifyOwnersProbesDisconnected({
|
||||
await this.notifyOwnersProbesDisconnected({
|
||||
monitorId: monitorId,
|
||||
isProbeDisconnected: true,
|
||||
});
|
||||
@@ -600,7 +603,7 @@ export class Service extends DatabaseService<Model> {
|
||||
},
|
||||
});
|
||||
|
||||
this.notifyOwnersProbesDisconnected({
|
||||
await this.notifyOwnersProbesDisconnected({
|
||||
monitorId: monitorId,
|
||||
isProbeDisconnected: false,
|
||||
});
|
||||
@@ -635,9 +638,20 @@ export class Service extends DatabaseService<Model> {
|
||||
return;
|
||||
}
|
||||
|
||||
const monitorId: ObjectID = monitor.id;
|
||||
let doesResourceHasOwners: boolean = true;
|
||||
|
||||
const owners: Array<User> = await this.findOwners(monitorId);
|
||||
let owners: Array<User> = await this.findOwners(monitor.id!);
|
||||
|
||||
if (owners.length === 0) {
|
||||
doesResourceHasOwners = false;
|
||||
|
||||
// find project owners.
|
||||
owners = await ProjectService.getOwners(monitor.projectId!);
|
||||
}
|
||||
|
||||
if (owners.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const title: string = data.isNoProbesEnabled
|
||||
? "No Probes Enabled. This monitor is not being monitored"
|
||||
@@ -650,7 +664,7 @@ export class Service extends DatabaseService<Model> {
|
||||
const vars: Dictionary<string> = {
|
||||
title: title,
|
||||
monitorName: monitor.name!,
|
||||
currentStatus: status,
|
||||
currentStatus: enabledStatus,
|
||||
projectName: monitor.project!.name!,
|
||||
monitorDescription: await Markdown.convertToHTML(
|
||||
monitor.description! || "",
|
||||
@@ -661,6 +675,10 @@ export class Service extends DatabaseService<Model> {
|
||||
).toString(),
|
||||
};
|
||||
|
||||
if (doesResourceHasOwners === true) {
|
||||
vars["isOwner"] = "true";
|
||||
}
|
||||
|
||||
for (const owner of owners) {
|
||||
// send email to the owner.
|
||||
|
||||
@@ -722,9 +740,20 @@ export class Service extends DatabaseService<Model> {
|
||||
return;
|
||||
}
|
||||
|
||||
const monitorId: ObjectID = monitor.id;
|
||||
let doesResourceHasOwners: boolean = true;
|
||||
|
||||
const owners: Array<User> = await this.findOwners(monitorId);
|
||||
let owners: Array<User> = await this.findOwners(monitor.id!);
|
||||
|
||||
if (owners.length === 0) {
|
||||
doesResourceHasOwners = false;
|
||||
|
||||
// find project owners.
|
||||
owners = await ProjectService.getOwners(monitor.projectId!);
|
||||
}
|
||||
|
||||
if (owners.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const status: string = data.isProbeDisconnected
|
||||
? "Disconnected"
|
||||
@@ -744,6 +773,10 @@ export class Service extends DatabaseService<Model> {
|
||||
).toString(),
|
||||
};
|
||||
|
||||
if (doesResourceHasOwners === true) {
|
||||
vars["isOwner"] = "true";
|
||||
}
|
||||
|
||||
for (const owner of owners) {
|
||||
// send email to the owner.
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ export interface ComponentProps {
|
||||
noItemsMessage?: string | undefined;
|
||||
title?: string | undefined;
|
||||
description?: string | undefined;
|
||||
disableCreate?: boolean | undefined;
|
||||
}
|
||||
|
||||
const MonitorsTable: FunctionComponent<ComponentProps> = (
|
||||
@@ -171,7 +172,7 @@ const MonitorsTable: FunctionComponent<ComponentProps> = (
|
||||
isDeleteable={false}
|
||||
showViewIdButton={true}
|
||||
isEditable={false}
|
||||
isCreateable={true}
|
||||
isCreateable={!props.disableCreate}
|
||||
isViewable={true}
|
||||
query={props.query || {}}
|
||||
createEditModalWidth={ModalWidth.Large}
|
||||
|
||||
@@ -9,6 +9,7 @@ const DisabledMonitors: FunctionComponent = (): ReactElement => {
|
||||
projectId: DashboardNavigation.getProjectId()?.toString(),
|
||||
disableActiveMonitoring: true,
|
||||
}}
|
||||
disableCreate={true}
|
||||
noItemsMessage="No disabled monitors. All monitors in active state."
|
||||
title="Disabled Monitors"
|
||||
description="Here is a list of all the monitors which are in disabled state."
|
||||
|
||||
@@ -9,6 +9,7 @@ const DisabledMonitors: FunctionComponent = (): ReactElement => {
|
||||
projectId: DashboardNavigation.getProjectId()?.toString(),
|
||||
isNoProbeEnabledOnThisMonitor: true,
|
||||
}}
|
||||
disableCreate={true}
|
||||
noItemsMessage="No monitors with disabled probes. All your monitors are being monitored."
|
||||
title="Monitors with all probes disabled"
|
||||
description="Here is a list of all the monitors where all probes are disabled. These monitors are not being monitored."
|
||||
|
||||
@@ -9,6 +9,7 @@ const DisabledMonitors: FunctionComponent = (): ReactElement => {
|
||||
projectId: DashboardNavigation.getProjectId()?.toString(),
|
||||
isAllProbesDisconnectedFromThisMonitor: true,
|
||||
}}
|
||||
disableCreate={true}
|
||||
noItemsMessage="No monitors with disconnected probes. All your monitors are being monitored."
|
||||
title="Monitors with all probes disconnected"
|
||||
description="Here is a list of all the monitors where all probes are disconnected. These monitors are not being monitored."
|
||||
|
||||
Reference in New Issue
Block a user