fix lint.

This commit is contained in:
Simon Larsen 2022-09-28 11:42:29 +01:00
parent 70bc204f1b
commit fcdc15a6f3
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
18 changed files with 135 additions and 120 deletions

View File

@ -46,12 +46,13 @@ export class Service extends DatabaseService<Model> {
existingProjectWithSameNameCount = (
await this.countBy({
query: {
_id:
QueryHelper.in(data.props.userGlobalAccessPermission?.projectIds.map(
_id: QueryHelper.in(
data.props.userGlobalAccessPermission?.projectIds.map(
(item: ObjectID) => {
return item.toString();
}
) || []),
) || []
),
name: QueryHelper.findWithSameText(data.data.name!),
},
props: {

View File

@ -26,7 +26,7 @@ const CounterModelAlert: Function = <TBaseModel extends BaseModel>(
useEffect(() => {
fetchCount();
},[props.refreshToggle])
}, [props.refreshToggle]);
const fetchCount: Function = async () => {
setError('');

View File

@ -1,16 +1,22 @@
import React, { FunctionComponent, ReactElement } from 'react';
export interface ComponentProps {
onClick: () => void;
logo: string;
onClick: () => void;
logo: string;
}
const Logo: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
return <img onClick={() => {
props.onClick && props.onClick();
}} src={props.logo} height={30} />
return (
<img
onClick={() => {
props.onClick && props.onClick();
}}
src={props.logo}
height={30}
/>
);
};
export default Logo;

View File

@ -196,12 +196,11 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
}, [tableColumns]);
const deleteItem: Function = async (item: TBaseModel) => {
if (!item.id) {
throw new BadDataException("item.id cannot be null");
throw new BadDataException('item.id cannot be null');
}
setIsLoading(true);
setIsLoading(true);
try {
await ModelAPI.deleteItem<TBaseModel>(
@ -209,7 +208,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
item.id,
props.deleteRequestOptions
);
props.onItemDeleted && props.onItemDeleted(item);
if (data.length === 1 && currentPageNumber > 1) {
@ -1180,9 +1179,11 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
currentDeleteableItem &&
currentDeleteableItem['_id']
) {
deleteItem(
BaseModel.fromJSON(currentDeleteableItem, props.modelType)
BaseModel.fromJSON(
currentDeleteableItem,
props.modelType
)
);
setShowDeleteConfirmModal(false);
}

View File

@ -84,9 +84,7 @@ export default class PermissionUtil {
LocalStorage.setItem('project_permissions', permissions);
}
public static clearProjectPermissions(
): void {
public static clearProjectPermissions(): void {
LocalStorage.setItem('project_permissions', null);
}
}

View File

@ -1,4 +1,4 @@
declare module '*.png';
declare module '*.svg';
declare module '*.jpg';
declare module '*.gif';
declare module '*.gif';

View File

@ -81,10 +81,6 @@ import PageNotFound from './Pages/PageNotFound/PageNotFound';
import Welcome from './Pages/Onboarding/Welcome';
const App: FunctionComponent = () => {
Navigation.setNavigateHook(useNavigate());
Navigation.setLocation(useLocation());
Navigation.setParams(useParams());
@ -105,12 +101,13 @@ const App: FunctionComponent = () => {
const onProjectSelected: (project: Project) => void = (
project: Project
): void => {
setSelectedProject(project);
if (projects.filter((i: Project) => {
return i && i._id === project._id;
}).length === 0) {
if (
projects.filter((i: Project) => {
return i && i._id === project._id;
}).length === 0
) {
setProjects([...projects, project]);
}
@ -145,7 +142,7 @@ const App: FunctionComponent = () => {
} catch (err) {
setError(
(err as HTTPErrorResponse).message ||
'Server Error. Please try again'
'Server Error. Please try again'
);
}
@ -166,7 +163,7 @@ const App: FunctionComponent = () => {
onProjectRequestAccepted={() => {
fetchProjects();
}}
onProjectRequestRejected={() => {
onProjectRequestRejected={() => {
fetchProjects();
}}
showProjectModal={showProjectModal}
@ -199,7 +196,6 @@ const App: FunctionComponent = () => {
}
/>
<PageRoute
path={RouteMap[PageMap.WELCOME]?.toString()}
element={
@ -254,7 +250,7 @@ const App: FunctionComponent = () => {
<MonitorInoperational
pageRoute={
RouteMap[
PageMap.MONITORS_INOPERATIONAL
PageMap.MONITORS_INOPERATIONAL
] as Route
}
currentProject={selectedProject}
@ -292,7 +288,7 @@ const App: FunctionComponent = () => {
<MonitorViewStatusTimeline
pageRoute={
RouteMap[
PageMap.MONITOR_VIEW_STATUS_TIMELINE
PageMap.MONITOR_VIEW_STATUS_TIMELINE
] as Route
}
currentProject={selectedProject}
@ -306,7 +302,7 @@ const App: FunctionComponent = () => {
<MonitorIncidents
pageRoute={
RouteMap[
PageMap.MONITOR_VIEW_INCIDENTS
PageMap.MONITOR_VIEW_INCIDENTS
] as Route
}
currentProject={selectedProject}
@ -356,7 +352,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewDelete
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_DELETE
PageMap.STATUS_PAGE_VIEW_DELETE
] as Route
}
currentProject={selectedProject}
@ -372,7 +368,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewBranding
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_BRANDING
PageMap.STATUS_PAGE_VIEW_BRANDING
] as Route
}
currentProject={selectedProject}
@ -388,7 +384,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewCustomHtmlCss
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_CUSTOM_HTML_CSS
PageMap.STATUS_PAGE_VIEW_CUSTOM_HTML_CSS
] as Route
}
currentProject={selectedProject}
@ -404,7 +400,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewAdvancedOptions
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_ADVANCED_OPTIONS
PageMap.STATUS_PAGE_VIEW_ADVANCED_OPTIONS
] as Route
}
currentProject={selectedProject}
@ -420,7 +416,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewEmailSubscribers
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_EMAIL_SUBSCRIBERS
PageMap.STATUS_PAGE_VIEW_EMAIL_SUBSCRIBERS
] as Route
}
currentProject={selectedProject}
@ -436,7 +432,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewSMSSubscribers
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_SMS_SUBSCRIBERS
PageMap.STATUS_PAGE_VIEW_SMS_SUBSCRIBERS
] as Route
}
currentProject={selectedProject}
@ -452,7 +448,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewWebhookSubscribers
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_WEBHOOK_SUBSCRIBERS
PageMap.STATUS_PAGE_VIEW_WEBHOOK_SUBSCRIBERS
] as Route
}
currentProject={selectedProject}
@ -468,7 +464,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewEmbedded
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_EMBEDDED
PageMap.STATUS_PAGE_VIEW_EMBEDDED
] as Route
}
currentProject={selectedProject}
@ -484,7 +480,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewResources
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_RESOURCES
PageMap.STATUS_PAGE_VIEW_RESOURCES
] as Route
}
currentProject={selectedProject}
@ -500,7 +496,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewDomains
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_DOMAINS
PageMap.STATUS_PAGE_VIEW_DOMAINS
] as Route
}
currentProject={selectedProject}
@ -514,7 +510,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewGroups
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_GROUPS
PageMap.STATUS_PAGE_VIEW_GROUPS
] as Route
}
currentProject={selectedProject}
@ -530,7 +526,7 @@ const App: FunctionComponent = () => {
<StatusPagesViewAnnouncement
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_ANNOUNCEMENTS
PageMap.STATUS_PAGE_VIEW_ANNOUNCEMENTS
] as Route
}
currentProject={selectedProject}
@ -592,7 +588,7 @@ const App: FunctionComponent = () => {
<IncidentViewStateTimeline
pageRoute={
RouteMap[
PageMap.INCIDENT_VIEW_STATE_TIMELINE
PageMap.INCIDENT_VIEW_STATE_TIMELINE
] as Route
}
currentProject={selectedProject}
@ -606,7 +602,7 @@ const App: FunctionComponent = () => {
<IncidentInternalNote
pageRoute={
RouteMap[
PageMap.INCIDENT_INTERNAL_NOTE
PageMap.INCIDENT_INTERNAL_NOTE
] as Route
}
currentProject={selectedProject}
@ -657,7 +653,7 @@ const App: FunctionComponent = () => {
onProjectDeleted={() => {
setSelectedProject(null);
setProjects([]);
fetchProjects();
fetchProjects();
Navigation.navigate(RouteMap[PageMap.INIT]!);
}}
pageRoute={
@ -676,7 +672,7 @@ const App: FunctionComponent = () => {
<SettingsMonitors
pageRoute={
RouteMap[
PageMap.SETTINGS_MONITORS_STATUS
PageMap.SETTINGS_MONITORS_STATUS
] as Route
}
currentProject={selectedProject}
@ -692,7 +688,7 @@ const App: FunctionComponent = () => {
<SettingsIncidents
pageRoute={
RouteMap[
PageMap.SETTINGS_INCIDENTS_STATE
PageMap.SETTINGS_INCIDENTS_STATE
] as Route
}
currentProject={selectedProject}
@ -708,7 +704,7 @@ const App: FunctionComponent = () => {
<SettingsIncidentSeverity
pageRoute={
RouteMap[
PageMap.SETTINGS_INCIDENTS_SEVERITY
PageMap.SETTINGS_INCIDENTS_SEVERITY
] as Route
}
currentProject={selectedProject}

View File

@ -23,7 +23,7 @@ export interface ComponentProps {
onProjectRequestRejected: () => void;
selectedProject: Project | null;
showProjectModal: boolean;
onProjectModalClose: () => void;
onProjectModalClose: () => void;
}
const DashboardHeader: FunctionComponent<ComponentProps> = (
@ -34,22 +34,29 @@ const DashboardHeader: FunctionComponent<ComponentProps> = (
const [showActiveIncidentsModal, setShowActiveIncidentsModal] =
useState<boolean>(false);
const [projectCountRefreshToggle, setProjectCountRefreshToggle] = useState<boolean>(true);
const [projectCountRefreshToggle, setProjectCountRefreshToggle] =
useState<boolean>(true);
return (
<>
<Header
leftComponents={
<>
{props.projects.length === 0 && <Logo onClick={()=>{}}/>}
{props.projects.length === 0 && (
<Logo onClick={() => {}} />
)}
<ProjectPicker
showProjectModal={props.showProjectModal}
onProjectModalClose={props.onProjectModalClose}
projects={props.projects}
onProjectSelected={props.onProjectSelected}
/>
<SearchBox key={2} selectedProject={props.selectedProject} onChange={(_value: string) => {}} />
<SearchBox
key={2}
selectedProject={props.selectedProject}
onChange={(_value: string) => {}}
/>
<div
style={{
marginLeft: '15px',
@ -109,11 +116,15 @@ const DashboardHeader: FunctionComponent<ComponentProps> = (
}}
onRequestAccepted={() => {
props.onProjectRequestAccepted();
setProjectCountRefreshToggle(!projectCountRefreshToggle);
setProjectCountRefreshToggle(
!projectCountRefreshToggle
);
}}
onRequestRejected={() => {
props.onProjectRequestRejected();
setProjectCountRefreshToggle(!projectCountRefreshToggle);
setProjectCountRefreshToggle(
!projectCountRefreshToggle
);
}}
/>
)}

View File

@ -1,17 +1,24 @@
import React, { FunctionComponent, ReactElement } from 'react';
import FullLogo from "CommonUI/src/Components/Header/Logo";
import FullLogo from 'CommonUI/src/Components/Header/Logo';
import OneUptimeLogo from 'CommonUI/src/Images/logos/OneUptimePNG/7.png';
export interface ComponentProps {
onClick: () => void;
onClick: () => void;
}
const Logo: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
return <div className='flex items-center' style={{marginLeft: "-25px"}}><FullLogo onClick={() => {
props.onClick && props.onClick();
}} logo={`/dashboard/public/${OneUptimeLogo}`} /></div>
return (
<div className="flex items-center" style={{ marginLeft: '-25px' }}>
<FullLogo
onClick={() => {
props.onClick && props.onClick();
}}
logo={`/dashboard/public/${OneUptimeLogo}`}
/>
</div>
);
};
export default Logo;

View File

@ -14,7 +14,7 @@ import ObjectID from 'Common/Types/ObjectID';
export interface ComponentProps {
onClose: () => void;
onRequestAccepted: () => void;
onRequestRejected: () => void;
onRequestRejected: () => void;
}
const ProjectInvitationsModal: FunctionComponent<ComponentProps> = (

View File

@ -16,13 +16,12 @@ export interface ComponentProps {
projects: Array<Project>;
onProjectSelected: (project: Project) => void;
showProjectModal: boolean;
onProjectModalClose: () => void;
onProjectModalClose: () => void;
}
const DashboardProjectPicker: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
const [showModel, setShowModel] = useState<boolean>(false);
const [selectedProject, setSelectedProject] = useState<Project | null>(
null
@ -79,21 +78,22 @@ const DashboardProjectPicker: FunctionComponent<ComponentProps> = (
}
}, [props.projects]);
return (
<>
{props.projects.length !== 0 && <ProjectPicker
selectedProjectName={selectedProject?.name || ''}
selectedProjectIcon={IconProp.Folder}
projects={props.projects}
onCreateProjectButtonClicked={() => {
setShowModel(true);
props.onProjectModalClose();
}}
onProjectSelected={(project: Project) => {
setSelectedProject(project);
}}
/>}
{props.projects.length !== 0 && (
<ProjectPicker
selectedProjectName={selectedProject?.name || ''}
selectedProjectIcon={IconProp.Folder}
projects={props.projects}
onCreateProjectButtonClicked={() => {
setShowModel(true);
props.onProjectModalClose();
}}
onProjectSelected={(project: Project) => {
setSelectedProject(project);
}}
/>
)}
{showModel ? (
<ModelFormModal<Project>
modelType={Project}

View File

@ -7,16 +7,14 @@ export interface ComponentProps {
selectedProject: Project | null;
}
const Search: FunctionComponent<ComponentProps> = (props: ComponentProps): ReactElement => {
const Search: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
if (!props.selectedProject) {
return <></>
return <></>;
}
return (
<SearchBox key={2} onChange={props.onChange} />
);
return <SearchBox key={2} onChange={props.onChange} />;
};
export default Search;

View File

@ -13,12 +13,13 @@ export interface ComponentProps {
show: boolean;
}
const DashboardNavbar: FunctionComponent<ComponentProps> = (props: ComponentProps): ReactElement => {
const DashboardNavbar: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
if (!props.show) {
return <></>;
}
return (
<NavBar
rightContent={

View File

@ -8,9 +8,9 @@ import PageMap from '../../Utils/PageMap';
import RouteMap from '../../Utils/RouteMap';
import PageComponentProps from '../PageComponentProps';
export interface ComponentProps extends PageComponentProps {
isLoadingProjects: boolean;
projects: Array<Project>
export interface ComponentProps extends PageComponentProps {
isLoadingProjects: boolean;
projects: Array<Project>;
}
const Init: FunctionComponent<ComponentProps> = (
@ -30,9 +30,7 @@ const Init: FunctionComponent<ComponentProps> = (
// set slug to latest project and redirect to home.
if (!props.isLoadingProjects && props.projects.length === 0) {
Navigation.navigate(
RouteMap[PageMap.WELCOME] as Route
);
Navigation.navigate(RouteMap[PageMap.WELCOME] as Route);
}
}, [props.projects]);

View File

@ -1,7 +1,10 @@
import React, { FunctionComponent, ReactElement } from 'react';
import PageComponentProps from '../PageComponentProps';
import Page from 'CommonUI/src/Components/Page/Page';
import Button, { ButtonSize, ButtonStyleType } from 'CommonUI/src/Components/Button/Button';
import Button, {
ButtonSize,
ButtonStyleType,
} from 'CommonUI/src/Components/Button/Button';
export interface ComponentProps extends PageComponentProps {
onClickShowProjectModal: () => void;
@ -10,18 +13,20 @@ export interface ComponentProps extends PageComponentProps {
const Welcome: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
return (
<Page
title={'Welcome to OneUptime.'}
breadcrumbLinks={[
]}
>
<p>Welcome to OneUptime. Thank you for signing up! To get started please create a new project.</p>
<Button onClick={() => {
props.onClickShowProjectModal();
}} title="Create New Project" buttonSize={ButtonSize.Normal} buttonStyle={ButtonStyleType.PRIMARY} />
<Page title={'Welcome to OneUptime.'} breadcrumbLinks={[]}>
<p>
Welcome to OneUptime. Thank you for signing up! To get started
please create a new project.
</p>
<Button
onClick={() => {
props.onClickShowProjectModal();
}}
title="Create New Project"
buttonSize={ButtonSize.Normal}
buttonStyle={ButtonStyleType.PRIMARY}
/>
</Page>
);
};

View File

@ -12,8 +12,8 @@ import ObjectID from 'Common/Types/ObjectID';
import ProjectUtil from 'CommonUI/src/Utils/Project';
import PermissionUtil from 'CommonUI/src/Utils/Permission';
export interface ComponentProps extends PageComponentProps {
onProjectDeleted: () => void;
export interface ComponentProps extends PageComponentProps {
onProjectDeleted: () => void;
}
const Settings: FunctionComponent<ComponentProps> = (

View File

@ -198,20 +198,14 @@ const TeamView: FunctionComponent<PageComponentProps> = (
if (item['hasAcceptedInvitation']) {
return (
<Pill
text='Invitation Accepted'
text="Invitation Accepted"
color={Green}
/>
);
} else {
return (
<Pill
text='Invitation Sent'
color={Yellow}
/>
);
}
return <></>;
return (
<Pill text="Invitation Sent" color={Yellow} />
);
},
},
]}

View File

@ -6,7 +6,6 @@ import PageMap from './PageMap';
import RouteParams from './RouteParams';
import ObjectID from 'Common/Types/ObjectID';
const RouteMap: Dictionary<Route> = {
[PageMap.INIT]: new Route(`/dashboard`),