From 7add1edd40d6028acb4db3d2359330d1726727c7 Mon Sep 17 00:00:00 2001 From: mohiit1502 Date: Wed, 26 Jul 2023 03:25:51 +0530 Subject: [PATCH] Changed Icons endpoint for prod environment --- src/app/components/IconsList/IconsList.tsx | 3 ++- src/app/components/atoms/Alert/Alert.tsx | 7 +++++-- .../BrowserIncompatibility.tsx | 5 +++-- src/app/components/atoms/Button/Button.tsx | 5 +++-- src/app/components/atoms/Icon/Icon.tsx | 15 ++++++++------- src/app/components/atoms/TreeList/TreeList.tsx | 3 ++- src/app/components/molecules/Search/Search.tsx | 3 ++- src/app/config/api-config.ts | 2 +- src/app/config/constants.ts | 6 +++++- 9 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/app/components/IconsList/IconsList.tsx b/src/app/components/IconsList/IconsList.tsx index b7f1102..3d10df7 100755 --- a/src/app/components/IconsList/IconsList.tsx +++ b/src/app/components/IconsList/IconsList.tsx @@ -3,6 +3,7 @@ import { useAppDispatch } from "../../hooks" import { notify } from "../../store" import { Pagination, Search } from ".." import Helper from "../../utils/helper" +import { ICON_ROOT } from "../../config/constants" import "./IconsList.component.scss" interface IconsListProps { @@ -22,7 +23,7 @@ const IconTile = (props: IconTileProps): JSX.Element => { { - const iconLink = `http://localhost:8080/icon/${icon.group}/${icon.name}` + const iconLink = `${ICON_ROOT}/${icon.group}/${icon.name}` navigator.clipboard.writeText(iconLink) onClick && onClick(icon) }} diff --git a/src/app/components/atoms/Alert/Alert.tsx b/src/app/components/atoms/Alert/Alert.tsx index 6fe2138..e386e40 100755 --- a/src/app/components/atoms/Alert/Alert.tsx +++ b/src/app/components/atoms/Alert/Alert.tsx @@ -1,6 +1,8 @@ import { useEffect, useState } from "react" import Icon from "../Icon" +import API_CONFIG from "../../../config/api-config" import "./Alert.component.scss" +import { ICON_ROOT } from "../../../config/constants" type AlertType = "success" | "warning" | "error" | "information" export interface AlertProps { @@ -53,6 +55,7 @@ const Alert = (props: AlertProps): JSX.Element => { default: icon = "vsc/VscInfo" } + return (
{ } ${type || "information"}${showClass ? " " + showClass : ""}`} > - + {message || "This is a dummy alert"} @@ -74,7 +77,7 @@ const Alert = (props: AlertProps): JSX.Element => { }} > diff --git a/src/app/components/atoms/BrowserIncompatibility/BrowserIncompatibility.tsx b/src/app/components/atoms/BrowserIncompatibility/BrowserIncompatibility.tsx index 3a378b5..49df3ad 100755 --- a/src/app/components/atoms/BrowserIncompatibility/BrowserIncompatibility.tsx +++ b/src/app/components/atoms/BrowserIncompatibility/BrowserIncompatibility.tsx @@ -1,5 +1,6 @@ import { Alert, Icon } from "../.." import Helper from "../../../utils/helper" +import { ICON_ROOT } from "../../../config/constants" import "./BrowserIncompatibility.component.scss" interface BrowserIncompatibilityProps { @@ -11,7 +12,7 @@ const BrowserIncompatibility = ( props: BrowserIncompatibilityProps, ): JSX.Element => { const { applicationName, moreLink } = props - const demoDummyLink = "http://localhost:3000/armco-design-system/docs/devices" + const demoDummyLink = "http://notabuck.com/armco-design-system/docs/devices" const demoAppName = '"My Awesome App"' const helpLink = moreLink || demoDummyLink const app = applicationName || demoAppName @@ -19,7 +20,7 @@ const BrowserIncompatibility = ( return (
diff --git a/src/app/components/atoms/Button/Button.tsx b/src/app/components/atoms/Button/Button.tsx index c65a5ee..695ebe6 100755 --- a/src/app/components/atoms/Button/Button.tsx +++ b/src/app/components/atoms/Button/Button.tsx @@ -1,6 +1,7 @@ import { MouseEventHandler } from "react" -import "./Button.component.scss" import Icon from "../Icon" +import { ICON_ROOT } from "../../../config/constants" +import "./Button.component.scss" interface ButtonProps { classes?: string @@ -22,7 +23,7 @@ const Button = (props: ButtonProps) => { > {icon && ( - + )} {content || "Button"} diff --git a/src/app/components/atoms/Icon/Icon.tsx b/src/app/components/atoms/Icon/Icon.tsx index 7be6e76..304bc1f 100755 --- a/src/app/components/atoms/Icon/Icon.tsx +++ b/src/app/components/atoms/Icon/Icon.tsx @@ -1,4 +1,5 @@ import { MouseEventHandler } from "react" +import { ICON_ROOT } from "../../../config/constants" import "./Icon.component.scss" interface IconProps { @@ -36,13 +37,13 @@ const Icon = (props: IconProps): JSX.Element | null => { if (src) { let srcPart = src if (src.startsWith("http")) { - if (src.indexOf("http://localhost:8080/icon") > -1) { - srcPart = src.substring("http://localhost:8080/icon/".length) + if (src.indexOf(ICON_ROOT) > -1) { + srcPart = src.substring(`${ICON_ROOT}/`.length) } else { console.error( "Malformed source provided, format should be / { console.error( "Malformed source provided, format should be / { if (iconInfo[3]) { inferredSize = iconInfo[3] } - qualifiedSrc = "http://localhost:8080/icon/" + srcPart + qualifiedSrc = `${ICON_ROOT}/` + srcPart } } else { - qualifiedSrc = "http://localhost:8080/icon/tb/TbError404" + qualifiedSrc = `${ICON_ROOT}/tb/TbError404` } - const demoDummyIconSrc = "http://localhost:8080/icon/si/SiHappycow" + const demoDummyIconSrc = `${ICON_ROOT}/si/SiHappycow` qualifiedSrc = !src ? (demo ? demoDummyIconSrc : qualifiedSrc) : qualifiedSrc let appendables = "" appendables += !inferredColor diff --git a/src/app/components/atoms/TreeList/TreeList.tsx b/src/app/components/atoms/TreeList/TreeList.tsx index 38eb670..c8d9adf 100755 --- a/src/app/components/atoms/TreeList/TreeList.tsx +++ b/src/app/components/atoms/TreeList/TreeList.tsx @@ -1,5 +1,6 @@ import { useState } from "react" import { Icon, Search } from "../.." +import { ICON_ROOT } from "../../../config/constants" import "./TreeList.component.scss" interface TreeListProps { @@ -88,8 +89,8 @@ const TreeListItem = (props: TreeListItemProps): JSX.Element => { > {children ? ( setIconHovered(true)} onMouseLeave={() => setIconHovered(false)} onClick={(e) => { diff --git a/src/app/components/molecules/Search/Search.tsx b/src/app/components/molecules/Search/Search.tsx index d043bda..c396803 100755 --- a/src/app/components/molecules/Search/Search.tsx +++ b/src/app/components/molecules/Search/Search.tsx @@ -1,6 +1,7 @@ import { ChangeEvent, useState } from "react" import { Button, Icon, TextInput } from "../.." import Helper from "../../../utils/helper" +import { ICON_ROOT } from "../../../config/constants" import "./Search.component.scss" interface BaseSearchProps { @@ -72,7 +73,7 @@ const Search = (props: SearchProps): JSX.Element => { type="text" />