From 7149e71317056e78b516ed2d1a8ff60d6d44c4c8 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 26 Nov 2019 17:28:56 -0300 Subject: [PATCH] 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 --- src/components/warning/warning.tsx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/components/warning/warning.tsx 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 -- 2.30.2