From: Lucas Di Pentima Date: Tue, 26 Nov 2019 20:28:56 +0000 (-0300) Subject: 15856: Adds new component to show a conditional warning icon. X-Git-Tag: 2.0.0~24^2~11 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/7149e71317056e78b516ed2d1a8ff60d6d44c4c8 15856: Adds new component to show a conditional warning icon. This component takes a list of regular expressions, if any of them matches the passed text, the icon is displayed with a custom tooltip message. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/components/warning/warning.tsx b/src/components/warning/warning.tsx new file mode 100644 index 00000000..1a8f4456 --- /dev/null +++ b/src/components/warning/warning.tsx @@ -0,0 +1,29 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from "react"; +import { WarningIcon } from "~/components/icon/icon"; +import { Tooltip } from "@material-ui/core"; + +interface WarningComponentProps { + text: string; + rules: RegExp[]; + message: string; +} + +export const WarningComponent = ({ text, rules, message }: WarningComponentProps) => + rules.find(aRule => text.match(aRule) !== null) + ? message + ? + : + : null; + +interface IllegalNamingWarningProps { + name: string; +} + +export const IllegalNamingWarning = ({ name }: IllegalNamingWarningProps) => + ; \ No newline at end of file