mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-12 06:53:32 +00:00
fix lint.
This commit is contained in:
parent
3ab4407aff
commit
f4c2c0db8f
36 changed files with 312 additions and 219 deletions
|
|
@ -132,18 +132,23 @@ export default class BaseModel extends BaseEntity {
|
|||
return dictionary[columnName] as TableColumnMetadata;
|
||||
}
|
||||
|
||||
public getColumnAccessControlForAllColumns(): Dictionary<ColumnAccessControl>{
|
||||
const dictionary: Dictionary<ColumnAccessControl> = getColumnAccessControlForAllColumns(this);
|
||||
|
||||
const defaultColumns = ['_id', 'createdAt', 'deletedAt', 'updatedAt'];
|
||||
public getColumnAccessControlForAllColumns(): Dictionary<ColumnAccessControl> {
|
||||
const dictionary: Dictionary<ColumnAccessControl> =
|
||||
getColumnAccessControlForAllColumns(this);
|
||||
|
||||
const defaultColumns: Array<string> = [
|
||||
'_id',
|
||||
'createdAt',
|
||||
'deletedAt',
|
||||
'updatedAt',
|
||||
];
|
||||
|
||||
for (const key of defaultColumns) {
|
||||
dictionary[key] = {
|
||||
read: this.readRecordPermissions,
|
||||
create: this.createRecordPermissions,
|
||||
update: this.updateRecordPermissions
|
||||
}
|
||||
update: this.updateRecordPermissions,
|
||||
};
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
|
|
@ -244,7 +249,6 @@ export default class BaseModel extends BaseEntity {
|
|||
if (baseModel.getTableColumnMetadata(key)) {
|
||||
(baseModel as any)[key] = json[key];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return baseModel as T;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ enum ObjectType {
|
|||
Search = 'Search',
|
||||
Port = 'Port',
|
||||
Hostname = 'Hostname',
|
||||
HashedString = 'HashedString'
|
||||
HashedString = 'HashedString',
|
||||
}
|
||||
|
||||
export type JSONValue =
|
||||
|
|
@ -90,7 +90,6 @@ export class JSONFunctions {
|
|||
|
||||
// this funciton serializes JSON with Common Objects to JSON that can be stringified.
|
||||
public static serialize(val: JSONObject): JSONObject {
|
||||
|
||||
const newVal: JSONValue = {};
|
||||
|
||||
for (const key in val) {
|
||||
|
|
@ -108,20 +107,15 @@ export class JSONFunctions {
|
|||
} else {
|
||||
newVal[key] = this.serializeValue(val[key] as JSONValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return newVal;
|
||||
}
|
||||
|
||||
public static serializeValue(val: JSONValue): JSONValue {
|
||||
|
||||
|
||||
if (!val) {
|
||||
return val;
|
||||
}
|
||||
else if (val && val instanceof Name) {
|
||||
} else if (val && val instanceof Name) {
|
||||
return {
|
||||
_type: ObjectType.Name,
|
||||
value: (val as Name).toString(),
|
||||
|
|
@ -191,7 +185,7 @@ export class JSONFunctions {
|
|||
public static deserializeValue(val: JSONValue): JSONValue {
|
||||
if (!val) {
|
||||
return val;
|
||||
} else if (val instanceof DatabaseProperty) {
|
||||
} else if (val instanceof DatabaseProperty) {
|
||||
return val;
|
||||
} else if (
|
||||
val &&
|
||||
|
|
|
|||
|
|
@ -69,17 +69,17 @@ enum Permission {
|
|||
CanDeleteProjectResources = 'CanDeleteProjectResources',
|
||||
CanReadProjectResources = 'CanReadProjectResources',
|
||||
|
||||
// Resource Permissions (Team Permission)
|
||||
CanCreateProjectStatusPage = 'CanCreateProjectStatusPage',
|
||||
CanEditProjectStatusPage = 'CanEditProjectStatusPage',
|
||||
CanDeleteProjectStatusPage = 'CanDeleteProjectStatusPage',
|
||||
// Resource Permissions (Team Permission)
|
||||
CanCreateProjectStatusPage = 'CanCreateProjectStatusPage',
|
||||
CanEditProjectStatusPage = 'CanEditProjectStatusPage',
|
||||
CanDeleteProjectStatusPage = 'CanDeleteProjectStatusPage',
|
||||
CanReadProjectStatusPage = 'CanReadProjectStatusPage',
|
||||
|
||||
// Resource Permissions (Team Permission)
|
||||
CanCreateProjectOnCallDuty = 'CanCreateProjectOnCallDuty',
|
||||
CanEditProjectOnCallDuty = 'CanEditProjectOnCallDuty',
|
||||
CanDeleteProjectOnCallDuty = 'CanDeleteProjectOnCallDuty',
|
||||
CanReadProjectOnCallDuty = 'CanReadProjectOnCallDuty',
|
||||
|
||||
// Resource Permissions (Team Permission)
|
||||
CanCreateProjectOnCallDuty = 'CanCreateProjectOnCallDuty',
|
||||
CanEditProjectOnCallDuty = 'CanEditProjectOnCallDuty',
|
||||
CanDeleteProjectOnCallDuty = 'CanDeleteProjectOnCallDuty',
|
||||
CanReadProjectOnCallDuty = 'CanReadProjectOnCallDuty',
|
||||
|
||||
// Project SMTP Config (Team Permission)
|
||||
CanCreateProjectSMTPConfig = 'CanCreateProjectSMTPConfig',
|
||||
|
|
@ -104,11 +104,9 @@ export class PermissionHelper {
|
|||
permissions1: Array<Permission>,
|
||||
permissions2: Array<Permission>
|
||||
): Array<Permission> {
|
||||
return (
|
||||
permissions1.filter((value: Permission) => {
|
||||
return permissions2.includes(value);
|
||||
})
|
||||
);
|
||||
return permissions1.filter((value: Permission) => {
|
||||
return permissions2.includes(value);
|
||||
});
|
||||
}
|
||||
|
||||
public static getProjectPermissionProps(): Array<PermissionProps> {
|
||||
|
|
@ -420,8 +418,6 @@ export class PermissionHelper {
|
|||
isAssignableToProject: true,
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
permission: Permission.CanCreateProjectStatusPage,
|
||||
title: 'Can Create Status Page',
|
||||
|
|
@ -451,7 +447,6 @@ export class PermissionHelper {
|
|||
isAssignableToProject: true,
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
permission: Permission.CanCreateProjectProbe,
|
||||
title: 'Can Create Probe',
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ export default class BaseAPI<
|
|||
let populate: Populate<BaseModel> = {};
|
||||
let sort: Sort<BaseModel> = {};
|
||||
|
||||
|
||||
if (req.body) {
|
||||
query = JSONFunctions.deserialize(
|
||||
req.body['query']
|
||||
|
|
@ -204,9 +203,10 @@ export default class BaseAPI<
|
|||
req.body['sort']
|
||||
) as Sort<BaseModel>;
|
||||
}
|
||||
|
||||
const databaseProps: DatabaseCommonInteractionProps = this.getDatabaseCommonInteractionProps(req);
|
||||
debugger;
|
||||
|
||||
const databaseProps: DatabaseCommonInteractionProps =
|
||||
this.getDatabaseCommonInteractionProps(req);
|
||||
|
||||
const list: Array<BaseModel> = await this.service.findBy({
|
||||
query,
|
||||
select,
|
||||
|
|
@ -262,7 +262,6 @@ export default class BaseAPI<
|
|||
): Promise<void> {
|
||||
const objectId: ObjectID = new ObjectID(req.params['id'] as string);
|
||||
|
||||
debugger;
|
||||
await this.service.deleteBy({
|
||||
query: {
|
||||
_id: objectId.toString(),
|
||||
|
|
@ -312,8 +311,10 @@ export default class BaseAPI<
|
|||
this.entityType
|
||||
) as TBaseModel;
|
||||
|
||||
const miscDataProps: JSONObject = JSONFunctions.deserialize(body['miscDataProps'] as JSONObject);
|
||||
|
||||
const miscDataProps: JSONObject = JSONFunctions.deserialize(
|
||||
body['miscDataProps'] as JSONObject
|
||||
);
|
||||
|
||||
const createBy: CreateBy<TBaseModel> = {
|
||||
data: item,
|
||||
miscDataProps: miscDataProps,
|
||||
|
|
|
|||
|
|
@ -49,10 +49,9 @@ export default class UserMiddleware {
|
|||
res: ExpressResponse,
|
||||
next: NextFunction
|
||||
): Promise<void> {
|
||||
|
||||
const projectId: ObjectID | null = ProjectMiddleware.getProjectId(req);
|
||||
const oneuptimeRequest: OneUptimeRequest = req as OneUptimeRequest;
|
||||
|
||||
|
||||
if (projectId) {
|
||||
oneuptimeRequest.projectId = projectId;
|
||||
|
||||
|
|
@ -93,7 +92,6 @@ export default class UserMiddleware {
|
|||
oneuptimeRequest.userAuthorization.userId
|
||||
);
|
||||
|
||||
|
||||
if (!userGlobalAccessPermission) {
|
||||
userGlobalAccessPermission =
|
||||
await AccessTokenService.refreshUserGlobalAccessPermission(
|
||||
|
|
@ -127,14 +125,12 @@ export default class UserMiddleware {
|
|||
}
|
||||
|
||||
// set permission hash.
|
||||
|
||||
|
||||
if (oneuptimeRequest.userGlobalAccessPermission) {
|
||||
const serializedValue: JSONObject = JSONFunctions.serialize(
|
||||
oneuptimeRequest.userGlobalAccessPermission
|
||||
);
|
||||
const globalValue: string = JSON.stringify(
|
||||
serializedValue
|
||||
);
|
||||
const globalValue: string = JSON.stringify(serializedValue);
|
||||
const globalPermissionsHash: string = await HashedString.hashValue(
|
||||
globalValue,
|
||||
null
|
||||
|
|
@ -157,7 +153,6 @@ export default class UserMiddleware {
|
|||
|
||||
// set project permissions hash.
|
||||
if (oneuptimeRequest.userProjectAccessPermission) {
|
||||
|
||||
const projectValue: string = JSON.stringify(
|
||||
JSONFunctions.serialize(
|
||||
oneuptimeRequest.userProjectAccessPermission
|
||||
|
|
|
|||
|
|
@ -26,11 +26,10 @@ export default class AccessTokenService {
|
|||
const teamMembers: Array<TeamMember> = await TeamMemberService.findBy({
|
||||
query: {
|
||||
userId: userId,
|
||||
hasAcceptedInvitation: true
|
||||
hasAcceptedInvitation: true,
|
||||
},
|
||||
select: {
|
||||
projectId: true,
|
||||
|
||||
},
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
|
|
@ -63,7 +62,6 @@ export default class AccessTokenService {
|
|||
public static async getUserGlobalAccessPermission(
|
||||
userId: ObjectID
|
||||
): Promise<UserGlobalAccessPermission | null> {
|
||||
|
||||
const json: JSONObject | null = await GlobalCache.getJSON(
|
||||
'user',
|
||||
userId.toString()
|
||||
|
|
@ -73,7 +71,8 @@ export default class AccessTokenService {
|
|||
return null;
|
||||
}
|
||||
|
||||
const accessPermission: UserGlobalAccessPermission = json as UserGlobalAccessPermission;
|
||||
const accessPermission: UserGlobalAccessPermission =
|
||||
json as UserGlobalAccessPermission;
|
||||
|
||||
return accessPermission;
|
||||
}
|
||||
|
|
@ -87,7 +86,7 @@ export default class AccessTokenService {
|
|||
query: {
|
||||
userId: userId,
|
||||
projectId: projectId,
|
||||
hasAcceptedInvitation: true
|
||||
hasAcceptedInvitation: true,
|
||||
},
|
||||
select: {
|
||||
teamId: true,
|
||||
|
|
@ -159,11 +158,11 @@ export default class AccessTokenService {
|
|||
userId: ObjectID,
|
||||
projectId: ObjectID
|
||||
): Promise<UserProjectAccessPermission | null> {
|
||||
|
||||
const json: UserProjectAccessPermission | null = await GlobalCache.getJSON(
|
||||
PermissionNamespace.ProjectPermission,
|
||||
userId.toString() + projectId.toString()
|
||||
) as UserProjectAccessPermission;
|
||||
const json: UserProjectAccessPermission | null =
|
||||
(await GlobalCache.getJSON(
|
||||
PermissionNamespace.ProjectPermission,
|
||||
userId.toString() + projectId.toString()
|
||||
)) as UserProjectAccessPermission;
|
||||
|
||||
return json;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -583,7 +583,13 @@ class DatabaseService<TBaseModel extends BaseModel> {
|
|||
DatabaseRequestType.Read
|
||||
);
|
||||
|
||||
const intersectingPermissions = PermissionHelper.getIntersectingPermissions(userPermissions.map((i) => i.permission), this.model.readRecordPermissions);
|
||||
const intersectingPermissions: Array<Permission> =
|
||||
PermissionHelper.getIntersectingPermissions(
|
||||
userPermissions.map((i: UserPermission) => {
|
||||
return i.permission;
|
||||
}),
|
||||
this.model.readRecordPermissions
|
||||
);
|
||||
|
||||
columns = this.getReadColumnsByPermissions(userPermissions || []);
|
||||
|
||||
|
|
@ -637,7 +643,12 @@ class DatabaseService<TBaseModel extends BaseModel> {
|
|||
);
|
||||
}
|
||||
|
||||
if (this.model.userColumn && findBy.props.userId && intersectingPermissions.length === 0 && this.model.readRecordPermissions.includes(Permission.CurrentUser)) {
|
||||
if (
|
||||
this.model.userColumn &&
|
||||
findBy.props.userId &&
|
||||
intersectingPermissions.length === 0 &&
|
||||
this.model.readRecordPermissions.includes(Permission.CurrentUser)
|
||||
) {
|
||||
(findBy.query as any)[this.model.userColumn] = findBy.props.userId;
|
||||
}
|
||||
|
||||
|
|
@ -768,15 +779,28 @@ class DatabaseService<TBaseModel extends BaseModel> {
|
|||
return deleteBy;
|
||||
}
|
||||
|
||||
const userPermissions: Array<UserPermission> = this.getPermissions(deleteBy.props, DatabaseRequestType.Delete);
|
||||
const intersectingPermissions = PermissionHelper.getIntersectingPermissions(userPermissions.map((i) => i.permission), this.model.deleteRecordPermissions);
|
||||
|
||||
const userPermissions: Array<UserPermission> = this.getPermissions(
|
||||
deleteBy.props,
|
||||
DatabaseRequestType.Delete
|
||||
);
|
||||
const intersectingPermissions: Array<Permission> =
|
||||
PermissionHelper.getIntersectingPermissions(
|
||||
userPermissions.map((i: UserPermission) => {
|
||||
return i.permission;
|
||||
}),
|
||||
this.model.deleteRecordPermissions
|
||||
);
|
||||
|
||||
if (this.model.projectColumn && deleteBy.props.projectId) {
|
||||
(deleteBy.query as any)[this.model.projectColumn] =
|
||||
deleteBy.props.projectId;
|
||||
}
|
||||
|
||||
if (this.model.userColumn && intersectingPermissions.length === 0 && this.model.deleteRecordPermissions.includes(Permission.CurrentUser)) {
|
||||
if (
|
||||
this.model.userColumn &&
|
||||
intersectingPermissions.length === 0 &&
|
||||
this.model.deleteRecordPermissions.includes(Permission.CurrentUser)
|
||||
) {
|
||||
(deleteBy.query as any)[this.model.userColumn] =
|
||||
deleteBy.props.userId;
|
||||
}
|
||||
|
|
@ -846,7 +870,7 @@ class DatabaseService<TBaseModel extends BaseModel> {
|
|||
userPermissions: Array<UserPermission>
|
||||
): Columns {
|
||||
const accessControl: Dictionary<ColumnAccessControl> =
|
||||
this.model.getColumnAccessControlForAllColumns();
|
||||
this.model.getColumnAccessControlForAllColumns();
|
||||
|
||||
const columns: Array<string> = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ export class Service extends DatabaseService<Model> {
|
|||
let ownerTeamMember: TeamMember = new TeamMember();
|
||||
ownerTeamMember.projectId = createdItem.data.id!;
|
||||
ownerTeamMember.userId = createdItem.props.userId!;
|
||||
ownerTeamMember.hasAcceptedInvitation = true;
|
||||
ownerTeamMember.invitationAcceptedAt = OneUptimeDate.getCurrentDate();
|
||||
ownerTeamMember.hasAcceptedInvitation = true;
|
||||
ownerTeamMember.invitationAcceptedAt = OneUptimeDate.getCurrentDate();
|
||||
ownerTeamMember.teamId = ownerTeam.id!;
|
||||
|
||||
ownerTeamMember = await TeamMemberService.create({
|
||||
|
|
|
|||
|
|
@ -12,26 +12,29 @@ export class Service extends DatabaseService<Model> {
|
|||
super(Model, postgresDatabase);
|
||||
}
|
||||
|
||||
protected override async onBeforeCreate(createBy: CreateBy<Model>): Promise<CreateBy<Model>> {
|
||||
|
||||
protected override async onBeforeCreate(
|
||||
createBy: CreateBy<Model>
|
||||
): Promise<CreateBy<Model>> {
|
||||
if (!createBy.data.hasAcceptedInvitation) {
|
||||
createBy.data.hasAcceptedInvitation = false;
|
||||
createBy.data.hasAcceptedInvitation = false;
|
||||
}
|
||||
|
||||
if (createBy.miscDataProps && createBy.miscDataProps["email"]) {
|
||||
const email: Email = new Email(createBy.miscDataProps["email"] as string);
|
||||
|
||||
if (createBy.miscDataProps && createBy.miscDataProps['email']) {
|
||||
const email: Email = new Email(
|
||||
createBy.miscDataProps['email'] as string
|
||||
);
|
||||
|
||||
let user: User | null = await UserService.findByEmail(email, {
|
||||
isRoot: true
|
||||
isRoot: true,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
user = await UserService.createByEmail(email, {
|
||||
isRoot: true
|
||||
})
|
||||
isRoot: true,
|
||||
});
|
||||
}
|
||||
|
||||
createBy.data.userId = user.id!;
|
||||
createBy.data.userId = user.id!;
|
||||
}
|
||||
|
||||
return createBy;
|
||||
|
|
@ -40,7 +43,6 @@ export class Service extends DatabaseService<Model> {
|
|||
protected override async onCreateSuccess(
|
||||
createBy: CreateBy<Model>
|
||||
): Promise<CreateBy<Model>> {
|
||||
|
||||
/// Refresh tokens.
|
||||
await AccessTokenService.refreshUserGlobalAccessPermission(
|
||||
createBy.data.userId!
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export class Service extends DatabaseService<Model> {
|
|||
skip: 0,
|
||||
select: {
|
||||
name: true,
|
||||
isTeamEditable: true
|
||||
isTeamEditable: true,
|
||||
},
|
||||
populate: {},
|
||||
props: updateBy.props,
|
||||
|
|
@ -50,7 +50,7 @@ export class Service extends DatabaseService<Model> {
|
|||
skip: 0,
|
||||
select: {
|
||||
name: true,
|
||||
isTeamDeleteable: true
|
||||
isTeamDeleteable: true,
|
||||
},
|
||||
populate: {},
|
||||
props: deleteBy.props,
|
||||
|
|
|
|||
|
|
@ -3,34 +3,38 @@ import Model from 'Model/Models/User';
|
|||
import DatabaseService from './DatabaseService';
|
||||
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
|
||||
import Email from 'Common/Types/Email';
|
||||
import User from 'Model/Models/User';
|
||||
|
||||
export class Service extends DatabaseService<Model> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
super(Model, postgresDatabase);
|
||||
}
|
||||
|
||||
public async findByEmail(email: Email, props: DatabaseCommonInteractionProps): Promise<Model | null> {
|
||||
|
||||
public async findByEmail(
|
||||
email: Email,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): Promise<Model | null> {
|
||||
return await this.findOneBy({
|
||||
query: {
|
||||
email: email
|
||||
email: email,
|
||||
},
|
||||
select: {
|
||||
_id: true
|
||||
_id: true,
|
||||
},
|
||||
props: props
|
||||
});
|
||||
props: props,
|
||||
});
|
||||
}
|
||||
|
||||
public async createByEmail(email: Email, props: DatabaseCommonInteractionProps): Promise<Model> {
|
||||
const user: Model = new User();
|
||||
user.email = email;
|
||||
public async createByEmail(
|
||||
email: Email,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): Promise<Model> {
|
||||
const user: Model = new Model();
|
||||
user.email = email;
|
||||
|
||||
return await this.create({
|
||||
data:user,
|
||||
props: props
|
||||
});
|
||||
data: user,
|
||||
props: props,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ import { JSONObject } from 'Common/Types/JSON';
|
|||
|
||||
export default interface CreateBy<TBaseModel extends BaseModel> {
|
||||
data: TBaseModel;
|
||||
miscDataProps?: JSONObject
|
||||
miscDataProps?: JSONObject;
|
||||
props: DatabaseCommonInteractionProps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -616,7 +616,11 @@ const BasicForm: Function = <T extends Object>(
|
|||
? field.overideFieldKey
|
||||
: (Object.keys(field.field)[0] as string);
|
||||
if ((values as any)[fieldName]) {
|
||||
(values as any)[fieldName] = new HashedString((values as any)[fieldName], false)
|
||||
(values as any)[fieldName] =
|
||||
new HashedString(
|
||||
(values as any)[fieldName],
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export interface ComponentProps<TBaseModel extends BaseModel> {
|
|||
initialValues?: FormValues<TBaseModel> | undefined;
|
||||
modelIdToEdit?: ObjectID | undefined;
|
||||
onError?: ((error: string) => void) | undefined;
|
||||
onBeforeCreate?: ((item: TBaseModel) => Promise<TBaseModel>) | undefined
|
||||
onBeforeCreate?: ((item: TBaseModel) => Promise<TBaseModel>) | undefined;
|
||||
}
|
||||
|
||||
const ModelForm: Function = <TBaseModel extends BaseModel>(
|
||||
|
|
@ -129,7 +129,7 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
|||
userPermissions.push(Permission.Public);
|
||||
|
||||
const accessControl: Dictionary<ColumnAccessControl> =
|
||||
props.model.getColumnAccessControlForAllColumns();
|
||||
props.model.getColumnAccessControlForAllColumns();
|
||||
|
||||
let fieldsToSet: Fields<TBaseModel> = [];
|
||||
|
||||
|
|
@ -316,19 +316,17 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
|||
}
|
||||
}, []);
|
||||
|
||||
|
||||
const getmiscDataProps: Function = (values: JSONObject): JSONObject => {
|
||||
|
||||
|
||||
const result: JSONObject = {};
|
||||
|
||||
for (const field of fields) {
|
||||
if (field.overideFieldKey && values[field.overideFieldKey]) {
|
||||
result[field.overideFieldKey] = values[field.overideFieldKey] || null;
|
||||
result[field.overideFieldKey] =
|
||||
values[field.overideFieldKey] || null;
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
return result;
|
||||
};
|
||||
|
||||
const onSubmit: Function = async (values: JSONObject): Promise<void> => {
|
||||
|
|
@ -355,14 +353,17 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
|||
(valuesToSend as any)['_id'] = props.modelIdToEdit.toString();
|
||||
}
|
||||
|
||||
let miscDataProps: JSONObject = getmiscDataProps(values);
|
||||
const miscDataProps: JSONObject = getmiscDataProps(values);
|
||||
|
||||
// remove those props from valuesToSend
|
||||
for (const key in miscDataProps) {
|
||||
delete valuesToSend[key];
|
||||
}
|
||||
|
||||
let tBaseModel: TBaseModel = props.model.fromJSON(valuesToSend, props.type);
|
||||
let tBaseModel: TBaseModel = props.model.fromJSON(
|
||||
valuesToSend,
|
||||
props.type
|
||||
);
|
||||
|
||||
if (props.onBeforeCreate && props.formType === FormType.Create) {
|
||||
tBaseModel = await props.onBeforeCreate(tBaseModel);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ enum FormFieldSchemaType {
|
|||
MultiSelectDropdown,
|
||||
Checkbox,
|
||||
Port,
|
||||
EncryptedText
|
||||
EncryptedText,
|
||||
}
|
||||
|
||||
export default FormFieldSchemaType;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import React, { FunctionComponent, ReactElement, useState } from 'react';
|
||||
import Icon, { IconProp } from '../Icon/Icon';
|
||||
|
||||
|
|
@ -14,29 +13,55 @@ const HiddenText: FunctionComponent<ComponentProps> = (
|
|||
const [copiedToClipboard, setCopyToClipboard] = useState<boolean>(false);
|
||||
|
||||
if (!showText) {
|
||||
return <p className='pointer underline' onClick={() => {
|
||||
setShowText(true);
|
||||
}}>
|
||||
Click here to reveal
|
||||
</p>
|
||||
return (
|
||||
<p
|
||||
className="pointer underline"
|
||||
onClick={() => {
|
||||
setShowText(true);
|
||||
}}
|
||||
>
|
||||
Click here to reveal
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (<div>
|
||||
<div className='flex'>
|
||||
<div style={{
|
||||
marginRight: "5px"
|
||||
}}>{props.text}</div> <Icon icon={IconProp.Hide} className='pointer' onClick={() => {
|
||||
setShowText(false);
|
||||
setCopyToClipboard(false);
|
||||
}}/>
|
||||
</div>
|
||||
return (
|
||||
<div>
|
||||
<span className='pointer underline' onClick={() => {
|
||||
navigator.clipboard.writeText(props.text)
|
||||
setCopyToClipboard(true);
|
||||
}}> {copiedToClipboard ? 'Copied to clipboard' : 'Copy to Clipboard'} </span>
|
||||
<div className="flex">
|
||||
<div
|
||||
style={{
|
||||
marginRight: '5px',
|
||||
}}
|
||||
>
|
||||
{props.text}
|
||||
</div>{' '}
|
||||
<Icon
|
||||
icon={IconProp.Hide}
|
||||
className="pointer"
|
||||
onClick={() => {
|
||||
setShowText(false);
|
||||
setCopyToClipboard(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{props.isCopyable && (
|
||||
<div>
|
||||
<span
|
||||
className="pointer underline"
|
||||
onClick={async () => {
|
||||
await navigator.clipboard.writeText(props.text);
|
||||
setCopyToClipboard(true);
|
||||
}}
|
||||
>
|
||||
{' '}
|
||||
{copiedToClipboard
|
||||
? 'Copied to clipboard'
|
||||
: 'Copy to Clipboard'}{' '}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>)
|
||||
);
|
||||
};
|
||||
|
||||
export default HiddenText;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export enum IconProp {
|
|||
Hide,
|
||||
Check,
|
||||
True,
|
||||
False,
|
||||
False,
|
||||
}
|
||||
|
||||
export interface ComponentProps {
|
||||
|
|
@ -123,7 +123,7 @@ const Icon: FunctionComponent<ComponentProps> = ({
|
|||
className,
|
||||
color,
|
||||
thick = ThickProp.Normal,
|
||||
onClick
|
||||
onClick,
|
||||
}: ComponentProps): ReactElement => {
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -14,4 +14,9 @@ export default interface Field<TBaseModel extends BaseModel> {
|
|||
url: Route | URL;
|
||||
openLinkInNewTab?: boolean;
|
||||
};
|
||||
opts?:
|
||||
| {
|
||||
isCopyable?: boolean | undefined;
|
||||
}
|
||||
| undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ enum FieldType {
|
|||
LongText,
|
||||
Color,
|
||||
Port,
|
||||
HiddenText
|
||||
HiddenText,
|
||||
}
|
||||
|
||||
export default FieldType;
|
||||
|
|
|
|||
|
|
@ -182,11 +182,19 @@ const ModelDetail: Function = <TBaseModel extends BaseModel>(
|
|||
}
|
||||
|
||||
if (field.fieldType === FieldType.Date) {
|
||||
data = OneUptimeDate.getDateAsLocalFormattedString(data as string, true);
|
||||
data = OneUptimeDate.getDateAsLocalFormattedString(
|
||||
data as string,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if (field.fieldType === FieldType.HiddenText) {
|
||||
data = (<HiddenText text={data as string}/>)
|
||||
data = (
|
||||
<HiddenText
|
||||
isCopyable={field.opts?.isCopyable || false}
|
||||
text={data as string}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -207,7 +215,7 @@ const ModelDetail: Function = <TBaseModel extends BaseModel>(
|
|||
)}
|
||||
</label>
|
||||
{field.description && <p>{field.description}</p>}
|
||||
|
||||
|
||||
<div
|
||||
className="form-control"
|
||||
style={{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export interface ComponentProps<TBaseModel extends BaseModel> {
|
|||
submitButtonStyleType?: undefined | ButtonStyleType;
|
||||
formProps: ModelFormComponentProps<TBaseModel>;
|
||||
modelIdToEdit?: ObjectID | undefined;
|
||||
onBeforeCreate?: ((item: TBaseModel) => Promise<TBaseModel>) | undefined
|
||||
onBeforeCreate?: ((item: TBaseModel) => Promise<TBaseModel>) | undefined;
|
||||
}
|
||||
|
||||
const ModelFromModal: Function = <TBaseModel extends BaseModel>(
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export interface ComponentProps<TBaseModel extends BaseModel> {
|
|||
currentPageRoute?: undefined | Route;
|
||||
query?: Query<TBaseModel>;
|
||||
onBeforeCreate?: ((item: TBaseModel) => Promise<TBaseModel>) | undefined;
|
||||
createVerb?: string;
|
||||
createVerb?: string;
|
||||
}
|
||||
|
||||
enum ModalType {
|
||||
|
|
@ -141,7 +141,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
props.type,
|
||||
{
|
||||
...query,
|
||||
...props.query
|
||||
...props.query,
|
||||
},
|
||||
itemsOnPage,
|
||||
(currentPageNumber - 1) * itemsOnPage,
|
||||
|
|
@ -571,7 +571,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
<ModelFromModal<TBaseModel>
|
||||
title={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} New ${model.singularName}`
|
||||
? `${props.createVerb || 'Create'} New ${
|
||||
model.singularName
|
||||
}`
|
||||
: `Edit ${model.singularName}`
|
||||
}
|
||||
onClose={() => {
|
||||
|
|
@ -579,7 +581,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
}}
|
||||
submitButtonText={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} ${model.singularName}`
|
||||
? `${props.createVerb || 'Create'} ${
|
||||
model.singularName
|
||||
}`
|
||||
: `Save Changes`
|
||||
}
|
||||
onSuccess={(_item: TBaseModel) => {
|
||||
|
|
|
|||
|
|
@ -47,9 +47,15 @@ const TableRow: FunctionComponent<ComponentProps> = (
|
|||
)
|
||||
) : column.type === TableColumnType.Boolean ? (
|
||||
props.item[column.key] ? (
|
||||
<Icon icon={IconProp.True} thick={ThickProp.Thick} />
|
||||
<Icon
|
||||
icon={IconProp.True}
|
||||
thick={ThickProp.Thick}
|
||||
/>
|
||||
) : (
|
||||
<Icon icon={IconProp.False} thick={ThickProp.Thick} />
|
||||
<Icon
|
||||
icon={IconProp.False}
|
||||
thick={ThickProp.Thick}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
(props.item[
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default class ModelAPI {
|
|||
apiUrl,
|
||||
{
|
||||
data: model.toJSON(),
|
||||
miscDataProps: miscDataProps || {}
|
||||
miscDataProps: miscDataProps || {},
|
||||
},
|
||||
this.getCommonHeaders()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@ const UserElement: FunctionComponent<ComponentProps> = (
|
|||
return (
|
||||
<div>
|
||||
<div>
|
||||
{((props.user.toJSONObject())[
|
||||
'name'
|
||||
]?.toString() as string) || ''}
|
||||
{(props.user.toJSONObject()['name']?.toString() as string) ||
|
||||
''}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{((props.user.toJSONObject())[
|
||||
'email'
|
||||
]?.toString() as string) || ''}
|
||||
{(props.user.toJSONObject()['email']?.toString() as string) ||
|
||||
''}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import LabelElement from '../../Components/Label/Label';
|
|||
const APIKeyView: FunctionComponent<PageComponentProps> = (
|
||||
props: PageComponentProps
|
||||
): ReactElement => {
|
||||
|
||||
|
||||
const modelId: ObjectID = new ObjectID(Navigation.getLastParam()?.toString().substring(1) || '')
|
||||
const modelId: ObjectID = new ObjectID(
|
||||
Navigation.getLastParam()?.toString().substring(1) || ''
|
||||
);
|
||||
|
||||
return (
|
||||
<Page
|
||||
|
|
@ -94,7 +94,7 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
|
|||
validation: {
|
||||
dateShouldBeInTheFuture: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
]}
|
||||
modelDetailProps={{
|
||||
type: ApiKey,
|
||||
|
|
@ -126,6 +126,9 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
|
|||
},
|
||||
title: 'API Key',
|
||||
fieldType: FieldType.HiddenText,
|
||||
opts: {
|
||||
isCopyable: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
modelId: modelId,
|
||||
|
|
@ -139,12 +142,12 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
|
|||
model={new ApiKeyPermission()}
|
||||
id="api-key-permission-table"
|
||||
isDeleteable={true}
|
||||
query={
|
||||
{
|
||||
apiKeyId: modelId
|
||||
}
|
||||
}
|
||||
onBeforeCreate={(item: ApiKeyPermission): Promise<ApiKeyPermission> => {
|
||||
query={{
|
||||
apiKeyId: modelId,
|
||||
}}
|
||||
onBeforeCreate={(
|
||||
item: ApiKeyPermission
|
||||
): Promise<ApiKeyPermission> => {
|
||||
item.apiKeyId = modelId;
|
||||
return Promise.resolve(item);
|
||||
}}
|
||||
|
|
@ -252,9 +255,7 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
|
|||
|
||||
<ModelDelete
|
||||
type={ApiKey}
|
||||
modelId={
|
||||
modelId
|
||||
}
|
||||
modelId={modelId}
|
||||
onDeleteSuccess={() => {
|
||||
Navigation.navigate(
|
||||
RouteMap[PageMap.SETTINGS_APIKEYS] as Route
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ import User from 'Model/Models/User';
|
|||
const TeamView: FunctionComponent<PageComponentProps> = (
|
||||
props: PageComponentProps
|
||||
): ReactElement => {
|
||||
|
||||
const modelId: ObjectID = new ObjectID(Navigation.getLastParam()?.toString().substring(1) || '')
|
||||
const modelId: ObjectID = new ObjectID(
|
||||
Navigation.getLastParam()?.toString().substring(1) || ''
|
||||
);
|
||||
|
||||
return (
|
||||
<Page
|
||||
|
|
@ -123,11 +124,9 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
createVerb={'Invite'}
|
||||
isCreateable={true}
|
||||
isViewable={false}
|
||||
query={
|
||||
{
|
||||
teamId: modelId
|
||||
}
|
||||
}
|
||||
query={{
|
||||
teamId: modelId,
|
||||
}}
|
||||
onBeforeCreate={(item: TeamMember): Promise<TeamPermission> => {
|
||||
item.teamId = modelId;
|
||||
return Promise.resolve(item);
|
||||
|
|
@ -150,7 +149,7 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
fieldType: FormFieldSchemaType.Email,
|
||||
required: false,
|
||||
placeholder: 'member@company.com',
|
||||
overideFieldKey: 'email'
|
||||
overideFieldKey: 'email',
|
||||
},
|
||||
]}
|
||||
showRefreshButton={true}
|
||||
|
|
@ -184,8 +183,7 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
},
|
||||
title: 'Invitation Accepted',
|
||||
type: TableColumnType.Boolean,
|
||||
|
||||
}
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
|
|
@ -199,12 +197,12 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
isEditable={true}
|
||||
isCreateable={true}
|
||||
isViewable={false}
|
||||
query={
|
||||
{
|
||||
teamId: modelId
|
||||
}
|
||||
}
|
||||
onBeforeCreate={(item: TeamPermission): Promise<TeamPermission> => {
|
||||
query={{
|
||||
teamId: modelId,
|
||||
}}
|
||||
onBeforeCreate={(
|
||||
item: TeamPermission
|
||||
): Promise<TeamPermission> => {
|
||||
item.teamId = modelId;
|
||||
return Promise.resolve(item);
|
||||
}}
|
||||
|
|
@ -279,7 +277,6 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
) {
|
||||
let counter: number = 0;
|
||||
for (const label of item['labels']) {
|
||||
|
||||
returnElements.push(
|
||||
<LabelElement
|
||||
key={counter}
|
||||
|
|
@ -291,7 +288,6 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
);
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ router.post(
|
|||
const data: JSONObject = req.body['data'];
|
||||
|
||||
const user: User = User.fromJSON(data as JSONObject, User) as User;
|
||||
|
||||
|
||||
await user.password?.hashValue(EncryptionSecret);
|
||||
|
||||
const alreadySavedUser: User | null = await UserService.findOneBy({
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export default class ApiKey extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,5 @@ export default [
|
|||
ApiKeyPermission,
|
||||
ProjectSmtpConfig,
|
||||
StatusPage,
|
||||
OnCallDuty
|
||||
|
||||
OnCallDuty,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ import EntityName from 'Common/Types/Database/EntityName';
|
|||
Permission.ProjectMember,
|
||||
],
|
||||
delete: [Permission.ProjectOwner, Permission.CanDeleteProjectOnCallDuty],
|
||||
update: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanEditProjectOnCallDuty,
|
||||
],
|
||||
update: [Permission.ProjectOwner, Permission.CanEditProjectOnCallDuty],
|
||||
})
|
||||
@CrudApiEndpoint(new Route('/team'))
|
||||
@SlugifyColumn('name', 'slug')
|
||||
|
|
@ -38,7 +35,10 @@ import EntityName from 'Common/Types/Database/EntityName';
|
|||
@EntityName('OnCallDuty', 'OnCallDutys')
|
||||
export default class OnCallDuty extends BaseModel {
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -66,7 +66,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
public project?: Project = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -75,7 +78,7 @@ export default class OnCallDuty extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
@ -84,7 +87,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
public projectId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -102,7 +108,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
public name?: string = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -120,7 +129,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
|
||||
@Index()
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -138,7 +150,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
public slug?: string = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
@ -166,7 +181,10 @@ export default class OnCallDuty extends BaseModel {
|
|||
public createdByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectOnCallDuty],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectOnCallDuty,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectOnCallDuty,
|
||||
|
|
|
|||
|
|
@ -261,7 +261,6 @@ export default class ProjectSmtpConfig extends BaseModel {
|
|||
})
|
||||
public username?: string = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ import EntityName from 'Common/Types/Database/EntityName';
|
|||
Permission.ProjectMember,
|
||||
],
|
||||
delete: [Permission.ProjectOwner, Permission.CanDeleteProjectStatusPage],
|
||||
update: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanEditProjectStatusPage,
|
||||
],
|
||||
update: [Permission.ProjectOwner, Permission.CanEditProjectStatusPage],
|
||||
})
|
||||
@CrudApiEndpoint(new Route('/team'))
|
||||
@SlugifyColumn('name', 'slug')
|
||||
|
|
@ -38,7 +35,10 @@ import EntityName from 'Common/Types/Database/EntityName';
|
|||
@EntityName('StatusPage', 'StatusPages')
|
||||
export default class StatusPage extends BaseModel {
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -66,7 +66,10 @@ export default class StatusPage extends BaseModel {
|
|||
public project?: Project = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -75,7 +78,7 @@ export default class StatusPage extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
@ -84,7 +87,10 @@ export default class StatusPage extends BaseModel {
|
|||
public projectId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -102,7 +108,10 @@ export default class StatusPage extends BaseModel {
|
|||
public name?: string = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -120,7 +129,10 @@ export default class StatusPage extends BaseModel {
|
|||
|
||||
@Index()
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -138,7 +150,10 @@ export default class StatusPage extends BaseModel {
|
|||
public slug?: string = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
@ -166,7 +181,10 @@ export default class StatusPage extends BaseModel {
|
|||
public createdByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.ProjectOwner, Permission.CanCreateProjectStatusPage],
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanCreateProjectStatusPage,
|
||||
],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.CanReadProjectStatusPage,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export default class Team extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ export default class TeamMember extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
@ -282,7 +282,6 @@ export default class TeamMember extends BaseModel {
|
|||
})
|
||||
public deletedByUserId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
|
|
@ -294,9 +293,7 @@ export default class TeamMember extends BaseModel {
|
|||
Permission.CanReadProjectTeam,
|
||||
Permission.ProjectMember,
|
||||
],
|
||||
update: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@TableColumn({
|
||||
isDefaultValueColumn: true,
|
||||
|
|
@ -311,8 +308,6 @@ export default class TeamMember extends BaseModel {
|
|||
})
|
||||
public hasAcceptedInvitation?: boolean = undefined;
|
||||
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.ProjectOwner,
|
||||
|
|
@ -324,9 +319,7 @@ export default class TeamMember extends BaseModel {
|
|||
Permission.CanReadProjectTeam,
|
||||
Permission.ProjectMember,
|
||||
],
|
||||
update: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@TableColumn({
|
||||
required: false,
|
||||
|
|
@ -335,7 +328,7 @@ export default class TeamMember extends BaseModel {
|
|||
@Column({
|
||||
type: ColumnType.Date,
|
||||
nullable: true,
|
||||
unique: false
|
||||
unique: false,
|
||||
})
|
||||
public invitationAcceptedAt?: Date = undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export default class TeamPermission extends BaseModel {
|
|||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({ type: TableColumnType.ObjectID , required: true })
|
||||
@TableColumn({ type: TableColumnType.ObjectID, required: true })
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue