diff --git a/Accounts/.env b/Accounts/.env index e69de29bb2..1e2371cfd5 100644 --- a/Accounts/.env +++ b/Accounts/.env @@ -0,0 +1 @@ +PORT=3003 \ No newline at end of file diff --git a/Accounts/Index.ts b/Accounts/Index.ts index 602cf4f379..63f8754d0e 100755 --- a/Accounts/Index.ts +++ b/Accounts/Index.ts @@ -16,7 +16,10 @@ app.use(ExpressStatic(path.join(__dirname, 'public'))); app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public'))); -app.use([`/${APP_NAME}/assets`,`/${APP_NAME}/${APP_NAME}/assets`], ExpressStatic(path.join(__dirname, 'dist'))); +app.use( + [`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`], + ExpressStatic(path.join(__dirname, 'dist')) +); app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => { res.sendFile(path.join(__dirname, 'public', 'index.html')); @@ -26,7 +29,6 @@ const init: Function = async (): Promise => { try { // init the app await App(APP_NAME); - } catch (err) { logger.error('App Init Failed:'); logger.error(err); diff --git a/Accounts/src/Pages/ForgotPassword.tsx b/Accounts/src/Pages/ForgotPassword.tsx index 6239f97265..3f28a3823e 100644 --- a/Accounts/src/Pages/ForgotPassword.tsx +++ b/Accounts/src/Pages/ForgotPassword.tsx @@ -1,14 +1,18 @@ -import React, { FunctionComponent } from 'react'; -import BasicModelForm from 'CommonUI/src/Components/Forms/BasicModelForm'; +import React, { FunctionComponent, useState } from 'react'; +import ModelForm, { FormType } from 'CommonUI/src/Components/Forms/ModelForm'; import User from 'Model/Models/User'; -import FormValues from 'CommonUI/src/Components/Forms/Types/FormValues'; import Route from 'Common/Types/API/Route'; import FormFieldSchemaType from 'CommonUI/src/Components/Forms/Types/FormFieldSchemaType'; import OneUptimeLogo from 'CommonUI/src/Images/logos/OneUptimePNG/7.png'; import Link from 'CommonUI/src/Components/Link/Link'; +import { FORGOT_PASSWORD_API_URL } from '../Utils/ApiPaths'; +import URL from 'Common/Types/API/URL'; const ForgotPassword: FunctionComponent = () => { - const user: User = new User(); + + const apiUrl: URL = FORGOT_PASSWORD_API_URL; + + const [isSuccess, setIsSuccess] = useState(false); return (
@@ -20,9 +24,11 @@ const ForgotPassword: FunctionComponent = () => {
-
-
+
{
- Reset Password + Forgot Password
-

+ {!isSuccess &&

Please enter your email and the password reset link will be sent to you.{' '} -

+

} + + + {isSuccess &&

+ We have emailed you the password reset link. Please do not forget to check spam.{' '} +

} +
- - model={user} + {!isSuccess && + modelType={User} id="login-form" + apiUrl={apiUrl} fields={[ { field: { @@ -53,12 +66,13 @@ const ForgotPassword: FunctionComponent = () => { required: true, }, ]} - onSubmit={( - _values: FormValues - ) => { }} + onSuccess={() => { + setIsSuccess(true); + }} submitButtonText={ 'Send Password Reset Link' } + formType={FormType.Create} maxPrimaryButtonWidth={true} footer={
@@ -75,7 +89,7 @@ const ForgotPassword: FunctionComponent = () => {

} - /> + />}

diff --git a/Accounts/src/Pages/Login.tsx b/Accounts/src/Pages/Login.tsx index 504a2efb52..f7bc49930e 100644 --- a/Accounts/src/Pages/Login.tsx +++ b/Accounts/src/Pages/Login.tsx @@ -23,9 +23,11 @@ const LoginPage: FunctionComponent = () => {

-
-
+
{
-
-
+
{
-
-
+
{
-
-
+
= 0 && port <= 65535) { - return true - } else { - return false; + return true; } + return false; } public constructor(port: number | string) { diff --git a/CommonServer/.env.tpl b/CommonServer/.env.tpl index 7c175c844b..06fd925e67 100644 --- a/CommonServer/.env.tpl +++ b/CommonServer/.env.tpl @@ -24,4 +24,18 @@ HOME_HOSTNAME={{ .Env.HOME_HOSTNAME }} BILLING_PRIVATE_KEY={{ .Env.BILLING_PRIVATE_KEY }} DOMAIN={{ .Env.DOMAIN }} -HTTP_PROTOCOL={{ .Env.HTTP_PROTOCOL }} \ No newline at end of file +HTTP_PROTOCOL={{ .Env.HTTP_PROTOCOL }} + +REALTIME_ROUTE={{ .Env.REALTIME_ROUTE }} +MAIL_ROUTE={{ .Env.MAIL_ROUTE }} +DASHBOARD_ROUTE={{ .Env.DASHBOARD_ROUTE }} +DASHBOARD_API_ROUTE={{ .Env.DASHBOARD_API_ROUTE }} +PROBE_API_ROUTE={{ .Env.PROBE_API_ROUTE }} +DATA_INGESTOR_ROUTE={{ .Env.DATA_INGESTOR_ROUTE }} +ACCOUNTS_ROUTE={{ .Env.ACCOUNTS_ROUTE }} +HOME_ROUTE={{ .Env.HOME_ROUTE }} +HELMCHARTS_ROUTE={{ .Env.HELMCHARTS_ROUTE }} +APIDOCS_ROUTE={{ .Env.APIDOCS_ROUTE }} +IDENTITY_ROUTE={{ .Env.IDENTITY_ROUTE }} +FILE_ROUTE={{ .Env.FILE_ROUTE }} +STATUS_PAGE_ROUTE={{ .Env.STATUS_PAGE_ROUTE }} \ No newline at end of file diff --git a/CommonServer/Config.ts b/CommonServer/Config.ts index 423a58bba7..fb939bc6c0 100644 --- a/CommonServer/Config.ts +++ b/CommonServer/Config.ts @@ -85,23 +85,36 @@ export const RedisHostname: string = process.env['REDIS_HOST'] || ''; export const RedisPassword: string = process.env['REDIS_PASSWORD'] || ''; export const RedisPort: Port = new Port(process.env['REDIS_PORT'] || ''); +export const DashboardApiRoute: Route = new Route( + process.env['DASHBOARD_API_ROUTE'] || '' +); -export const DashboardApiRoute: Route = new Route(process.env['DASHBOARD_API_ROUTE'] || ''); - -export const IdentityRoute: Route = new Route(process.env['IDENTITY_ROUTE'] || ''); +export const IdentityRoute: Route = new Route( + process.env['IDENTITY_ROUTE'] || '' +); export const FileRoute: Route = new Route(process.env['FILE_ROUTE'] || ''); -export const StausPageRoute: Route = new Route(process.env['STATUS_PAGE_ROUTE'] || ''); +export const StausPageRoute: Route = new Route( + process.env['STATUS_PAGE_ROUTE'] || '' +); -export const DashboardRoute: Route = new Route(process.env['DASHBOARD_ROUTE'] || ''); +export const DashboardRoute: Route = new Route( + process.env['DASHBOARD_ROUTE'] || '' +); -export const IntegrationRoute: Route = new Route(process.env['INTEGRATION_ROUTE'] || ''); +export const IntegrationRoute: Route = new Route( + process.env['INTEGRATION_ROUTE'] || '' +); export const HelmRoute: Route = new Route(process.env['HELMCHART_ROUTE'] || ''); -export const AccountsRoute: Route = new Route(process.env['ACCOUNTS_ROUTE'] || ''); +export const AccountsRoute: Route = new Route( + process.env['ACCOUNTS_ROUTE'] || '' +); -export const ApiDocsRoute: Route = new Route(process.env['APIDOCS_ROUTE'] || ''); +export const ApiDocsRoute: Route = new Route( + process.env['APIDOCS_ROUTE'] || '' +); export const AdminDashboardRoute: Route = new Route( process.env['ADMINDASHBOARD_ROUTE'] || '' diff --git a/CommonServer/Middleware/ClusterKeyAuthorization.ts b/CommonServer/Middleware/ClusterKeyAuthorization.ts index 71b01cb543..b9626f284a 100644 --- a/CommonServer/Middleware/ClusterKeyAuthorization.ts +++ b/CommonServer/Middleware/ClusterKeyAuthorization.ts @@ -34,7 +34,7 @@ export default class ClusterKeyAuthorization { ); } - const isAuthorized: boolean = clusterKey === ONEUPTIME_SECRET; + const isAuthorized: boolean = clusterKey.toString() === ONEUPTIME_SECRET.toString(); if (!isAuthorized) { return Response.sendErrorResponse( diff --git a/CommonServer/Services/MailService.ts b/CommonServer/Services/MailService.ts index a3dc4867ff..b9b07e7886 100644 --- a/CommonServer/Services/MailService.ts +++ b/CommonServer/Services/MailService.ts @@ -15,6 +15,7 @@ export default class MailService { ): Promise> { const body: JSONObject = { ...mail, + clusterKey: ClusterKey.toString() }; if (mailServer) { @@ -28,15 +29,8 @@ export default class MailService { } return await API.post( - new URL( - HttpProtocol, - MailHostname, - new Route('/email/send') - ), - body, - { - clusterkey: ClusterKey.toString(), - } + new URL(HttpProtocol, MailHostname, new Route('/email/send')), + body ); } } diff --git a/Dashboard/Index.ts b/Dashboard/Index.ts index de34676cb4..a0c01f94df 100755 --- a/Dashboard/Index.ts +++ b/Dashboard/Index.ts @@ -16,7 +16,10 @@ app.use(ExpressStatic(path.join(__dirname, 'public'))); app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public'))); -app.use([`/${APP_NAME}/assets`,`/${APP_NAME}/${APP_NAME}/assets`], ExpressStatic(path.join(__dirname, 'dist'))); +app.use( + [`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`], + ExpressStatic(path.join(__dirname, 'dist')) +); app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => { res.sendFile(path.join(__dirname, 'public', 'index.html')); @@ -26,7 +29,6 @@ const init: Function = async (): Promise => { try { // init the app await App(APP_NAME); - } catch (err) { logger.error('App Init Failed:'); logger.error(err); diff --git a/Dashboard/package.json b/Dashboard/package.json index 29e84bbdc6..489bd58f94 100644 --- a/Dashboard/package.json +++ b/Dashboard/package.json @@ -24,7 +24,7 @@ "test": "react-app-rewired test", "eject": "webpack eject", "compile": "tsc", - "start": "webpack serve --port=3009", + "start": "node --require ts-node/register Index.ts", "audit": "npm audit --audit-level=low", "preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'", "dep-check": "depcheck ./ --skip-missing=true'" diff --git a/Identity/API/AuthenticationAPI.ts b/Identity/API/AuthenticationAPI.ts index 51bf329278..90857c782d 100644 --- a/Identity/API/AuthenticationAPI.ts +++ b/Identity/API/AuthenticationAPI.ts @@ -31,6 +31,7 @@ import OneUptimeDate from 'Common/Types/Date'; import PositiveNumber from 'Common/Types/PositiveNumber'; import BaseModel from 'Common/Models/BaseModel'; import Route from 'Common/Types/API/Route'; +import logger from 'CommonServer/Utils/Logger'; const router: ExpressRouter = Express.getRouter(); @@ -86,7 +87,7 @@ router.post( emailVerificationToken && user && alreadySavedUser?.id?.toString() === - emailVerificationToken?.userId?.toString() + emailVerificationToken?.userId?.toString() ) { user.isEmailVerified = true; } @@ -123,18 +124,21 @@ router.post( if (alreadySavedUser) { // Send Welcome Mail - await MailService.sendMail({ + MailService.sendMail({ toEmail: user.email!, - subject: "Welcome to OneUptime.", + subject: 'Welcome to OneUptime.', templateType: EmailTemplateType.WelomeEmail, vars: { name: user.name!.toString(), dashboardUrl: new URL( HttpProtocol, - Domain, DashboardRoute + Domain, + DashboardRoute ).toString(), homeUrl: new URL(HttpProtocol, HomeHostname).toString(), - } + }, + }).catch((err: Error) => { + logger.error(err); }); } else { // Send EmailVerification Link because this is a new user. @@ -144,11 +148,18 @@ router.post( templateType: EmailTemplateType.WelomeEmail, vars: { name: user.name!.toString(), - emailVerificationUrl: new URL(HttpProtocol, Domain, new Route(AccountsRoute.toString()).addRoute("/reset-password/")).toString(), + emailVerificationUrl: new URL( + HttpProtocol, + Domain, + new Route(AccountsRoute.toString()).addRoute( + '/reset-password/' + ) + ).toString(), homeUrl: new URL(HttpProtocol, HomeHostname).toString(), - } - } - ); + }, + }).catch((err: Error) => { + logger.error(err); + }); } if (savedUser) { @@ -171,7 +182,7 @@ router.post( ); router.post( - '/request-reset-password', + '/forgot-password', async ( req: ExpressRequest, res: ExpressResponse, @@ -197,29 +208,36 @@ router.post( }); if (alreadySavedUser) { - - const token = ObjectID.generate().toString(); + const token: string = ObjectID.generate().toString(); await UserService.updateOneBy({ query: { - _id: user._id! + _id: user._id!, }, data: { resetPasswordToken: token, - resetPasswordExpires: OneUptimeDate.getOneDayAfter() + resetPasswordExpires: OneUptimeDate.getOneDayAfter(), }, props: { - isRoot: true - } + isRoot: true, + }, }); MailService.sendMail({ toEmail: user.email!, - subject: "Password Reset Request for OneUptime", + subject: 'Password Reset Request for OneUptime', templateType: EmailTemplateType.ForgotPassword, vars: { homeURL: new URL(HttpProtocol, Domain).toString(), - tokenVerifyUrl: new URL(HttpProtocol, Domain, new Route(AccountsRoute.toString()).addRoute("/reset-password/" + token)).toString(), - } + tokenVerifyUrl: new URL( + HttpProtocol, + Domain, + new Route(AccountsRoute.toString()).addRoute( + '/reset-password/' + token + ) + ).toString(), + }, + }).catch((err: Error) => { + logger.error(err); }); return Response.sendEmptyResponse(req, res); @@ -228,7 +246,6 @@ router.post( throw new BadDataException( `No user is registered with ${user.email?.toString()}` ); - } catch (err) { return next(err); } diff --git a/Mail/API/Mail.ts b/Mail/API/Mail.ts index 150b207e35..3bc2ac3e87 100644 --- a/Mail/API/Mail.ts +++ b/Mail/API/Mail.ts @@ -25,7 +25,7 @@ router.post( toEmail: new Email(body['to-email'] as string), subject: body['subject'] as string, vars: body['vars'] as Dictionary, - body: body['body'] as string || '', + body: (body['body'] as string) || '', }; let mailServer: EmailServer | undefined = undefined; @@ -34,16 +34,19 @@ router.post( mailServer = MailService.getEmailServer(req.body); } - await MailService.send( - mail, mailServer - ); + await MailService.send(mail, mailServer); return Response.sendEmptyResponse(req, res); } ); -const hasMailServerSettingsInBody = (body: JSONObject): boolean => { - return body && Object.keys(body).filter((key) => key.startsWith("SMTP_")).length > 0; -} +const hasMailServerSettingsInBody: Function = (body: JSONObject): boolean => { + return ( + body && + Object.keys(body).filter((key: string) => { + return key.startsWith('SMTP_'); + }).length > 0 + ); +}; export default router; diff --git a/Mail/Services/MailService.ts b/Mail/Services/MailService.ts index 10abd6602c..860839defb 100755 --- a/Mail/Services/MailService.ts +++ b/Mail/Services/MailService.ts @@ -17,75 +17,81 @@ import { JSONObject } from 'Common/Types/JSON'; import logger from 'CommonServer/Utils/Logger'; export default class MailService { - public static isSMTPConfigValid(obj: JSONObject): boolean { if (!obj['SMTP_USERNAME']) { logger.error('SMTP_USERNAME env var not found'); - return false; + return false; } if (!obj['SMTP_EMAIL']) { logger.error('SMTP_EMAIL env var not found'); - return false; + return false; } if (!Email.isValid(obj['SMTP_EMAIL'].toString())) { - logger.error('SMTP_EMAIL env var ' + obj['SMTP_EMAIL'] + ' is not a valid email'); - return false; + logger.error( + 'SMTP_EMAIL env var ' + + obj['SMTP_EMAIL'] + + ' is not a valid email' + ); + return false; } if (!obj['SMTP_FROM_NAME']) { logger.error('SMTP_FROM_NAME env var not found'); - return false; + return false; } if (!obj['SMTP_IS_SECURE']) { logger.error('SMTP_IS_SECURE env var not found'); - return false; + return false; } if (!obj['SMTP_PORT']) { logger.error('SMTP_PORT env var not found'); - return false; + return false; } if (!Port.isValid(obj['SMTP_PORT'].toString())) { - logger.error('SMTP_PORT ' + obj['SMTP_HOST'] + ' env var not valid'); - return false; + logger.error( + 'SMTP_PORT ' + obj['SMTP_HOST'] + ' env var not valid' + ); + return false; } if (!obj['SMTP_HOST']) { logger.error('SMTP_HOST env var not found'); - return false; + return false; } if (!Hostname.isValid(obj['SMTP_HOST'].toString())) { - logger.error('SMTP_HOST env var ' + obj['SMTP_HOST'] + ' not valid'); - return false; + logger.error( + 'SMTP_HOST env var ' + obj['SMTP_HOST'] + ' not valid' + ); + return false; } if (!obj['SMTP_PASSWORD']) { logger.error('SMTP_PASSWORD env var not found'); - return false; + return false; } - return true; + return true; } - public static getEmailServer(obj : JSONObject): EmailServer { + public static getEmailServer(obj: JSONObject): EmailServer { if (!this.isSMTPConfigValid(obj)) { - throw new BadDataException("SMTP Config is not valid"); + throw new BadDataException('SMTP Config is not valid'); } - return { username: obj['SMTP_USERNAME']?.toString()!, - password: obj['SMTP_PASSWORD']?.toString()!, - host: new Hostname(obj['SMTP_HOST']?.toString()!), - port: new Port(obj['SMTP_PORT']?.toString()!), - fromEmail: new Email(obj['SMTP_EMAIL']?.toString()!), - fromName: obj['SMTP_FROM_NAME']?.toString()!, - secure: obj['SMTP_IS_SECURE'] === "true", + password: obj['SMTP_PASSWORD']?.toString()!, + host: new Hostname(obj['SMTP_HOST']?.toString()!), + port: new Port(obj['SMTP_PORT']?.toString()!), + fromEmail: new Email(obj['SMTP_EMAIL']?.toString()!), + fromName: obj['SMTP_FROM_NAME']?.toString()!, + secure: obj['SMTP_IS_SECURE'] === 'true', }; } @@ -93,7 +99,6 @@ export default class MailService { return this.getEmailServer(process.env); } - private static async compileEmailBody( emailTemplateType: EmailTemplateType, vars: Dictionary @@ -193,7 +198,9 @@ export default class MailService { mail.vars['year'] = OneUptimeDate.getCurrentYear().toString(); } - mail.body = mail.templateType ? await this.compileEmailBody(mail.templateType, mail.vars) : this.compileText(mail.body || '', mail.vars); + mail.body = mail.templateType + ? await this.compileEmailBody(mail.templateType, mail.vars) + : this.compileText(mail.body || '', mail.vars); mail.subject = this.compileText(mail.subject, mail.vars); await this.transportMail(mail, EmailServer); diff --git a/Scripts/Install/MergeEnvTemplate.ts b/Scripts/Install/MergeEnvTemplate.ts index 6f66ace094..082640eb82 100644 --- a/Scripts/Install/MergeEnvTemplate.ts +++ b/Scripts/Install/MergeEnvTemplate.ts @@ -1,6 +1,6 @@ // This script merges config.env.tpl to config.env -import fs from 'fs' +import fs from 'fs'; const init: Function = (): void => { const tempate: string = fs.readFileSync('./config.tpl.env', 'utf8'); diff --git a/Scripts/Install/ReplaceValueInConfig.ts b/Scripts/Install/ReplaceValueInConfig.ts index b92532562b..11bd0df1ce 100644 --- a/Scripts/Install/ReplaceValueInConfig.ts +++ b/Scripts/Install/ReplaceValueInConfig.ts @@ -1,7 +1,6 @@ // This script merges config.env.tpl to config.env - -import fs from 'fs' +import fs from 'fs'; const init: Function = (): void => { let env: string = ''; diff --git a/StatusPage/Index.ts b/StatusPage/Index.ts index 730eaedbc4..a2bd170e2a 100755 --- a/StatusPage/Index.ts +++ b/StatusPage/Index.ts @@ -16,7 +16,10 @@ app.use(ExpressStatic(path.join(__dirname, 'public'))); app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public'))); -app.use([`/${APP_NAME}/assets`,`/${APP_NAME}/${APP_NAME}/assets`], ExpressStatic(path.join(__dirname, 'dist'))); +app.use( + [`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`], + ExpressStatic(path.join(__dirname, 'dist')) +); app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => { res.sendFile(path.join(__dirname, 'public', 'index.html')); @@ -26,7 +29,6 @@ const init: Function = async (): Promise => { try { // init the app await App(APP_NAME); - } catch (err) { logger.error('App Init Failed:'); logger.error(err); diff --git a/StatusPage/package.json b/StatusPage/package.json index abd7155014..9b141e6b8a 100644 --- a/StatusPage/package.json +++ b/StatusPage/package.json @@ -24,7 +24,7 @@ "test": "react-app-rewired test", "eject": "webpack eject", "compile": "tsc", - "start": "webpack serve --port=3105", + "start": "node --require ts-node/register Index.ts", "audit": "npm audit --audit-level=low", "preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'", "dep-check": "depcheck ./ --skip-missing=true'" diff --git a/StatusPage/src/App.tsx b/StatusPage/src/App.tsx index e398f4192b..28cc28f875 100644 --- a/StatusPage/src/App.tsx +++ b/StatusPage/src/App.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent, useState } from 'react'; +import React, { FunctionComponent, useState, useEffect } from 'react'; import Route from 'Common/Types/API/Route'; import { Routes, @@ -26,7 +26,6 @@ import 'CommonUI/src/Styles/theme.scss'; import Navigation from 'CommonUI/src/Utils/Navigation'; import { JSONFunctions, JSONObject } from 'Common/Types/JSON'; import RouteParams from './Utils/RouteParams'; -import { useEffect } from 'react'; const App: FunctionComponent = () => { Navigation.setNavigateHook(useNavigate()); @@ -35,10 +34,9 @@ const App: FunctionComponent = () => { const [isPreview, setIsPreview] = useState(false); - useEffect(() => { setIsPreview(isPreviewPage()); - }, []) + }, []); // js. const [javascript, setJavaScript] = useState(null); @@ -49,7 +47,7 @@ const App: FunctionComponent = () => { } }; - const isPreviewPage: Function = (): boolean => { + const isPreviewPage: Function = (): boolean => { const id: string | null = Navigation.getParamByName( RouteParams.StatusPageId, RouteMap[PageMap.PREVIEW_OVERVIEW]! @@ -59,7 +57,7 @@ const App: FunctionComponent = () => { return true; } - return false; + return false; }; return ( @@ -80,7 +78,6 @@ const App: FunctionComponent = () => { = ( footerEventStatus: 'Announced at', footerDateTime: announcement.showAnnouncementAt, eventViewRoute: RouteUtil.populateRouteParams( - props.isPreviewPage ? RouteMap[PageMap.PREVIEW_ANNOUNCEMENT_DETAIL] as Route : RouteMap[PageMap.ANNOUNCEMENT_DETAIL] as Route, + props.isPreviewPage + ? (RouteMap[ + PageMap.PREVIEW_ANNOUNCEMENT_DETAIL + ] as Route) + : (RouteMap[PageMap.ANNOUNCEMENT_DETAIL] as Route), announcement.id! ), }); diff --git a/StatusPage/src/Pages/Incidents/List.tsx b/StatusPage/src/Pages/Incidents/List.tsx index 0c99cf306f..eeb33d3f12 100644 --- a/StatusPage/src/Pages/Incidents/List.tsx +++ b/StatusPage/src/Pages/Incidents/List.tsx @@ -104,7 +104,7 @@ const Overview: FunctionComponent = ( try { setError( (err as HTTPErrorResponse).message || - 'Server Error. Please try again' + 'Server Error. Please try again' ); } catch (e) { setError('Server Error. Please try again'); @@ -177,11 +177,12 @@ const Overview: FunctionComponent = ( eventDescription: incident.description, eventTimeline: timeline, eventType: 'Incident', - eventViewRoute: RouteUtil.populateRouteParams(props.isPreviewPage ? - RouteMap[PageMap.PREVIEW_INCIDENT_DETAIL] as Route : - RouteMap[PageMap.INCIDENT_DETAIL] as Route, - incident.id! - ), + eventViewRoute: RouteUtil.populateRouteParams( + props.isPreviewPage + ? (RouteMap[PageMap.PREVIEW_INCIDENT_DETAIL] as Route) + : (RouteMap[PageMap.INCIDENT_DETAIL] as Route), + incident.id! + ), }); } diff --git a/StatusPage/src/Pages/Overview/Overview.tsx b/StatusPage/src/Pages/Overview/Overview.tsx index 84ff376493..60017d5dd8 100644 --- a/StatusPage/src/Pages/Overview/Overview.tsx +++ b/StatusPage/src/Pages/Overview/Overview.tsx @@ -573,11 +573,14 @@ const Overview: FunctionComponent = ( )} eventType={'Incident'} eventViewRoute={RouteUtil.populateRouteParams( - props.isPreviewPage ? RouteMap[ - PageMap.PREVIEW_INCIDENT_DETAIL - ] as Route : RouteMap[ - PageMap.INCIDENT_DETAIL - ] as Route, + props.isPreviewPage + ? (RouteMap[ + PageMap + .PREVIEW_INCIDENT_DETAIL + ] as Route) + : (RouteMap[ + PageMap.INCIDENT_DETAIL + ] as Route), incidentGroup.incident.id! )} /> @@ -616,11 +619,14 @@ const Overview: FunctionComponent = ( } eventType={'Scheduled Maintenance'} eventViewRoute={RouteUtil.populateRouteParams( - props.isPreviewPage ? RouteMap[ - PageMap.PREVIEW_SCHEDULED_EVENT_DETAIL - ] as Route : RouteMap[ - PageMap.SCHEDULED_EVENT_DETAIL - ] as Route, + props.isPreviewPage + ? (RouteMap[ + PageMap + .PREVIEW_SCHEDULED_EVENT_DETAIL + ] as Route) + : (RouteMap[ + PageMap.SCHEDULED_EVENT_DETAIL + ] as Route), scheduledEventGroup.scheduledMaintenance .id! )} diff --git a/StatusPage/src/Pages/PageComponentProps.ts b/StatusPage/src/Pages/PageComponentProps.ts index bf1c4192e4..46dc241845 100644 --- a/StatusPage/src/Pages/PageComponentProps.ts +++ b/StatusPage/src/Pages/PageComponentProps.ts @@ -5,5 +5,5 @@ export default interface ComponentProps { pageRoute: Route; statusPageId?: ObjectID | null | undefined; onLoadComplete: () => void; - isPreviewPage?: boolean; // if this status page is not hosted on a domain, then this is true, otherwise false. + isPreviewPage?: boolean; // if this status page is not hosted on a domain, then this is true, otherwise false. } diff --git a/StatusPage/src/Pages/ScheduledEvent/List.tsx b/StatusPage/src/Pages/ScheduledEvent/List.tsx index d9d2690225..bf188cee08 100644 --- a/StatusPage/src/Pages/ScheduledEvent/List.tsx +++ b/StatusPage/src/Pages/ScheduledEvent/List.tsx @@ -191,7 +191,11 @@ const Overview: FunctionComponent = ( eventTimeline: timeline, eventType: 'Scheduled Maintenance', eventViewRoute: RouteUtil.populateRouteParams( - props.isPreviewPage ? RouteMap[PageMap.PREVIEW_SCHEDULED_EVENT_DETAIL] as Route : RouteMap[PageMap.SCHEDULED_EVENT_DETAIL] as Route, + props.isPreviewPage + ? (RouteMap[ + PageMap.PREVIEW_SCHEDULED_EVENT_DETAIL + ] as Route) + : (RouteMap[PageMap.SCHEDULED_EVENT_DETAIL] as Route), scheduledMaintenance.id! ), });