[ARVADOS-WORKBENCH2] updated: 1.4.1-141-g435d259b

Git user git at public.curoverse.com
Tue Dec 3 15:31:39 UTC 2019


Summary of changes:
 src/components/warning/warning.tsx |  3 ++-
 src/validators/valid-name.tsx      | 14 ++++++++++++++
 src/validators/validators.tsx      |  5 +++--
 3 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 src/validators/valid-name.tsx

       via  435d259b65ca110065a96581c1d568fb3ddd205d (commit)
      from  8378a7a9d6ffef1626ed8516150ce0807635a5fa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 435d259b65ca110065a96581c1d568fb3ddd205d
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue Dec 3 12:30:33 2019 -0300

    15856: Adds name validation to projects and collection edit/create dialogs.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/components/warning/warning.tsx b/src/components/warning/warning.tsx
index 7299c174..9a49ff0f 100644
--- a/src/components/warning/warning.tsx
+++ b/src/components/warning/warning.tsx
@@ -4,6 +4,7 @@
 
 import * as React from "react";
 import { ErrorIcon } from "~/components/icon/icon";
+import { invalidNamingRules } from "~/validators/valid-name";
 import { Tooltip } from "@material-ui/core";
 
 interface WarningComponentProps {
@@ -25,5 +26,5 @@ interface IllegalNamingWarningProps {
 
 export const IllegalNamingWarning = ({ name }: IllegalNamingWarningProps) =>
     <WarningComponent
-        text={name} rules={[/\//, /^\.{1,2}$/]}
+        text={name} rules={invalidNamingRules}
         message="Names being '.', '..' or including '/' cause issues with WebDAV, please edit it to something different." />;
\ No newline at end of file
diff --git a/src/validators/valid-name.tsx b/src/validators/valid-name.tsx
new file mode 100644
index 00000000..468811d8
--- /dev/null
+++ b/src/validators/valid-name.tsx
@@ -0,0 +1,14 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+
+const ERROR_MESSAGE = "Name cannot be '.' or '..' or contain '/' characters";
+
+export const invalidNamingRules = [/\//, /^\.{1,2}$/];
+
+export const validName = (value: string) => {
+    return invalidNamingRules.find(aRule => value.match(aRule) !== null)
+        ? ERROR_MESSAGE
+        : undefined;
+};
diff --git a/src/validators/validators.tsx b/src/validators/validators.tsx
index acef9744..13ce4e6a 100644
--- a/src/validators/validators.tsx
+++ b/src/validators/validators.tsx
@@ -6,13 +6,14 @@ import { require } from './require';
 import { maxLength } from './max-length';
 import { isRsaKey } from './is-rsa-key';
 import { isRemoteHost } from "./is-remote-host";
+import { validName } from "./valid-name";
 
 export const TAG_KEY_VALIDATION = [require, maxLength(255)];
 export const TAG_VALUE_VALIDATION = [require, maxLength(255)];
 
-export const PROJECT_NAME_VALIDATION = [require, maxLength(255)];
+export const PROJECT_NAME_VALIDATION = [require, validName, maxLength(255)];
 
-export const COLLECTION_NAME_VALIDATION = [require, maxLength(255)];
+export const COLLECTION_NAME_VALIDATION = [require, validName, maxLength(255)];
 export const COLLECTION_DESCRIPTION_VALIDATION = [maxLength(255)];
 export const COLLECTION_PROJECT_VALIDATION = [require];
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list