mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Add showEvenIfPermissionDoesNotExist property to Field interface
This commit is contained in:
@@ -167,7 +167,7 @@ const RegisterPage: () => JSX.Element = () => {
|
||||
title: 'Confirm Password',
|
||||
overrideFieldKey: 'confirmPassword',
|
||||
required: true,
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -118,7 +118,11 @@ const ModelForm: <TBaseModel extends BaseModel>(
|
||||
? (Object.keys(field.field)[0] as string)
|
||||
: null;
|
||||
|
||||
if (key && (hasPermissionOnField(key) || field.forceShow)) {
|
||||
if (
|
||||
key &&
|
||||
(hasPermissionOnField(key) ||
|
||||
field.showEvenIfPermissionDoesNotExist)
|
||||
) {
|
||||
(select as Dictionary<boolean>)[key] = true;
|
||||
}
|
||||
}
|
||||
@@ -224,7 +228,7 @@ const ModelForm: <TBaseModel extends BaseModel>(
|
||||
const hasPermission: boolean = hasPermissionOnField(key);
|
||||
|
||||
if (
|
||||
(field.forceShow || hasPermission) &&
|
||||
(field.showEvenIfPermissionDoesNotExist || hasPermission) &&
|
||||
fieldsToSet.filter((i: ModelField<TBaseModel>) => {
|
||||
const fieldObj:
|
||||
| {
|
||||
|
||||
@@ -45,7 +45,7 @@ export default interface Field<TEntity> {
|
||||
description?: string;
|
||||
field?: SelectFormFields<TEntity> | undefined;
|
||||
placeholder?: string;
|
||||
forceShow?: boolean; // show this field even if user does not have permissions to view.
|
||||
showEvenIfPermissionDoesNotExist?: boolean; // show this field even if user does not have permissions to view.
|
||||
disabled?: boolean;
|
||||
stepId?: string | undefined;
|
||||
required?: boolean | ((item: FormValues<TEntity>) => boolean) | undefined;
|
||||
|
||||
@@ -343,7 +343,7 @@ const IncidentsTable: FunctionComponent<ComponentProps> = (
|
||||
overrideField: {
|
||||
ownerTeams: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Teams',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
@@ -362,7 +362,7 @@ const IncidentsTable: FunctionComponent<ComponentProps> = (
|
||||
overrideField: {
|
||||
ownerUsers: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Users',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
|
||||
@@ -174,7 +174,7 @@ const ScheduledMaintenancesTable: FunctionComponent<ComponentProps> = (
|
||||
overrideField: {
|
||||
ownerTeams: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Teams',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
@@ -193,7 +193,7 @@ const ScheduledMaintenancesTable: FunctionComponent<ComponentProps> = (
|
||||
overrideField: {
|
||||
ownerUsers: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Users',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
|
||||
@@ -150,7 +150,7 @@ const OnCallPolicyDelete: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
teams: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Teams',
|
||||
stepId: 'notification',
|
||||
description:
|
||||
@@ -169,7 +169,7 @@ const OnCallPolicyDelete: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
onCallSchedules: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'On Call Duty Schedules',
|
||||
stepId: 'notification',
|
||||
description:
|
||||
@@ -188,7 +188,7 @@ const OnCallPolicyDelete: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
users: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Users',
|
||||
stepId: 'notification',
|
||||
description:
|
||||
|
||||
@@ -210,7 +210,7 @@ const IncidentTemplates: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
ownerTeams: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Teams',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
@@ -229,7 +229,7 @@ const IncidentTemplates: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
ownerUsers: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Owner - Users',
|
||||
stepId: 'owners',
|
||||
description:
|
||||
|
||||
@@ -146,7 +146,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
|
||||
overrideField: {
|
||||
notificationMethod: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
overrideFieldKey: 'notificationMethod',
|
||||
title: 'Notification Method',
|
||||
description: 'How do you want to be notified?',
|
||||
|
||||
@@ -117,7 +117,7 @@ const ForgotPassword: FunctionComponent<ComponentProps> = (
|
||||
email: true,
|
||||
},
|
||||
title: 'Email',
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
fieldType: FormFieldSchemaType.Email,
|
||||
required: true,
|
||||
},
|
||||
|
||||
@@ -132,7 +132,7 @@ const LoginPage: FunctionComponent<ComponentProps> = (
|
||||
field: {
|
||||
email: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Email',
|
||||
fieldType: FormFieldSchemaType.Email,
|
||||
required: true,
|
||||
@@ -143,7 +143,7 @@ const LoginPage: FunctionComponent<ComponentProps> = (
|
||||
},
|
||||
title: 'Password',
|
||||
required: true,
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
validation: {
|
||||
minLength: 6,
|
||||
},
|
||||
|
||||
@@ -122,7 +122,7 @@ const ResetPassword: FunctionComponent<ComponentProps> = (
|
||||
field: {
|
||||
password: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
fieldType: FormFieldSchemaType.Password,
|
||||
validation: {
|
||||
minLength: 6,
|
||||
@@ -139,7 +139,7 @@ const ResetPassword: FunctionComponent<ComponentProps> = (
|
||||
minLength: 6,
|
||||
toMatchField: 'password',
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
fieldType: FormFieldSchemaType.Password,
|
||||
placeholder: 'Confirm Password',
|
||||
title: 'Confirm Password',
|
||||
|
||||
@@ -107,7 +107,7 @@ const SubscribePage: FunctionComponent<SubscribePageProps> = (
|
||||
field: {
|
||||
subscriberEmail: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Your Email',
|
||||
fieldType: FormFieldSchemaType.Email,
|
||||
required: (model: FormValues<StatusPageSubscriber>) => {
|
||||
@@ -123,7 +123,7 @@ const SubscribePage: FunctionComponent<SubscribePageProps> = (
|
||||
field: {
|
||||
subscriberPhone: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Your Phone Number',
|
||||
fieldType: FormFieldSchemaType.Email,
|
||||
required: (model: FormValues<StatusPageSubscriber>) => {
|
||||
@@ -142,7 +142,7 @@ const SubscribePage: FunctionComponent<SubscribePageProps> = (
|
||||
field: {
|
||||
isSubscribedToAllResources: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Subscribe to All Resources',
|
||||
description:
|
||||
'Select this option if you want to subscribe to all resources.',
|
||||
@@ -155,7 +155,7 @@ const SubscribePage: FunctionComponent<SubscribePageProps> = (
|
||||
field: {
|
||||
statusPageResources: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Select Resources to Subscribe',
|
||||
description:
|
||||
'Please select the resources you want to subscribe to.',
|
||||
@@ -172,7 +172,7 @@ const SubscribePage: FunctionComponent<SubscribePageProps> = (
|
||||
field: {
|
||||
isUnsubscribed: true,
|
||||
},
|
||||
forceShow: true,
|
||||
showEvenIfPermissionDoesNotExist: true,
|
||||
title: 'Unsubscribe',
|
||||
description:
|
||||
'Please select this if you would like to unsubscribe from all resources.',
|
||||
|
||||
Reference in New Issue
Block a user