Skip to content

Commit

Permalink
refactor: improve code formatting and readability in UserSettings com…
Browse files Browse the repository at this point in the history
…ponents
  • Loading branch information
simlarsen committed Jan 17, 2025
1 parent 74d21e7 commit 69a3a89
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 43 deletions.
55 changes: 29 additions & 26 deletions Dashboard/src/Pages/UserSettings/AlertOnCallRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import React, {
const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
const [error, setError] = useState<string>("");
const [isLoading, setIsLoading] = useState<boolean>(true);
const [alertSeverities, setAlertSeverities] = useState<
Array<AlertSeverity>
>([]);
const [alertSeverities, setAlertSeverities] = useState<Array<AlertSeverity>>(
[],
);
const [userEmails, setUserEmails] = useState<Array<UserEmail>>([]);
const [userSMSs, setUserSMSs] = useState<Array<UserSMS>>([]);
const [userCalls, setUserCalls] = useState<Array<UserCall>>([]);
Expand Down Expand Up @@ -217,8 +217,8 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
setIsLoading(true);

try {
const alertSeverities: ListResult<AlertSeverity> =
await ModelAPI.getList({
const alertSeverities: ListResult<AlertSeverity> = await ModelAPI.getList(
{
modelType: AlertSeverity,
query: {
projectId: DashboardNavigation.getProjectId()!,
Expand All @@ -229,7 +229,8 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
name: true,
},
sort: {},
});
},
);

const userEmails: ListResult<UserEmail> = await ModelAPI.getList({
modelType: UserEmail,
Expand Down Expand Up @@ -335,26 +336,28 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
return (
<Fragment>
<div>
{alertSeverities.map(
(alertSeverity: AlertSeverity, i: number) => {
return (
<div key={i}>
{getModelTable({
alertSeverity: alertSeverity,
ruleType: NotificationRuleType.ON_CALL_INCIDENT_CREATED,
title:
alertSeverity.name + " Severity Alert: " +" When I am on call and " +
alertSeverity.name + " severity alert" +
" is assigned to me...",
description:
"Here are the rules when you are on call and " +
alertSeverity.name + " Severity alert" +
" is assigned to you.",
})}
</div>
);
},
)}
{alertSeverities.map((alertSeverity: AlertSeverity, i: number) => {
return (
<div key={i}>
{getModelTable({
alertSeverity: alertSeverity,
ruleType: NotificationRuleType.ON_CALL_INCIDENT_CREATED,
title:
alertSeverity.name +
" Severity Alert: " +
" When I am on call and " +
alertSeverity.name +
" severity alert" +
" is assigned to me...",
description:
"Here are the rules when you are on call and " +
alertSeverity.name +
" Severity alert" +
" is assigned to you.",
})}
</div>
);
})}
</div>

{/* <div>
Expand Down
4 changes: 3 additions & 1 deletion Dashboard/src/Pages/UserSettings/IncidentOnCallRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
incidentSeverity: incidentSeverity,
ruleType: NotificationRuleType.ON_CALL_INCIDENT_CREATED,
title:
incidentSeverity.name + " Severity: "+ " When I am on call and " +
incidentSeverity.name +
" Severity: " +
" When I am on call and " +
incidentSeverity.name +
" is assigned to me...",
description:
Expand Down
21 changes: 10 additions & 11 deletions Dashboard/src/Routes/UserSettingsRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const UserSettingsIncidentNotificationRules: LazyExoticComponent<
return import("../Pages/UserSettings/IncidentOnCallRules");
});


const UserSettingsAlertNotificationRules: LazyExoticComponent<

FunctionComponent<ComponentProps>
> = lazy(() => {
return import("../Pages/UserSettings/AlertOnCallRules");
Expand Down Expand Up @@ -83,7 +81,7 @@ const UserSettingsRoutes: FunctionComponent<ComponentProps> = (
<PageRoute
path={
UserSettingsRoutePath[
PageMap.USER_SETTINGS_ON_CALL_LOGS_TIMELINE
PageMap.USER_SETTINGS_ON_CALL_LOGS_TIMELINE
] || ""
}
element={
Expand All @@ -101,7 +99,7 @@ const UserSettingsRoutes: FunctionComponent<ComponentProps> = (
<PageRoute
path={
UserSettingsRoutePath[
PageMap.USER_SETTINGS_NOTIFICATION_SETTINGS
PageMap.USER_SETTINGS_NOTIFICATION_SETTINGS
] || ""
}
element={
Expand Down Expand Up @@ -135,24 +133,28 @@ const UserSettingsRoutes: FunctionComponent<ComponentProps> = (

<PageRoute
path={
UserSettingsRoutePath[PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES] || ""
UserSettingsRoutePath[
PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES
] || ""
}
element={
<Suspense fallback={Loader}>
<UserSettingsIncidentNotificationRules
{...props}
pageRoute={
RouteMap[PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES] as Route
RouteMap[
PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES
] as Route
}
/>
</Suspense>
}
/>


<PageRoute
path={
UserSettingsRoutePath[PageMap.USER_SETTINGS_ALERT_ON_CALL_RULES] || ""
UserSettingsRoutePath[PageMap.USER_SETTINGS_ALERT_ON_CALL_RULES] ||
""
}
element={
<Suspense fallback={Loader}>
Expand All @@ -165,9 +167,6 @@ const UserSettingsRoutes: FunctionComponent<ComponentProps> = (
</Suspense>
}
/>



</PageRoute>
</Routes>
);
Expand Down
9 changes: 4 additions & 5 deletions Dashboard/src/Utils/Breadcrumbs/UserSettingsBreadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ export function getUserSettingsBreadcrumbs(
PageMap.USER_SETTINGS_NOTIFICATION_SETTINGS,
["Project", "User Settings", "Notification Settings"],
),
...BuildBreadcrumbLinksByTitles(PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES, [
"Project",
"User Settings",
"Incident On-Call Rules",
]),
...BuildBreadcrumbLinksByTitles(
PageMap.USER_SETTINGS_INCIDENT_ON_CALL_RULES,
["Project", "User Settings", "Incident On-Call Rules"],
),
...BuildBreadcrumbLinksByTitles(PageMap.USER_SETTINGS_ALERT_ON_CALL_RULES, [
"Project",
"User Settings",
Expand Down

0 comments on commit 69a3a89

Please sign in to comment.