IllegalNamingWarning is conditional on ForwardSlashNameSubstitution 16041-valid-name
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 17 Jan 2020 15:03:24 +0000 (10:03 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 17 Jan 2020 15:03:24 +0000 (10:03 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/components/warning/warning.tsx

index 728cb45a1b515980d7b91c0c96d67fe3000188de..bd3303616d7e41a9b7f618ec6742df558c8cc159 100644 (file)
@@ -4,8 +4,10 @@
 
 import * as React from "react";
 import { ErrorIcon } from "~/components/icon/icon";
-import { disallowSlash } from "~/validators/valid-name";
 import { Tooltip } from "@material-ui/core";
+import { disallowSlash } from "~/validators/valid-name";
+import { connect } from "react-redux";
+import { RootState } from "~/store/store";
 
 interface WarningComponentProps {
     text: string;
@@ -22,9 +24,17 @@ export const WarningComponent = ({ text, rules, message }: WarningComponentProps
 
 interface IllegalNamingWarningProps {
     name: string;
+    validate: RegExp[];
 }
 
-export const IllegalNamingWarning = ({ name }: IllegalNamingWarningProps) =>
-    <WarningComponent
-        text={name} rules={[disallowSlash]}
-        message="Names embedding '/' will be renamed or invisible to file system access (arv-mount or WebDAV)" />;
+
+export const IllegalNamingWarning = connect(
+    (state: RootState) => {
+        return {
+            validate: (state.auth.config.clusterConfig.Collections.ForwardSlashNameSubstitution === "" ?
+                [disallowSlash] : [])
+        };
+    })(({ name, validate }: IllegalNamingWarningProps) =>
+        <WarningComponent
+            text={name} rules={validate}
+            message="Names embedding '/' will be renamed or invisible to file system access (arv-mount or WebDAV)" />);