From b04a06e92c74708999d3fc85ad32ee7f901edbd3 Mon Sep 17 00:00:00 2001 From: Rohit Raj Date: Wed, 16 Oct 2024 17:39:00 +0530 Subject: [PATCH 1/2] refactor: Multiple Improvements and UAT changes fix: DeploymentConfigCompare - Navigation - error handling; code refactor feat: add support for navlist icon --- src/Assets/Icon/ic-file-code.svg | 20 ++++++++++ .../DeploymentConfigDiff.component.tsx | 9 ++++- .../DeploymentConfigDiff.scss | 2 +- .../DeploymentConfigDiff.types.ts | 10 ++++- .../DeploymentConfigDiff.utils.tsx | 2 + .../DeploymentConfigDiffMain.tsx | 22 ++++++----- .../DeploymentConfigDiffNavigation.tsx | 37 +++++++++++++++---- 7 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 src/Assets/Icon/ic-file-code.svg diff --git a/src/Assets/Icon/ic-file-code.svg b/src/Assets/Icon/ic-file-code.svg new file mode 100644 index 000000000..d8f0955c5 --- /dev/null +++ b/src/Assets/Icon/ic-file-code.svg @@ -0,0 +1,20 @@ + + + + + + diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.component.tsx b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.component.tsx index 7c48506d8..addbebca1 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.component.tsx +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.component.tsx @@ -12,6 +12,7 @@ export const DeploymentConfigDiff = ({ navHeading, navHelpText, tabConfig, + errorConfig, ...resProps }: DeploymentConfigDiffProps) => (
@@ -23,7 +24,13 @@ export const DeploymentConfigDiff = ({ navHeading={navHeading} navHelpText={navHelpText} tabConfig={tabConfig} + errorConfig={errorConfig} + /> + -
) diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.scss b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.scss index 9e0859448..c3395c14f 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.scss +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.scss @@ -39,7 +39,7 @@ &__tab-list { label { - flex-grow: 1 + flex-grow: 1; } .radio__item-label { diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.types.ts b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.types.ts index 8a3dd0424..0f8a3b202 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.types.ts +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.types.ts @@ -42,6 +42,7 @@ export type DeploymentConfigDiffSelectPickerProps = } export interface DeploymentConfigDiffNavigationItem extends Pick { + Icon?: React.FunctionComponent> hasDiff?: boolean } @@ -84,7 +85,14 @@ export interface DeploymentConfigDiffProps { export interface DeploymentConfigDiffNavigationProps extends Pick< DeploymentConfigDiffProps, - 'isLoading' | 'navList' | 'collapsibleNavList' | 'goBackURL' | 'navHeading' | 'navHelpText' | 'tabConfig' + | 'isLoading' + | 'navList' + | 'collapsibleNavList' + | 'goBackURL' + | 'navHeading' + | 'navHelpText' + | 'tabConfig' + | 'errorConfig' > {} export interface DeploymentConfigDiffMainProps diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx index 2688bce9a..d7674e069 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx @@ -1,6 +1,7 @@ import { ReactComponent as ICCheck } from '@Icons/ic-check.svg' import { ReactComponent as ICStamp } from '@Icons/ic-stamp.svg' import { ReactComponent as ICEditFile } from '@Icons/ic-edit-file.svg' +import { ReactComponent as ICFileCode } from '@Icons/ic-file-code.svg' import { stringComparatorBySortOrder, yamlComparatorBySortOrder } from '@Shared/Helpers' import { DEPLOYMENT_HISTORY_CONFIGURATION_LIST_MAP } from '@Shared/constants' import { YAMLStringify } from '@Common/Helper' @@ -507,6 +508,7 @@ export const getAppEnvDeploymentConfigList = { + if (isLoading) { + return + } + + if (errorConfig?.error) { + return + } + + return
{renderDiffs()}
+ } + return (
@@ -183,15 +195,7 @@ export const DeploymentConfigDiffMain = ({ {renderSortButton()}
-
- {errorConfig?.error && } - {!errorConfig?.error && - (isLoading ? ( - - ) : ( -
{renderDiffs()}
- ))} -
+
{renderContent()}
) } diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffNavigation.tsx b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffNavigation.tsx index b8f2d8307..50569b47a 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffNavigation.tsx +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffNavigation.tsx @@ -25,6 +25,7 @@ export const DeploymentConfigDiffNavigation = ({ navHeading, navHelpText, tabConfig, + errorConfig, }: DeploymentConfigDiffNavigationProps) => { // STATES const [expandedIds, setExpandedIds] = useState>({}) @@ -101,17 +102,18 @@ export const DeploymentConfigDiffNavigation = ({ ) } - const renderContent = () => ( + const renderNavigation = () => ( <> - {navList.map(({ title, href, onClick, hasDiff }) => ( + {navList.map(({ title, href, onClick, hasDiff, Icon }) => ( - {title} + {Icon && } + {title} {hasDiff && (
@@ -125,7 +127,7 @@ export const DeploymentConfigDiffNavigation = ({ {navHelpText && (
- +

{navHelpText}

@@ -133,13 +135,32 @@ export const DeploymentConfigDiffNavigation = ({ ) - const renderLoading = () => ['90', '70', '50'].map((item) => ) + const renderContent = () => { + if (isLoading) { + return ['90', '70', '50'].map((item) => ) + } + + if (errorConfig?.error) { + return ( +
+ + + +

+ Failed to load files. Please reload or select a different reference to compare with. +

+
+ ) + } + + return renderNavigation() + } return ( -
+
{renderTopContent()} {!!tabConfig?.tabs.length && renderTabConfig()} -
{isLoading ? renderLoading() : renderContent()}
+
{renderContent()}
) } From 135df491d0f776b90b564f894ba6bcca7ff77154 Mon Sep 17 00:00:00 2001 From: Rohit Raj Date: Wed, 16 Oct 2024 17:45:26 +0530 Subject: [PATCH 2/2] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54230a428..77ff2bc6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0-beta-1", + "version": "0.5.0-beta-10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0-beta-1", + "version": "0.5.0-beta-10", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index c0cf55e16..712fddef3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0-beta-1", + "version": "0.5.0-beta-10", "description": "Supporting common component library", "type": "module", "main": "dist/index.js",