From ca750eb1233960a9f50ad5c902d8f09fb3e9bb2c Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Wed, 6 Jul 2022 16:12:46 +0600 Subject: [PATCH] Show workspace name rules (#2217) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- packages/ui/src/components/Status.svelte | 5 +++-- plugins/login-assets/lang/en.json | 5 +++-- plugins/login-assets/lang/ru.json | 5 +++-- .../src/components/CreateWorkspaceForm.svelte | 9 ++++++++- plugins/login-resources/src/components/Form.svelte | 6 +++++- .../login-resources/src/components/StatusControl.svelte | 2 +- plugins/login-resources/src/plugin.ts | 5 +++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/components/Status.svelte b/packages/ui/src/components/Status.svelte index 7058676b38..5636c6a656 100644 --- a/packages/ui/src/components/Status.svelte +++ b/packages/ui/src/components/Status.svelte @@ -6,12 +6,13 @@ import Label from './Label.svelte' export let status: Status + export let overflow: boolean = true -
+
{#if status.severity !== Severity.OK} -
+
{/if}
diff --git a/plugins/login-assets/lang/en.json b/plugins/login-assets/lang/en.json index f68862e748..e441c37390 100644 --- a/plugins/login-assets/lang/en.json +++ b/plugins/login-assets/lang/en.json @@ -3,7 +3,7 @@ "RequiredField": "Required field {field}", "FieldsDoNotMatch": "{field} don't match {field2}", "ConnectingToServer": "Connecting to server....", - "IncorrectValue": "Incorrect value {field}" + "IncorrectValue": "Incorrect value {field}. {descr}" }, "string": { "LogIn": "Login", @@ -27,6 +27,7 @@ "InviteNote": "Link is valid for 1 hour", "WantAnotherWorkspace": "Want to create another workspace?", "ChangeAccount": "Change account", - "NotSeeingWorkspace": "Not seeing your workspace?" + "NotSeeingWorkspace": "Not seeing your workspace?", + "WorksaceNameRule": "The workspace name can contains lowercase letters, numbers, and symbols !@#%&^-" } } \ No newline at end of file diff --git a/plugins/login-assets/lang/ru.json b/plugins/login-assets/lang/ru.json index a6d87dd935..ba5bfd9f97 100644 --- a/plugins/login-assets/lang/ru.json +++ b/plugins/login-assets/lang/ru.json @@ -3,7 +3,7 @@ "RequiredField": "Требуется заполнить {field}", "FieldsDoNotMatch": "{field} не совпадает {field2}", "ConnectingToServer": "Подключение к серверу....", - "IncorrectValue": "Неправильное значение {field}" + "IncorrectValue": "Неправильное значение {field}. {descr}" }, "string": { "LogIn": "Вход", @@ -27,6 +27,7 @@ "InviteNote": "Ссылка действительна 1 час", "WantAnotherWorkspace": "Хотите создать другое рабочее пространство?", "ChangeAccount": "Сменить пользователя", - "NotSeeingWorkspace": "Не видите ваше рабочее пространство?" + "NotSeeingWorkspace": "Не видите ваше рабочее пространство?", + "WorksaceNameRule": "Название рабочего пространства должно состояить из строчных латинских букв, цифр и символов !@#%&^-" } } \ No newline at end of file diff --git a/plugins/login-resources/src/components/CreateWorkspaceForm.svelte b/plugins/login-resources/src/components/CreateWorkspaceForm.svelte index 84b92a302d..d3f3e64cf2 100644 --- a/plugins/login-resources/src/components/CreateWorkspaceForm.svelte +++ b/plugins/login-resources/src/components/CreateWorkspaceForm.svelte @@ -29,7 +29,14 @@ import { workbenchId } from '@anticrm/workbench' import InviteLink from './InviteLink.svelte' - const fields = [{ name: 'workspace', i18n: login.string.Workspace, rule: /^[0-9a-z#%&^\-@!)(]{3,63}$/ }] + const fields = [ + { + name: 'workspace', + i18n: login.string.Workspace, + rule: /^[0-9a-z#%&^\-@!)(]{3,63}$/, + ruleDescr: login.string.WorksaceNameRule + } + ] const object = { workspace: '' diff --git a/plugins/login-resources/src/components/Form.svelte b/plugins/login-resources/src/components/Form.svelte index 73fc1d81b4..707327a965 100644 --- a/plugins/login-resources/src/components/Form.svelte +++ b/plugins/login-resources/src/components/Form.svelte @@ -30,6 +30,7 @@ optional?: boolean short?: boolean rule?: RegExp + ruleDescr?: IntlString } interface Action { @@ -71,7 +72,10 @@ } if (f.rule !== undefined) { if (!f.rule.test(v)) { - status = new Status(Severity.INFO, login.status.IncorrectValue, { field: await translate(field.i18n, {}) }) + status = new Status(Severity.INFO, login.status.IncorrectValue, { + field: await translate(field.i18n, {}), + descr: field.ruleDescr ? await translate(field.ruleDescr, {}) : '' + }) return } } diff --git a/plugins/login-resources/src/components/StatusControl.svelte b/plugins/login-resources/src/components/StatusControl.svelte index 99a53bcc07..41cde2b72b 100644 --- a/plugins/login-resources/src/components/StatusControl.svelte +++ b/plugins/login-resources/src/components/StatusControl.svelte @@ -23,7 +23,7 @@ {#if status.severity !== Severity.OK}
- +
{/if} diff --git a/plugins/login-resources/src/plugin.ts b/plugins/login-resources/src/plugin.ts index f1e01e3dbd..81e822f449 100644 --- a/plugins/login-resources/src/plugin.ts +++ b/plugins/login-resources/src/plugin.ts @@ -24,7 +24,7 @@ export default mergeIds(loginId, login, { RequiredField: '' as StatusCode<{ field: string }>, FieldsDoNotMatch: '' as StatusCode<{ field: string, field2: string }>, ConnectingToServer: '' as StatusCode, - IncorrectValue: '' as StatusCode<{ field: string }> + IncorrectValue: '' as StatusCode<{ field: string, descr: string }> }, string: { CreateWorkspace: '' as IntlString, @@ -48,6 +48,7 @@ export default mergeIds(loginId, login, { WantAnotherWorkspace: '' as IntlString, NotSeeingWorkspace: '' as IntlString, ChangeAccount: '' as IntlString, - InviteNote: '' as IntlString + InviteNote: '' as IntlString, + WorksaceNameRule: '' as IntlString } })