X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/4cad4c0d882111b0eb5576005108a62ff30b143d..c6b3db3a8e2fcb7fe8d44cdd60e12fe7e2be571f:/src/components/warning/warning.tsx

diff --git a/src/components/warning/warning.tsx b/src/components/warning/warning.tsx
index 9a49ff0f..d459a37d 100644
--- a/src/components/warning/warning.tsx
+++ b/src/components/warning/warning.tsx
@@ -2,10 +2,12 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
-import { ErrorIcon } from "~/components/icon/icon";
-import { invalidNamingRules } from "~/validators/valid-name";
+import React from "react";
+import { ErrorIcon } from "components/icon/icon";
 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;
@@ -14,17 +16,26 @@ interface WarningComponentProps {
 }
 
 export const WarningComponent = ({ text, rules, message }: WarningComponentProps) =>
-    rules.find(aRule => text.match(aRule) !== null)
-    ? message
-        ? <Tooltip title={message}><ErrorIcon /></Tooltip>
-        : <ErrorIcon />
-    : null;
+    !text ? <Tooltip title={"No name"}><ErrorIcon /></Tooltip>
+        : (rules.find(aRule => text.match(aRule) !== null)
+            ? message
+                ? <Tooltip title={message}><ErrorIcon /></Tooltip>
+                : <ErrorIcon />
+            : null);
 
 interface IllegalNamingWarningProps {
     name: string;
+    validate: RegExp[];
 }
 
-export const IllegalNamingWarning = ({ name }: IllegalNamingWarningProps) =>
-    <WarningComponent
-        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
+
+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)" />);
