chore: remove username interface (#2621)
This commit is contained in:
parent
0d465f4d71
commit
f736085af6
@ -33,4 +33,3 @@ export * from './time';
|
|||||||
export * from './updatedAt';
|
export * from './updatedAt';
|
||||||
export * from './updatedBy';
|
export * from './updatedBy';
|
||||||
export * from './url';
|
export * from './url';
|
||||||
export * from './username';
|
|
||||||
|
@ -2,6 +2,13 @@ import { ISchema } from '@formily/react';
|
|||||||
import { defaultProps, operators, unique } from './properties';
|
import { defaultProps, operators, unique } from './properties';
|
||||||
import { IField } from './types';
|
import { IField } from './types';
|
||||||
import { i18n } from '../../i18n';
|
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 = {
|
export const input: IField = {
|
||||||
name: 'input',
|
name: 'input',
|
||||||
|
@ -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
@ -34,7 +34,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
interface: 'username',
|
interface: 'input',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
name: 'username',
|
name: 'username',
|
||||||
unique: true,
|
unique: true,
|
||||||
|
@ -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() {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user