mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Add doNotShowWhenCreating option to Field interface
The Field interface in the CommonUI project has been updated to include a new property, doNotShowWhenCreating. This property allows developers to specify whether a field should be shown in the form when creating a new entity. By setting doNotShowWhenCreating to true, the field will be hidden during the creation process. This change provides more control over the visibility of fields in the form based on the create or edit mode.
This commit is contained in:
@@ -59,6 +59,18 @@ export default class SmsService {
|
||||
smsCost = smsCost * smsSegments;
|
||||
}
|
||||
|
||||
smsLog.toNumber = to;
|
||||
|
||||
smsLog.smsText =
|
||||
options && options.isSensitive
|
||||
? 'This message is sensitive and is not logged'
|
||||
: message;
|
||||
smsLog.smsCostInUSDCents = 0;
|
||||
|
||||
if (options.projectId) {
|
||||
smsLog.projectId = options.projectId;
|
||||
}
|
||||
|
||||
const twilioConfig: TwilioConfig | null =
|
||||
options.customTwilioConfig || (await getTwilioConfig());
|
||||
|
||||
@@ -71,17 +83,7 @@ export default class SmsService {
|
||||
twilioConfig.authToken
|
||||
);
|
||||
|
||||
smsLog.toNumber = to;
|
||||
smsLog.fromNumber = twilioConfig.phoneNumber;
|
||||
smsLog.smsText =
|
||||
options && options.isSensitive
|
||||
? 'This message is sensitive and is not logged'
|
||||
: message;
|
||||
smsLog.smsCostInUSDCents = 0;
|
||||
|
||||
if (options.projectId) {
|
||||
smsLog.projectId = options.projectId;
|
||||
}
|
||||
|
||||
let project: Project | null = null;
|
||||
|
||||
|
||||
@@ -2040,6 +2040,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
}
|
||||
|
||||
statusPageSubscriber.statusPageId = objectId;
|
||||
statusPageSubscriber.sendYouHaveSubscribedMessage = true;
|
||||
statusPageSubscriber.projectId = statusPage.projectId!;
|
||||
statusPageSubscriber.isSubscribedToAllResources = Boolean(
|
||||
req.body.data['isSubscribedToAllResources']
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class MigrationName1718100824584 implements MigrationInterface {
|
||||
public name = 'MigrationName1718100824584';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "StatusPageSubscriber" ADD "sendYouHaveSubscribedMessage" boolean NOT NULL DEFAULT true`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class MigrationName1718101665865 implements MigrationInterface {
|
||||
public name = 'MigrationName1718101665865';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "SmsLog" ALTER COLUMN "fromNumber" DROP NOT NULL`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "SmsLog" ALTER COLUMN "fromNumber" SET NOT NULL`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import { MigrationName1717839110671 } from './1717839110671-MigrationName';
|
||||
import { MigrationName1717849921874 } from './1717849921874-MigrationName';
|
||||
import { MigrationName1717955235341 } from './1717955235341-MigrationName';
|
||||
import { MigrationName1718037833516 } from './1718037833516-MigrationName';
|
||||
import { MigrationName1718100824584 } from './1718100824584-MigrationName';
|
||||
import { MigrationName1718101665865 } from './1718101665865-MigrationName';
|
||||
|
||||
export default [
|
||||
InitialMigration,
|
||||
@@ -12,4 +14,6 @@ export default [
|
||||
MigrationName1717849921874,
|
||||
MigrationName1717955235341,
|
||||
MigrationName1718037833516,
|
||||
MigrationName1718100824584,
|
||||
MigrationName1718101665865,
|
||||
];
|
||||
|
||||
@@ -96,4 +96,5 @@ export default interface Field<TEntity> {
|
||||
|
||||
// set this to true if you want to show this field in the form even when the form is in edit mode.
|
||||
doNotShowWhenEditing?: boolean | undefined;
|
||||
doNotShowWhenCreating?: boolean | undefined;
|
||||
}
|
||||
|
||||
@@ -161,10 +161,14 @@ const ModelTable: <TBaseModel extends BaseModel>(
|
||||
props.formFields?.filter(
|
||||
(field: ModelField<TBaseModel>) => {
|
||||
// If the field has doNotShowWhenEditing set to true, then don't show it when editing
|
||||
return !(
|
||||
field.doNotShowWhenEditing &&
|
||||
modelIdToEdit
|
||||
);
|
||||
|
||||
if (modelIdToEdit) {
|
||||
return !field.doNotShowWhenEditing;
|
||||
}
|
||||
|
||||
// If the field has doNotShowWhenCreating set to true, then don't show it when creating
|
||||
|
||||
return !field.doNotShowWhenCreating;
|
||||
}
|
||||
) || [],
|
||||
steps: props.formSteps || [],
|
||||
|
||||
@@ -126,6 +126,7 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
'Send "You have subscribed to this status page" email to this subscriber?',
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
doNotShowWhenEditing: true,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
@@ -135,6 +136,7 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
description: 'Unsubscribe this email from the status page.',
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
doNotShowWhenCreating: true,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -118,7 +118,17 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
required: true,
|
||||
placeholder: '+11234567890',
|
||||
},
|
||||
|
||||
{
|
||||
field: {
|
||||
sendYouHaveSubscribedMessage: true,
|
||||
},
|
||||
title: 'Send Subscription SMS',
|
||||
description:
|
||||
'Send "You have subscribed to this status page" SMS to this subscriber?',
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
doNotShowWhenEditing: true,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
isUnsubscribed: true,
|
||||
@@ -128,6 +138,7 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
'Unsubscribe this phone number from the status page.',
|
||||
fieldType: FormFieldSchemaType.Toggle,
|
||||
required: false,
|
||||
doNotShowWhenCreating: true,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -148,14 +148,14 @@ export default class SmsLog extends BaseModel {
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({
|
||||
required: true,
|
||||
required: false, // false because we may not have a from number if you dont have a twilio config.
|
||||
type: TableColumnType.Phone,
|
||||
title: 'From Number',
|
||||
description: 'Phone Number SMS was sent from',
|
||||
canReadOnRelationQuery: false,
|
||||
})
|
||||
@Column({
|
||||
nullable: false,
|
||||
nullable: true,
|
||||
type: ColumnType.Phone,
|
||||
length: ColumnLength.Phone,
|
||||
transformer: Phone.getDatabaseTransformer(),
|
||||
|
||||
Reference in New Issue
Block a user