chore: remove username interface (#2621)

This commit is contained in:
YANG QIA 2023-09-09 00:28:35 +08:00 committed by GitHub
parent 0d465f4d71
commit f736085af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 672 additions and 666 deletions

View File

@ -33,4 +33,3 @@ export * from './time';
export * from './updatedAt';
export * from './updatedBy';
export * from './url';
export * from './username';

View File

@ -2,6 +2,13 @@ import { ISchema } from '@formily/react';
import { defaultProps, operators, unique } from './properties';
import { IField } from './types';
import { i18n } from '../../i18n';
import { registerValidateRules } from '@formily/validator';
registerValidateRules({
username(value) {
return /^[^@.<>"'/]{2,16}$/.test(value) || i18n.t('Must be 2-16 characters in length (excluding @.<>"\'/)');
},
});
export const input: IField = {
name: 'input',

View File

@ -1,40 +0,0 @@
import { i18n } from '../../i18n';
import { defaultProps, operators, unique } from './properties';
import { IField } from './types';
import { registerValidateRules } from '@formily/core';
registerValidateRules({
username(value) {
return /^[^@.<>"'/]{2,16}$/.test(value) || i18n.t('2 to 16 characters (excluding @.<>"\'/)');
},
});
export const username: IField = {
name: 'username',
type: 'object',
group: 'basic',
order: 1,
title: '{{t("Username")}}',
sortable: true,
default: {
type: 'string',
// name,
uiSchema: {
type: 'string',
// title,
'x-component': 'Input',
'x-validator': { username: true },
required: true,
},
},
availableTypes: ['string'],
hasDefaultValue: false,
properties: {
...defaultProps,
unique,
},
filterable: {
operators: operators.string,
},
titleUsable: true,
};

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ export default {
},
},
{
interface: 'username',
interface: 'input',
type: 'string',
name: 'username',
unique: true,

View File

@ -0,0 +1,24 @@
import { Migration } from '@nocobase/server';
export default class UpdateUserNameInterfaceMigration extends Migration {
async up() {
const match = await this.app.version.satisfies('<=0.13.0-alpha.8');
if (!match) {
return;
}
const Field = this.context.db.getRepository('fields');
const field = await Field.findOne({
filter: {
name: 'username',
collectionName: 'users',
interface: 'username',
},
});
if (!field) {
return;
}
await field.update({ interface: 'input' });
}
async down() {}
}