diff --git a/package-lock.json b/package-lock.json index 85301cabc..9548bd586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.21.0-pre-5", + "version": "1.21.0-beta-10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.21.0-pre-5", + "version": "1.21.0-beta-10", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 104dde616..ae16c82a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.21.0-pre-5", + "version": "1.21.0-beta-10", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Assets/IconV2/ic-chart-repo.svg b/src/Assets/IconV2/ic-chart-repo.svg new file mode 100644 index 000000000..8d0dff3f9 --- /dev/null +++ b/src/Assets/IconV2/ic-chart-repo.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Assets/IconV2/ic-external-link.svg b/src/Assets/IconV2/ic-external-link.svg new file mode 100644 index 000000000..ddcdbcf6f --- /dev/null +++ b/src/Assets/IconV2/ic-external-link.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/Pages-Devtron-2.0/Shared/Overview/components.tsx b/src/Pages-Devtron-2.0/Shared/Overview/components.tsx new file mode 100644 index 000000000..82e343284 --- /dev/null +++ b/src/Pages-Devtron-2.0/Shared/Overview/components.tsx @@ -0,0 +1,128 @@ +import { ReactNode, useState } from 'react' +import { NavLink } from 'react-router-dom' +import { motion } from 'framer-motion' + +import { ConditionalWrap } from '@Common/Helper' +import { Tooltip } from '@Common/Tooltip' +import { Button, ButtonStyleType, ButtonVariantType, Icon } from '@Shared/Components' + +import { MetricsInfoCardProps, SectionEmptyStateProps } from './types' + +export const SectionEmptyState = ({ + iconName = 'ic-priority-medium-fill', + iconColor, + title, + subtitle, + buttonConfig, +}: SectionEmptyStateProps) => ( +
+ +
+ {title} + {subtitle && {subtitle}} +
+ {buttonConfig &&
+) + +const navLinkWrap = (redirectionLink: string) => (children: ReactNode) => ( + {children} +) + +export const MetricsInfoLoadingCard = ({ withSubtitle }: { withSubtitle?: boolean }) => ( +
+
+
+ + +
+
+
+ {withSubtitle && ( +
+ +
+ )} +
+) + +export const MetricsInfoCard = ({ + dataTestId, + metricTitle, + metricValue, + metricUnit, + valueOutOf, + iconName, + subtitle, + redirectionLink, + tooltipContent, + subtitleRedirection, +}: MetricsInfoCardProps) => { + const [isHovering, setIsHovering] = useState(false) + + const handleHoverStart = () => setIsHovering(true) + const handleHoverEnd = () => setIsHovering(false) + + return ( + + +
+
+ + + {metricTitle} + + +
+ {metricValue} + {valueOutOf && ( + / {valueOutOf} + )} + {metricUnit && ( + {metricUnit} + )} +
+
+
+ {redirectionLink && isHovering ? ( +
+
+ {subtitle && ( +
+ + + {subtitle} + + +
+ )} +
+
+ ) +} + +export const LoadingDonutChart = () => ( +
+
+
+ + +
+
+) diff --git a/src/Pages-Devtron-2.0/Shared/Overview/constants.ts b/src/Pages-Devtron-2.0/Shared/Overview/constants.ts new file mode 100644 index 000000000..c83e60d16 --- /dev/null +++ b/src/Pages-Devtron-2.0/Shared/Overview/constants.ts @@ -0,0 +1,27 @@ +const OVERVIEW_DEFAULT_PAGE_SIZE = { + SMALL: 5, + MEDIUM: 10, + LARGE: 20, +} + +export const OVERVIEW_PAGE_SIZE_OPTIONS = [ + { + value: OVERVIEW_DEFAULT_PAGE_SIZE.MEDIUM, + selected: true, + }, + { + value: OVERVIEW_DEFAULT_PAGE_SIZE.LARGE, + selected: false, + }, +] + +export const OVERVIEW_PAGE_SIZE_OPTIONS_SMALL = [ + { + value: OVERVIEW_DEFAULT_PAGE_SIZE.SMALL, + selected: true, + }, + { + value: OVERVIEW_DEFAULT_PAGE_SIZE.MEDIUM, + selected: false, + }, +] diff --git a/src/Pages-Devtron-2.0/Shared/Overview/index.ts b/src/Pages-Devtron-2.0/Shared/Overview/index.ts new file mode 100644 index 000000000..d3f2deaa4 --- /dev/null +++ b/src/Pages-Devtron-2.0/Shared/Overview/index.ts @@ -0,0 +1,3 @@ +export * from './components' +export * from './constants' +export { type MetricsInfoCardProps, ProdNonProdSelectValueTypes } from './types' diff --git a/src/Pages-Devtron-2.0/Shared/Overview/types.ts b/src/Pages-Devtron-2.0/Shared/Overview/types.ts new file mode 100644 index 000000000..bf8556b87 --- /dev/null +++ b/src/Pages-Devtron-2.0/Shared/Overview/types.ts @@ -0,0 +1,29 @@ +import { ButtonComponentType, ButtonProps, IconName } from '@Shared/Components' +import { IconBaseColorType } from '@Shared/types' + +export interface SectionEmptyStateProps { + iconColor?: IconBaseColorType + iconName?: IconName + title: string + subtitle?: string + buttonConfig?: ButtonProps +} + +export interface MetricsInfoCardProps { + dataTestId: string + metricTitle: string + metricValue: string + metricUnit?: string + valueOutOf?: string + iconName: IconName + subtitle?: string + tooltipContent: string + redirectionLink?: string + subtitleRedirection?: string +} + +export enum ProdNonProdSelectValueTypes { + ALL = 'All', + PRODUCTION = 'Prod', + NON_PRODUCTION = 'Non-Prod', +} diff --git a/src/Pages-Devtron-2.0/Shared/index.ts b/src/Pages-Devtron-2.0/Shared/index.ts new file mode 100644 index 000000000..bb81fdde1 --- /dev/null +++ b/src/Pages-Devtron-2.0/Shared/index.ts @@ -0,0 +1 @@ +export * from './Overview' diff --git a/src/Pages-Devtron-2.0/index.ts b/src/Pages-Devtron-2.0/index.ts index 900f8bd9b..df634e1ce 100644 --- a/src/Pages-Devtron-2.0/index.ts +++ b/src/Pages-Devtron-2.0/index.ts @@ -4,3 +4,4 @@ export * from './DataProtectionManagement' export * from './InfrastructureManagement' export * from './Navigation' export * from './SecurityCenter' +export * from './Shared' diff --git a/src/Shared/Components/Icon/Icon.tsx b/src/Shared/Components/Icon/Icon.tsx index 4d80ff930..f9517d50e 100644 --- a/src/Shared/Components/Icon/Icon.tsx +++ b/src/Shared/Components/Icon/Icon.tsx @@ -64,6 +64,7 @@ import { ReactComponent as ICCaretLeft } from '@IconsV2/ic-caret-left.svg' import { ReactComponent as ICCaretRight } from '@IconsV2/ic-caret-right.svg' import { ReactComponent as ICCd } from '@IconsV2/ic-cd.svg' import { ReactComponent as ICChartLineUp } from '@IconsV2/ic-chart-line-up.svg' +import { ReactComponent as ICChartRepo } from '@IconsV2/ic-chart-repo.svg' import { ReactComponent as ICChatCircleDots } from '@IconsV2/ic-chat-circle-dots.svg' import { ReactComponent as ICChatCircleOnline } from '@IconsV2/ic-chat-circle-online.svg' import { ReactComponent as ICCheck } from '@IconsV2/ic-check.svg' @@ -129,6 +130,7 @@ import { ReactComponent as ICError } from '@IconsV2/ic-error.svg' import { ReactComponent as ICExitFullscreen } from '@IconsV2/ic-exit-fullscreen.svg' import { ReactComponent as ICExpandRightSm } from '@IconsV2/ic-expand-right-sm.svg' import { ReactComponent as ICExpandSm } from '@IconsV2/ic-expand-sm.svg' +import { ReactComponent as ICExternalLink } from '@IconsV2/ic-external-link.svg' import { ReactComponent as ICFailure } from '@IconsV2/ic-failure.svg' import { ReactComponent as ICFastForward } from '@IconsV2/ic-fast-forward.svg' import { ReactComponent as ICFile } from '@IconsV2/ic-file.svg' @@ -378,6 +380,7 @@ export const iconMap = { 'ic-caret-right': ICCaretRight, 'ic-cd': ICCd, 'ic-chart-line-up': ICChartLineUp, + 'ic-chart-repo': ICChartRepo, 'ic-chat-circle-dots': ICChatCircleDots, 'ic-chat-circle-online': ICChatCircleOnline, 'ic-check-all': ICCheckAll, @@ -443,6 +446,7 @@ export const iconMap = { 'ic-exit-fullscreen': ICExitFullscreen, 'ic-expand-right-sm': ICExpandRightSm, 'ic-expand-sm': ICExpandSm, + 'ic-external-link': ICExternalLink, 'ic-failure': ICFailure, 'ic-fast-forward': ICFastForward, 'ic-file-code': ICFileCode,