// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 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; rules: RegExp[]; message: string; } export const WarningComponent = ({ text, rules, message }: WarningComponentProps) => !text ? : (rules.find(aRule => text.match(aRule) !== null) ? message ? : : null); interface IllegalNamingWarningProps { name: string; validate: RegExp[]; } export const IllegalNamingWarning = connect( (state: RootState) => { return { validate: (state.auth.config.clusterConfig.Collections.ForwardSlashNameSubstitution === "" ? [disallowSlash] : []) }; })(({ name, validate }: IllegalNamingWarningProps) => );