From 565a02d334a92aea65331d96fb0e719dd2558336 Mon Sep 17 00:00:00 2001 From: Eshank Vaish Date: Thu, 8 Aug 2024 16:34:30 +0530 Subject: [PATCH 01/52] feat: add enum for image promotion --- src/Shared/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index b3fe30a0c..a645d6b91 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -437,6 +437,7 @@ export enum ResourceVersionType { export enum PolicyKindType { lockConfiguration = 'lock-configuration', + imagePromotion = 'lock-configuration', } export interface LastExecutionResultType { From b459767b7f6dcfac385478a9b75c29ec560120b0 Mon Sep 17 00:00:00 2001 From: Eshank Vaish Date: Thu, 8 Aug 2024 17:46:36 +0530 Subject: [PATCH 02/52] fix: add configuration menu position for select picker --- src/Shared/Components/SelectPicker/SelectPicker.component.tsx | 3 ++- src/Shared/Components/SelectPicker/type.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx index 6ec01511c..5205fe0a3 100644 --- a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx +++ b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx @@ -126,6 +126,7 @@ const SelectPicker = ({ disabledTippyContent, showSelectedOptionsCount = false, menuSize, + menuPosition = 'fixed', ...props }: SelectPickerProps) => { const { inputId, required, isDisabled } = props @@ -208,7 +209,7 @@ const SelectPicker = ({ }} styles={selectStyles} menuPlacement="auto" - menuPosition="fixed" + menuPosition={menuPosition} menuShouldScrollIntoView backspaceRemovesValue={false} aria-errormessage={errorElementId} diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index 6a1d980d7..e9373ba13 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -54,6 +54,7 @@ export interface SelectPickerProps | 'required' | 'isOptionDisabled' | 'placeholder' + | 'menuPosition' >, Required> { /** From 0de46bc46914f4dc17130b89df7b03f1c8d6252b Mon Sep 17 00:00:00 2001 From: Eshank Vaish Date: Fri, 9 Aug 2024 11:05:55 +0530 Subject: [PATCH 03/52] fix: naming for descriptor typing --- src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx | 4 ++-- src/Pages/GlobalConfigurations/BuildInfra/types.tsx | 2 +- src/Shared/Components/FeatureDescription/index.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx b/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx index 96839067b..a406bbb9d 100644 --- a/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx +++ b/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { DescriptorProps } from './types' +import { BuildInfraDescriptorProps } from './types' import { BreadCrumb, DOCUMENTATION } from '../../../Common' import { BUILD_INFRA_TEXT } from './constants' import { InfoIconTippy } from '../../../Shared' @@ -25,7 +25,7 @@ const Descriptor = ({ children, tippyInfoText, tippyAdditionalContent, -}: DescriptorProps) => ( +}: BuildInfraDescriptorProps) => (
diff --git a/src/Pages/GlobalConfigurations/BuildInfra/types.tsx b/src/Pages/GlobalConfigurations/BuildInfra/types.tsx index 519222311..373deca6f 100644 --- a/src/Pages/GlobalConfigurations/BuildInfra/types.tsx +++ b/src/Pages/GlobalConfigurations/BuildInfra/types.tsx @@ -74,7 +74,7 @@ export enum BuildInfraProfileVariants { CUSTOM = 'CUSTOM', } -export interface DescriptorProps { +export interface BuildInfraDescriptorProps { /** * In case we want to restrict the max-width */ diff --git a/src/Shared/Components/FeatureDescription/index.ts b/src/Shared/Components/FeatureDescription/index.ts index 2cb9f1ab1..6ff97bf34 100644 --- a/src/Shared/Components/FeatureDescription/index.ts +++ b/src/Shared/Components/FeatureDescription/index.ts @@ -16,3 +16,4 @@ export * from './FeatureDescriptionModal' export { default as FeatureTitleWithInfo } from './FeatureTitleWithInfo' +export * from './types' From e0abda195b57a0638bff40e91f1fd8407ed4a196 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:25:15 +0530 Subject: [PATCH 04/52] fix: update the policy kind type --- src/Shared/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index a5b9f5baa..e04329092 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -460,7 +460,7 @@ export interface SeverityCount { unknown: number } export enum PolicyKindType { - lockConfiguration = 'lock-configuration', + lockConfiguration = 'lock-configuration-dummy', imagePromotion = 'image-promotion', // TODO: Update after BE is ready plugins = 'lock-configuration', From 12a15c008602736671cd588565eaccec005be294 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:28:14 +0530 Subject: [PATCH 05/52] feat: expose formatOptionLabel in select picker --- src/Shared/Components/SelectPicker/type.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index 820a894b8..a1d363b18 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -100,6 +100,7 @@ export type SelectPickerProps & Partial< Pick< From 513902c3555c480628ff0f09c23d72c7782b165f Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:03:19 +0530 Subject: [PATCH 06/52] feat: show the info icon based on prop in feature description modal --- .../FeatureDescription/FeatureTitleWithInfo.tsx | 9 +++++++-- src/Shared/Components/FeatureDescription/types.ts | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Shared/Components/FeatureDescription/FeatureTitleWithInfo.tsx b/src/Shared/Components/FeatureDescription/FeatureTitleWithInfo.tsx index c1584e7c7..45d65d6d5 100644 --- a/src/Shared/Components/FeatureDescription/FeatureTitleWithInfo.tsx +++ b/src/Shared/Components/FeatureDescription/FeatureTitleWithInfo.tsx @@ -35,6 +35,7 @@ const FeatureTitleWithInfo = ({ docLinkText = 'View Documentation', dataTestId = 'feature-title-with-info', additionalContent, + showInfoIcon = false, }: DescriptorProps) => { const [showFeatureDescriptionModal, setShowFeatureDescriptionModal] = useState(false) const onClickInfoIcon = () => { @@ -64,10 +65,14 @@ const FeatureTitleWithInfo = ({
) } - if (breadCrumbs?.length > 0) { + if (breadCrumbs?.length > 0 || showInfoIcon) { return (
- + {showInfoIcon && breadCrumbs?.length === 0 ? ( + {title} + ) : ( + + )}
) diff --git a/src/Shared/Components/FeatureDescription/types.ts b/src/Shared/Components/FeatureDescription/types.ts index d874b3588..d963293a2 100644 --- a/src/Shared/Components/FeatureDescription/types.ts +++ b/src/Shared/Components/FeatureDescription/types.ts @@ -38,4 +38,10 @@ export interface DescriptorProps extends FeatureDescriptionModalProps { docLinkText?: string dataTestId?: string additionalContent?: ReactNode + /** + * If true, the info icon is displayed which when clicked shows the feature description modal + * + * @default false + */ + showInfoIcon?: boolean } From f833d34b9f9ad159d4f4f89535b5606446910843 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:28:40 +0530 Subject: [PATCH 07/52] fix: icon re-rendering in select picker --- .../SelectPicker/SelectPicker.component.tsx | 20 +++---------- src/Shared/Components/SelectPicker/common.tsx | 13 ++++----- src/Shared/Components/SelectPicker/type.ts | 28 +++++++++++-------- 3 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx index bf0e9bcdf..48647ea7b 100644 --- a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx +++ b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx @@ -14,14 +14,7 @@ * limitations under the License. */ -import { - ControlProps, - GroupHeadingProps, - MultiValueProps, - OptionProps, - ValueContainerProps, - MenuPlacement, -} from 'react-select' +import { GroupHeadingProps, MultiValueProps, OptionProps, ValueContainerProps, MenuPlacement } from 'react-select' import CreatableSelect from 'react-select/creatable' import { ReactElement, useCallback, useMemo } from 'react' @@ -257,13 +250,6 @@ const SelectPicker = ({ ) } - const renderControl = useCallback( - (controlProps: ControlProps>) => ( - - ), - [icon, shouldShowSelectedOptionIcon], - ) - const renderValueContainer = useCallback( (valueContainerProps: ValueContainerProps>) => ( ({ IndicatorSeparator: null, LoadingIndicator: SelectPickerLoadingIndicator, DropdownIndicator: SelectPickerDropdownIndicator, - Control: renderControl, + Control: SelectPickerControl, Option: renderOption, MenuList: SelectPickerMenuList, ClearIndicator: SelectPickerClearIndicator, @@ -399,6 +385,8 @@ const SelectPicker = ({ renderMenuListFooter={!optionListError && renderMenuListFooter} inputValue={inputValue} onInputChange={onInputChange} + icon={icon} + showSelectedOptionIcon={shouldShowSelectedOptionIcon} />
diff --git a/src/Shared/Components/SelectPicker/common.tsx b/src/Shared/Components/SelectPicker/common.tsx index fbf8cf465..626d69b7b 100644 --- a/src/Shared/Components/SelectPicker/common.tsx +++ b/src/Shared/Components/SelectPicker/common.tsx @@ -59,13 +59,12 @@ export const SelectPickerClearIndicator = ( ) -export const SelectPickerControl = ({ - icon, - showSelectedOptionIcon, - ...props -}: ControlProps> & - Pick, 'icon' | 'showSelectedOptionIcon'>) => { - const { children, getValue } = props +export const SelectPickerControl = (props: ControlProps>) => { + const { + children, + getValue, + selectProps: { icon, showSelectedOptionIcon }, + } = props const { startIcon, endIcon } = getValue()?.[0] ?? {} let iconToDisplay: SelectPickerOptionType['startIcon'] = icon diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index bf5cb50fa..e308a27e5 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -65,6 +65,17 @@ declare module 'react-select/base' { * Imp Note: The menu open/close needs to handled by the consumer in this case */ renderCustomOptions?: () => ReactElement + /** + * Icon to be rendered in the control + */ + icon?: ReactElement + /** + * If true, the selected option icon is shown in the container. + * startIcon has higher priority than endIcon. + * + * @default 'true' + */ + showSelectedOptionIcon?: boolean } } @@ -107,7 +118,11 @@ export type SelectPickerProps, - 'renderMenuListFooter' | 'shouldRenderCustomOptions' | 'renderCustomOptions' + | 'renderMenuListFooter' + | 'shouldRenderCustomOptions' + | 'renderCustomOptions' + | 'icon' + | 'showSelectedOptionIcon' > > & Required, 'inputId'>> & @@ -121,10 +136,6 @@ export type SelectPickerProps > & { - /** - * Icon to be rendered in the control - */ - icon?: ReactElement /** * Error message for the select */ @@ -137,13 +148,6 @@ export type SelectPickerProps Date: Tue, 8 Oct 2024 17:00:54 +0530 Subject: [PATCH 08/52] chore: bump common --- 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 04f57b8a4..fcefe4da9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "4.0.2", + "version": "4.0.2-beta-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "4.0.2", + "version": "4.0.2-beta-1", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 74d4e34cd..771e1e6fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "4.0.2", + "version": "4.0.2-beta-1", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From cb65b13413ac96241b0d4d38405141de838eebf7 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Tue, 8 Oct 2024 17:40:11 +0530 Subject: [PATCH 09/52] feat: add flag for cd mandatory plugin --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 57d0183d5..e90d35e6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -76,6 +76,7 @@ export interface customEnv { SYSTEM_CONTROLLER_LISTING_TIMEOUT?: number FEATURE_STEP_WISE_LOGS_ENABLE?: boolean FEATURE_IMAGE_PROMOTION_ENABLE?: boolean + FEATURE_CD_MANDATORY_PLUGINS_ENABLE?: boolean } declare global { interface Window { From 670b6cad097523a63fe3f353f3bd5c256345c12e Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:56:26 +0530 Subject: [PATCH 10/52] feat: expose size for getPluginStoreData --- src/Shared/Components/Plugin/service.tsx | 3 ++- src/Shared/Components/Plugin/types.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index a943bb686..a75a2f10d 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -68,13 +68,14 @@ export const getPluginStoreData = async ({ appId, offset = 0, signal, + size = 20, }: GetPluginStoreDataServiceParamsType): Promise => { try { const payload: GetPluginListPayloadType = { searchKey, offset, appId, - size: 20, + size, tag: selectedTags, } const { result } = await get(getUrlWithSearchParams(ROUTES.PLUGIN_GLOBAL_LIST_V2, payload), { diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 4b1b0494f..3b4dea25c 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -178,6 +178,7 @@ export interface GetPluginStoreDataServiceParamsType extends Pick Date: Wed, 9 Oct 2024 18:09:07 +0530 Subject: [PATCH 11/52] fix: conditionally hide label for date time picker --- src/Shared/Components/DatePicker/DateTimePicker.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Shared/Components/DatePicker/DateTimePicker.tsx b/src/Shared/Components/DatePicker/DateTimePicker.tsx index ccbe3af8e..0b6777b36 100644 --- a/src/Shared/Components/DatePicker/DateTimePicker.tsx +++ b/src/Shared/Components/DatePicker/DateTimePicker.tsx @@ -69,9 +69,11 @@ const DateTimePicker = ({ return (
- + {label && ( + + )}
Date: Thu, 10 Oct 2024 16:06:41 +0530 Subject: [PATCH 12/52] feat: expose getOptionLabel in filter select picker --- src/Shared/Components/SelectPicker/type.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index e308a27e5..0aa998771 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -263,6 +263,7 @@ export interface FilterSelectPickerProps | 'shouldMenuAlignRight' | 'optionListError' | 'reloadOptionList' + | 'getOptionLabel' > { appliedFilterOptions: SelectPickerOptionType[] handleApplyFilter: (filtersToApply: SelectPickerOptionType[]) => void From 9b5df6e8cd4ebff7b756f4f3f0f91e9069e62bed Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:54:53 +0530 Subject: [PATCH 13/52] feat: add validateDateAndTime validator --- src/Shared/validations.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Shared/validations.tsx b/src/Shared/validations.tsx index 4a8454c5f..d6fc0edc7 100644 --- a/src/Shared/validations.tsx +++ b/src/Shared/validations.tsx @@ -32,6 +32,8 @@ export const MESSAGES = { VALID_POSITIVE_INTEGER: 'This field should be a valid positive integer', MAX_SAFE_INTEGER: `Maximum allowed value is ${Number.MAX_SAFE_INTEGER}`, INVALID_SEMANTIC_VERSION: 'Please follow semantic versioning', + INVALID_DATE: 'Please enter a valid date', + DATE_BEFORE_CURRENT_TIME: 'The date & time cannot be before the current time', } const MAX_DESCRIPTION_LENGTH = 350 @@ -342,3 +344,24 @@ export const validateJSON = (json: string): ValidationResponseType => { } } } + +export const validateDateAndTime = (date: Date): ValidationResponseType => { + if (date) { + const currentDate = new Date() + if (currentDate.getTime() > date.getTime()) { + return { + isValid: false, + message: MESSAGES.DATE_BEFORE_CURRENT_TIME, + } + } + } else { + return { + isValid: false, + message: MESSAGES.INVALID_DATE, + } + } + + return { + isValid: true, + } +} From c6f8689b47d289d6a16435dee682965984e9a17a Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:39:45 +0530 Subject: [PATCH 14/52] fix: styling for toast manager and button --- src/Shared/Components/Button/Button.component.tsx | 2 +- src/Shared/Services/ToastManager/toastManager.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shared/Components/Button/Button.component.tsx b/src/Shared/Components/Button/Button.component.tsx index 3dbbdd6b2..60e345126 100644 --- a/src/Shared/Components/Button/Button.component.tsx +++ b/src/Shared/Components/Button/Button.component.tsx @@ -171,7 +171,7 @@ const Button = ({ diff --git a/src/Shared/Services/ToastManager/toastManager.scss b/src/Shared/Services/ToastManager/toastManager.scss index 141a9a118..1263b125a 100644 --- a/src/Shared/Services/ToastManager/toastManager.scss +++ b/src/Shared/Services/ToastManager/toastManager.scss @@ -47,7 +47,7 @@ &__content { // Override the style for the action button - button { + button.button, a.button { color: var(--N0); svg *[stroke^="#"] { From c0dcb905426f16be04dba760b399288f15bb9306 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:48:18 +0530 Subject: [PATCH 15/52] feat: update the value for policy kind type enum --- src/Shared/types.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index e04329092..6631517b7 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -460,10 +460,9 @@ export interface SeverityCount { unknown: number } export enum PolicyKindType { - lockConfiguration = 'lock-configuration-dummy', + lockConfiguration = 'lock-configuration', imagePromotion = 'image-promotion', - // TODO: Update after BE is ready - plugins = 'lock-configuration', + plugins = 'plugin', } export interface LastExecutionResultType { From acb396fce800a017d9d2540e3f1e9d2e122ec05f Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:50:09 +0530 Subject: [PATCH 16/52] feat: hide start icon in option in case of multi select --- src/Shared/Components/SelectPicker/common.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Shared/Components/SelectPicker/common.tsx b/src/Shared/Components/SelectPicker/common.tsx index 626d69b7b..ed6cc5b12 100644 --- a/src/Shared/Components/SelectPicker/common.tsx +++ b/src/Shared/Components/SelectPicker/common.tsx @@ -148,7 +148,8 @@ export const SelectPickerOption = ({ /> )}
- {startIcon && ( + {/* startIcon is not to be shown in option in case of multi select */} + {!isMulti && startIcon && (
{startIcon}
)}
@@ -200,7 +201,7 @@ export const SelectPickerMultiValueLabel = ['multiSelectProps'], 'getIsOptionValid'>) => { const { data, selectProps } = props const isOptionValid = getIsOptionValid(data) - const iconToDisplay = isOptionValid ? data.startIcon || data.endIcon : + const iconToDisplay = isOptionValid ? (data.startIcon || data.endIcon) ?? null : return (
From 3132227fd2c457e9b880894e651a5c092cfc9d29 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:49:31 +0530 Subject: [PATCH 17/52] feat: expose parentPluginIdentifier --- src/Shared/Components/Plugin/service.tsx | 2 ++ src/Shared/Components/Plugin/types.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index a75a2f10d..eb2d2861b 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -36,12 +36,14 @@ export const getPluginsDetail = async ({ pluginIds, signal, shouldShowError = true, + parentPluginIdentifiers, }: PluginDetailServiceParamsType): Promise> => { try { const payload: PluginDetailPayloadType = { appId, parentPluginId: parentPluginIds, pluginId: pluginIds, + parentPluginIdentifier: parentPluginIdentifiers ? `${parentPluginIdentifiers}` : null, } const { result } = await get( diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 3b4dea25c..ebe0191fd 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -84,6 +84,7 @@ export interface PluginDetailServiceParamsType { appId: number pluginIds?: number[] parentPluginIds?: number[] + parentPluginIdentifiers?: string[] /** * @default true */ @@ -94,6 +95,7 @@ export interface PluginDetailServiceParamsType { export interface PluginDetailPayloadType extends Pick { pluginId?: PluginDetailServiceParamsType['pluginIds'] parentPluginId?: PluginDetailServiceParamsType['parentPluginIds'] + parentPluginIdentifier?: PluginDetailServiceParamsType['parentPluginIdentifiers'][number] } export interface PluginListFiltersType extends Pick, 'searchKey'> { From bbc63db159a743277aebcb423e1fb07b4996ec95 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Mon, 14 Oct 2024 17:15:22 +0530 Subject: [PATCH 18/52] feat: update DefinitionSourceType for v2 --- src/Common/Policy.Types.ts | 16 ++++++---------- src/Shared/types.ts | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index f99dcfb45..b54bcc16b 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -23,6 +23,8 @@ export enum ApplyPolicyToStage { PRE_CI = 'PRE_CI', POST_CI = 'POST_CI', PRE_OR_POST_CI = 'PRE_OR_POST_CI', + POST_CD = 'POST_CD', + PRE_CD = 'PRE_CD', } export enum PluginRequiredStage { @@ -32,16 +34,10 @@ export enum PluginRequiredStage { } export interface DefinitionSourceType { - projectName: string - isDueToProductionEnvironment: boolean - isDueToLinkedPipeline: boolean - policyName: string - appName?: string - clusterName?: string - environmentName?: string - branchNames?: string[] - ciPipelineName?: string + policyNames: string[] + linkedCIPipelineNames?: string[] } + export interface MandatoryPluginDetailType { id: number parentPluginId: number @@ -52,7 +48,7 @@ export interface MandatoryPluginDetailType { applied?: boolean inputVariables?: VariableType[] outputVariables?: VariableType[] - definitionSources?: DefinitionSourceType[] + definitionSources?: DefinitionSourceType } export interface MandatoryPluginDataType { pluginData: MandatoryPluginDetailType[] diff --git a/src/Shared/types.ts b/src/Shared/types.ts index e04329092..69ec7a669 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -439,6 +439,7 @@ export enum ResourceKindType { installation = 'installation', environment = 'environment', cdPipeline = 'cd-pipeline', + ciPipeline = 'ci-pipeline', project = 'project', } From 64d65f859185cc50d76b74db88df8bfa0b9861ec Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Mon, 14 Oct 2024 17:39:58 +0530 Subject: [PATCH 19/52] feat: Add ProcessPluginDataParamsType for CI and CD pipelines --- src/Common/Policy.Types.ts | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index b54bcc16b..3fdeb3fa3 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { PluginDataStoreType } from '../Shared' -import { VariableType } from './CIPipeline.Types' +import { PluginDataStoreType, PluginDetailPayloadType } from '../Shared' +import { FormType, VariableType } from './CIPipeline.Types' import { ServerErrors } from './ServerError' import { ResponseType } from './Types' @@ -62,6 +62,36 @@ export interface ProcessPluginDataReturnType { mandatoryPluginsError?: ServerErrors } +export type ProcessPluginDataCIParamsType = { + ciPipelineId: number + /** + * Comma separated branch names used for v1 api + * For v2 format is [branchName1],[branchName2] + */ + branchName?: string + + cdPipelineId?: never + envName?: never +} + +export type ProcessPluginDataCDParamsType = { + cdPipelineId: number + envName?: string + + ciPipelineId?: never + branchName?: never +} + +export type ProcessPluginDataParamsType = { + formData: FormType + pluginDataStoreState: PluginDataStoreType + appId: number + /** + * Would be sent in case we have to get data for steps + */ + requiredPluginIds: PluginDetailPayloadType['pluginId'] +} & (ProcessPluginDataCIParamsType | ProcessPluginDataCDParamsType) + export enum ConsequenceAction { BLOCK = 'BLOCK', ALLOW_UNTIL_TIME = 'ALLOW_UNTIL_TIME', From 27df864b0fc68e6536575e1bedfddf4da731e566 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:33:45 +0530 Subject: [PATCH 20/52] feat: add ci-pipeline to resource kind --- src/Shared/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 6631517b7..73944754d 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -438,6 +438,7 @@ export enum ResourceKindType { tenant = 'tenant', installation = 'installation', environment = 'environment', + ciPipeline = 'ci-pipeline', cdPipeline = 'cd-pipeline', project = 'project', } From 36553e56bbb71dfa4dc81ee9396077e4c086b582 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:58:52 +0530 Subject: [PATCH 21/52] feat: add type ALL query param to getParentPluginList --- src/Shared/Components/Plugin/service.tsx | 11 +++++------ src/Shared/Components/Plugin/types.ts | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index eb2d2861b..5f5c095e8 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -70,14 +70,13 @@ export const getPluginStoreData = async ({ appId, offset = 0, signal, - size = 20, }: GetPluginStoreDataServiceParamsType): Promise => { try { const payload: GetPluginListPayloadType = { searchKey, offset, appId, - size, + size: 20, tag: selectedTags, } const { result } = await get(getUrlWithSearchParams(ROUTES.PLUGIN_GLOBAL_LIST_V2, payload), { @@ -118,7 +117,7 @@ export const getAvailablePluginTags = async (appId: number): Promise = } } -export const getParentPluginList = async (appId?: number): Promise> => { - const queryParams: GetParentPluginListPayloadType = { appId } - return get(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, queryParams)) -} +export const getParentPluginList = async ( + params: Partial, +): Promise> => + get(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params)) diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index ebe0191fd..0abda6aaf 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -30,7 +30,9 @@ export interface PluginAPIBaseQueryParamsType { } export interface GetPluginTagsPayloadType extends PluginAPIBaseQueryParamsType {} -export interface GetParentPluginListPayloadType extends PluginAPIBaseQueryParamsType {} +export interface GetParentPluginListPayloadType extends PluginAPIBaseQueryParamsType { + type?: 'ALL' +} export interface PluginTagNamesDTO { tagNames: string[] @@ -73,7 +75,7 @@ export interface ParentPluginDTO { pluginIdentifier: string } -export interface MinParentPluginDTO extends Pick {} +export interface MinParentPluginDTO extends Pick {} export interface PluginDetailDTO { parentPlugins: ParentPluginDTO[] @@ -180,7 +182,6 @@ export interface GetPluginStoreDataServiceParamsType extends Pick Date: Tue, 15 Oct 2024 13:11:19 +0530 Subject: [PATCH 22/52] feat: add shouldShowNoOptionsMessage in select picker --- .../Components/SelectPicker/SelectPicker.component.tsx | 7 ++++++- src/Shared/Components/SelectPicker/type.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx index 48647ea7b..41003b6db 100644 --- a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx +++ b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx @@ -206,6 +206,7 @@ const SelectPicker = ({ isCreatable = false, onCreateOption, closeMenuOnSelect = false, + shouldShowNoOptionsMessage = true, ...props }: SelectPickerProps) => { const { inputId, required, isDisabled, controlShouldRenderValue = true, value, options } = props @@ -284,7 +285,11 @@ const SelectPicker = ({ return } - return

No options

+ if (shouldShowNoOptionsMessage) { + return

No options

+ } + + return null } const renderDisabledTippy = (children: ReactElement) => ( diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index 0aa998771..6e07623fb 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -222,6 +222,14 @@ export type SelectPickerProps Date: Tue, 15 Oct 2024 15:10:08 +0530 Subject: [PATCH 23/52] fix: optional arg for getParentPluginList --- src/Shared/Components/Plugin/service.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index 5f5c095e8..4461da9d2 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -118,6 +118,6 @@ export const getAvailablePluginTags = async (appId: number): Promise = } export const getParentPluginList = async ( - params: Partial, + params?: Partial, ): Promise> => get(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params)) From b53af78a0e04d3de2ea0cfa24665b040505971b9 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:28:02 +0530 Subject: [PATCH 24/52] doc: add js docs for consequence action --- src/Common/Policy.Types.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index f99dcfb45..a7f10b8b3 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -67,8 +67,17 @@ export interface ProcessPluginDataReturnType { } export enum ConsequenceAction { + /** + * This is used if the policy is enforced immediately. + */ BLOCK = 'BLOCK', + /** + * This is used if the policy will be enforced after a certain timestamp. + */ ALLOW_UNTIL_TIME = 'ALLOW_UNTIL_TIME', + /** + * This is used if the policy is not enforced yet (just to show waring). + */ ALLOW_FOREVER = 'ALLOW_FOREVER', } From 085837b86b793cb632ff22b0c39686e1660c743d Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:31:33 +0530 Subject: [PATCH 25/52] feat: pre cd and post cd --- src/Common/Policy.Types.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index a7f10b8b3..871f0a6c4 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -22,6 +22,11 @@ import { ResponseType } from './Types' export enum ApplyPolicyToStage { PRE_CI = 'PRE_CI', POST_CI = 'POST_CI', + PRE_CD = 'PRE_CD', + POST_CD = 'POST_CD', + /** + * @deprecated in mandatory plugin policy v2 + */ PRE_OR_POST_CI = 'PRE_OR_POST_CI', } From 2994ec0ba742090d2fb7efd485a37437696d2595 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Tue, 15 Oct 2024 18:36:33 +0530 Subject: [PATCH 26/52] chore: Remove isMandatory property from StepType interface --- src/Common/CIPipeline.Types.ts | 1 - src/Common/Policy.Types.ts | 11 +++++++---- src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Common/CIPipeline.Types.ts b/src/Common/CIPipeline.Types.ts index 86418dfde..ea92fb660 100644 --- a/src/Common/CIPipeline.Types.ts +++ b/src/Common/CIPipeline.Types.ts @@ -170,7 +170,6 @@ export interface StepType { inlineStepDetail?: InlineStepDetailType pluginRefStepDetail?: PluginRefStepDetailType triggerIfParentStageFail: boolean - isMandatory?: boolean } export interface BuildStageType { diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index 3fdeb3fa3..0a9764117 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { PluginDataStoreType, PluginDetailPayloadType } from '../Shared' +import { PluginDataStoreType, PluginDetailPayloadType, ResourceKindType } from '../Shared' import { FormType, VariableType } from './CIPipeline.Types' import { ServerErrors } from './ServerError' import { ResponseType } from './Types' @@ -27,10 +27,11 @@ export enum ApplyPolicyToStage { PRE_CD = 'PRE_CD', } +// This enum is mapping values from BuildStageVariable export enum PluginRequiredStage { - PRE_CI = 'preBuildStage', - POST_CI = 'postBuildStage', - PRE_OR_POST_CI = 'PRE_OR_POST_CI', + PRE_STAGE = 'preBuildStage', + POST_STAGE = 'postBuildStage', + PRE_OR_POST_STAGE = 'PRE_OR_POST_CI', } export interface DefinitionSourceType { @@ -63,6 +64,7 @@ export interface ProcessPluginDataReturnType { } export type ProcessPluginDataCIParamsType = { + resourceKind: ResourceKindType.ciPipeline ciPipelineId: number /** * Comma separated branch names used for v1 api @@ -75,6 +77,7 @@ export type ProcessPluginDataCIParamsType = { } export type ProcessPluginDataCDParamsType = { + resourceKind: ResourceKindType.cdPipeline cdPipelineId: number envName?: string diff --git a/src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx b/src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx index 729ddae89..62f5107b8 100644 --- a/src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx +++ b/src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx @@ -30,9 +30,11 @@ const InfoIconTippy = ({ placement = 'bottom', dataTestid = 'info-tippy-button', children, + headingInfo, }: InfoIconTippyProps) => ( Date: Wed, 16 Oct 2024 02:58:53 +0530 Subject: [PATCH 27/52] feat: Add TaskActionModalType and TaskActionModalStateType interfaces --- src/Shared/Components/Plugin/types.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 3b4dea25c..d05130cc2 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -250,3 +250,14 @@ export interface PluginTagsContainerProps { export interface PluginImageContainerProps extends Pick { fallbackImageClassName?: string } + +export enum TaskActionModalType { + DELETE = 'DELETE', + MOVE_PLUGIN = 'MOVE_PLUGIN', +} + +export interface TaskActionModalStateType { + type: TaskActionModalType + pluginId: PluginDetailType['id'] + taskIndex: number +} From 4dc9d3db576c2e0cf91156832859b300a8545f20 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:44:22 +0530 Subject: [PATCH 28/52] fix: handling for option comparison --- .../SelectPicker/SelectPicker.component.tsx | 5 ++-- src/Shared/Components/SelectPicker/type.ts | 2 +- src/Shared/Components/SelectPicker/utils.ts | 30 +++++++------------ 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx index 41003b6db..ee7e90ff1 100644 --- a/src/Shared/Components/SelectPicker/SelectPicker.component.tsx +++ b/src/Shared/Components/SelectPicker/SelectPicker.component.tsx @@ -209,7 +209,7 @@ const SelectPicker = ({ shouldShowNoOptionsMessage = true, ...props }: SelectPickerProps) => { - const { inputId, required, isDisabled, controlShouldRenderValue = true, value, options } = props + const { inputId, required, isDisabled, controlShouldRenderValue = true, value, options, getOptionValue } = props const { isGroupHeadingSelectable = false, getIsOptionValid = () => true } = multiSelectProps // Only large variant is supported for multi select picker @@ -246,8 +246,9 @@ const SelectPicker = ({ value as SelectPickerOptionType[], trimmedInput as OptionValue, null, + getOptionValue, ) && - !getSelectPickerOptionByValue(options, trimmedInput as OptionValue, null) + !getSelectPickerOptionByValue(options, trimmedInput as OptionValue, null, getOptionValue) ) } diff --git a/src/Shared/Components/SelectPicker/type.ts b/src/Shared/Components/SelectPicker/type.ts index 6e07623fb..b1ecf7bc0 100644 --- a/src/Shared/Components/SelectPicker/type.ts +++ b/src/Shared/Components/SelectPicker/type.ts @@ -271,7 +271,7 @@ export interface FilterSelectPickerProps | 'shouldMenuAlignRight' | 'optionListError' | 'reloadOptionList' - | 'getOptionLabel' + | 'getOptionValue' > { appliedFilterOptions: SelectPickerOptionType[] handleApplyFilter: (filtersToApply: SelectPickerOptionType[]) => void diff --git a/src/Shared/Components/SelectPicker/utils.ts b/src/Shared/Components/SelectPicker/utils.ts index fa765114c..ce5a7f93d 100644 --- a/src/Shared/Components/SelectPicker/utils.ts +++ b/src/Shared/Components/SelectPicker/utils.ts @@ -340,36 +340,28 @@ export const getGroupCheckboxValue = ( * @param optionsList - The list of options or groups of options. * @param value - The value to compare against the options' values. * @param defaultOption - The default option to return if no match is found. + * @param getOptionValue - Override the default value for the option * @returns The matched option or the default option if no match is found. */ export const getSelectPickerOptionByValue = ( optionsList: OptionsOrGroups, GroupBase>>, value: OptionValue, defaultOption: SelectPickerOptionType = { label: '', value: '' as unknown as OptionValue }, + getOptionValue: SelectPickerProps['getOptionValue'] = null, ): SelectPickerOptionType => { if (!Array.isArray(optionsList)) { return defaultOption } - const foundOption = optionsList.reduce( - (acc, curr) => { - if (!acc.notFound) return acc + const flatOptionsList = optionsList.flatMap>((groupOrBaseOption) => + 'options' in groupOrBaseOption ? groupOrBaseOption.options : [groupOrBaseOption], + ) - if ('value' in curr && curr.value === value) { - return { data: curr, notFound: false } - } - - if ('options' in curr && curr.options) { - const nestedOption = curr.options.find(({ value: _value }) => _value === value) - if (nestedOption) { - return { data: nestedOption, notFound: false } - } - } - - return acc - }, - { notFound: true, data: defaultOption }, - ).data + return ( + flatOptionsList.find((option) => { + const optionValue = getOptionValue ? getOptionValue(option) : option.value - return foundOption + return optionValue === value + }) ?? defaultOption + ) } From 50117b773e5448995b062702eb4a9d993626217f Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:45:13 +0530 Subject: [PATCH 29/52] 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 5fabfab8a..116482cbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0", + "version": "0.5.0-beta-7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0", + "version": "0.5.0-beta-7", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 39d63d669..abfb27853 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.0", + "version": "0.5.0-beta-7", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From d2ac10c3b7cd28bdd8e7911bb0085c0d206f2dc0 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 16 Oct 2024 14:56:19 +0530 Subject: [PATCH 30/52] feat: add types related to mandatory plugin consequences --- src/Common/Types.ts | 15 ++++++--------- src/Shared/Components/Plugin/types.ts | 8 +++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Common/Types.ts b/src/Common/Types.ts index 690b9ac2d..ce48fecaa 100644 --- a/src/Common/Types.ts +++ b/src/Common/Types.ts @@ -19,7 +19,7 @@ import { Placement } from 'tippy.js' import { UserGroupDTO } from '@Pages/GlobalConfigurations' import { ImageComment, ReleaseTag } from './ImageTags.Types' import { ACTION_STATE, DEPLOYMENT_WINDOW_TYPE, DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.' -import { RegistryType, RuntimeParamsListItemType, Severity } from '../Shared' +import { MandatoryPluginNodeType, RegistryType, RuntimeParamsListItemType, Severity } from '../Shared' /** * Generic response type object with support for overriding the result type @@ -552,7 +552,7 @@ export interface DownstreamNodesEnvironmentsType { environmentName: string } -export interface CommonNodeAttr { +export interface CommonNodeAttr extends Pick { connectingCiPipelineId?: number parents: string | number[] | string[] x: number @@ -602,15 +602,10 @@ export interface CommonNodeAttr { approvalUsers?: string[] userApprovalConfig?: UserApprovalConfigType requestedUserId?: number - showPluginWarning?: boolean + showPluginWarning: boolean helmPackageName?: string isVirtualEnvironment?: boolean deploymentAppType?: DeploymentAppTypes - isCITriggerBlocked?: boolean - ciBlockState?: { - action: any - metadataField: string - } appReleaseTagNames?: string[] tagsEditable?: boolean isGitOpsRepoNotConfigured?: boolean @@ -791,7 +786,7 @@ export interface CDStageConfigMapSecretNames { secrets: any[] } -export interface PrePostDeployStageType { +export interface PrePostDeployStageType extends MandatoryPluginNodeType { isValid: boolean steps: TaskErrorObj[] triggerType: string @@ -829,6 +824,8 @@ export interface CdPipeline { preDeployStage?: PrePostDeployStageType postDeployStage?: PrePostDeployStageType isProdEnv?: boolean + isGitOpsRepoNotConfigured?: boolean + isDeploymentBlocked?: boolean } export interface ExternalCiConfig { diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index d05130cc2..14a1d81b1 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -15,7 +15,7 @@ */ import { MutableRefObject } from 'react' -import { VariableType } from '../../../Common' +import { ConsequenceType, VariableType } from '../../../Common' import { BaseFilterQueryParams } from '../../types' import { ImageWithFallbackProps } from '../ImageWithFallback' import { getPluginStoreData } from './service' @@ -261,3 +261,9 @@ export interface TaskActionModalStateType { pluginId: PluginDetailType['id'] taskIndex: number } + +export interface MandatoryPluginNodeType { + isOffendingMandatoryPlugin: boolean + isTriggerBlocked: boolean + pluginBlockState: ConsequenceType +} From 47c151fb81c52eb1addb4b6f3f974c9c6a21290c Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 16 Oct 2024 17:13:42 +0530 Subject: [PATCH 31/52] chore: remove dead code --- src/Common/Policy.Types.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index 0a9764117..3e4d78c57 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -17,7 +17,6 @@ import { PluginDataStoreType, PluginDetailPayloadType, ResourceKindType } from '../Shared' import { FormType, VariableType } from './CIPipeline.Types' import { ServerErrors } from './ServerError' -import { ResponseType } from './Types' export enum ApplyPolicyToStage { PRE_CI = 'PRE_CI', @@ -111,7 +110,3 @@ export interface BlockedStateData { isCITriggerBlocked: boolean ciBlockState: ConsequenceType } - -export interface GetBlockedStateResponse extends ResponseType { - result?: BlockedStateData -} From 5e371887eb8b5911dd008da4dd59ec8e5f43d251 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Thu, 17 Oct 2024 23:52:48 +0530 Subject: [PATCH 32/52] fix: remove duplicated enums --- src/Common/Policy.Types.ts | 7 ++----- src/Shared/types.ts | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index f890f49df..fc108ecd4 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -21,14 +21,12 @@ import { ServerErrors } from './ServerError' export enum ApplyPolicyToStage { PRE_CI = 'PRE_CI', POST_CI = 'POST_CI', - PRE_CD = 'PRE_CD', - POST_CD = 'POST_CD', /** * @deprecated in mandatory plugin policy v2 */ PRE_OR_POST_CI = 'PRE_OR_POST_CI', - POST_CD = 'POST_CD', PRE_CD = 'PRE_CD', + POST_CD = 'POST_CD', } // This enum is mapping values from BuildStageVariable @@ -76,13 +74,11 @@ export type ProcessPluginDataCIParamsType = { */ branchName?: string - cdPipelineId?: never envName?: never } export type ProcessPluginDataCDParamsType = { resourceKind: ResourceKindType.cdPipeline - cdPipelineId: number envName?: string ciPipelineId?: never @@ -93,6 +89,7 @@ export type ProcessPluginDataParamsType = { formData: FormType pluginDataStoreState: PluginDataStoreType appId: number + appName: string /** * Would be sent in case we have to get data for steps */ diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 8ec942258..e157ad107 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -438,7 +438,6 @@ export enum ResourceKindType { tenant = 'tenant', installation = 'installation', environment = 'environment', - ciPipeline = 'ci-pipeline', cdPipeline = 'cd-pipeline', ciPipeline = 'ci-pipeline', project = 'project', From abf00c9f2e620586758d49e15b318d3638934ebf Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:53:04 +0530 Subject: [PATCH 33/52] fix: add tooltip on filter chip truncation --- src/Shared/Components/FilterChips/FilterChips.component.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Shared/Components/FilterChips/FilterChips.component.tsx b/src/Shared/Components/FilterChips/FilterChips.component.tsx index e39a9373b..3ac83548f 100644 --- a/src/Shared/Components/FilterChips/FilterChips.component.tsx +++ b/src/Shared/Components/FilterChips/FilterChips.component.tsx @@ -15,7 +15,7 @@ */ import { ReactComponent as CloseIcon } from '../../../Assets/Icon/ic-close.svg' -import { noop } from '../../../Common' +import { noop, Tooltip } from '../../../Common' import { FilterChipProps, FilterChipsProps } from './types' const FilterChip = ({ @@ -45,7 +45,9 @@ const FilterChip = ({ )} - {valueToDisplay} + + {valueToDisplay} + {showRemoveIcon && (
From 176073f7e7849e129335e4289127388f77b84098 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Mon, 21 Oct 2024 00:20:41 +0530 Subject: [PATCH 36/52] chore: rename mandatory plugin types --- src/Common/Types.ts | 6 +++--- src/Shared/Components/Plugin/types.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Common/Types.ts b/src/Common/Types.ts index ce48fecaa..e194c174e 100644 --- a/src/Common/Types.ts +++ b/src/Common/Types.ts @@ -19,7 +19,7 @@ import { Placement } from 'tippy.js' import { UserGroupDTO } from '@Pages/GlobalConfigurations' import { ImageComment, ReleaseTag } from './ImageTags.Types' import { ACTION_STATE, DEPLOYMENT_WINDOW_TYPE, DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.' -import { MandatoryPluginNodeType, RegistryType, RuntimeParamsListItemType, Severity } from '../Shared' +import { MandatoryPluginBaseStateType, RegistryType, RuntimeParamsListItemType, Severity } from '../Shared' /** * Generic response type object with support for overriding the result type @@ -552,7 +552,7 @@ export interface DownstreamNodesEnvironmentsType { environmentName: string } -export interface CommonNodeAttr extends Pick { +export interface CommonNodeAttr extends Pick { connectingCiPipelineId?: number parents: string | number[] | string[] x: number @@ -786,7 +786,7 @@ export interface CDStageConfigMapSecretNames { secrets: any[] } -export interface PrePostDeployStageType extends MandatoryPluginNodeType { +export interface PrePostDeployStageType extends MandatoryPluginBaseStateType { isValid: boolean steps: TaskErrorObj[] triggerType: string diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 8bf65ce16..8c2c68c3d 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -254,18 +254,18 @@ export interface PluginImageContainerProps extends Pick Date: Mon, 21 Oct 2024 00:29:33 +0530 Subject: [PATCH 37/52] refactor: Update import statements in Policy.Types.ts --- src/Common/Policy.Types.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index fc108ecd4..41ac5405d 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -14,8 +14,9 @@ * limitations under the License. */ +import { PipelineFormType } from '@Pages/CDPipeline' import { PluginDataStoreType, PluginDetailPayloadType, ResourceKindType } from '../Shared' -import { FormType, VariableType } from './CIPipeline.Types' +import { VariableType } from './CIPipeline.Types' import { ServerErrors } from './ServerError' export enum ApplyPolicyToStage { @@ -86,14 +87,14 @@ export type ProcessPluginDataCDParamsType = { } export type ProcessPluginDataParamsType = { - formData: FormType + formData: PipelineFormType pluginDataStoreState: PluginDataStoreType appId: number appName: string /** * Would be sent in case we have to get data for steps */ - requiredPluginIds: PluginDetailPayloadType['pluginId'] + requiredPluginIds?: PluginDetailPayloadType['pluginId'] } & (ProcessPluginDataCIParamsType | ProcessPluginDataCDParamsType) export enum ConsequenceAction { From f748a0f083595ffda4fc2cde6b83c5b641818a18 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:18:23 +0530 Subject: [PATCH 38/52] fix: remove showOnTruncate --- src/Shared/Components/FilterChips/FilterChips.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/Components/FilterChips/FilterChips.component.tsx b/src/Shared/Components/FilterChips/FilterChips.component.tsx index 3ac83548f..63ea141eb 100644 --- a/src/Shared/Components/FilterChips/FilterChips.component.tsx +++ b/src/Shared/Components/FilterChips/FilterChips.component.tsx @@ -45,7 +45,7 @@ const FilterChip = ({ )} - + {valueToDisplay} {showRemoveIcon && ( From 1f060946421e4c24870833e10087d6121347d668 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:06:36 +0530 Subject: [PATCH 39/52] fix: typing for consequence type --- src/Common/Policy.Types.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index 871f0a6c4..9741af7a6 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -86,10 +86,18 @@ export enum ConsequenceAction { ALLOW_FOREVER = 'ALLOW_FOREVER', } -export interface ConsequenceType { - action: ConsequenceAction - metadataField: string -} +export type ConsequenceType = + | { + action: Exclude + metadataField?: never | null + } + | { + action: ConsequenceAction.ALLOW_UNTIL_TIME + /** + * Denotes the time till which the policy enforcement is relaxed + */ + metadataField: string + } export interface BlockedStateData { isOffendingMandatoryPlugin: boolean From fdfebbb8b6490e76a5922c73c09939a14c6c0187 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:13:36 +0530 Subject: [PATCH 40/52] fix: typing for ci block state --- src/Common/Types.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Common/Types.ts b/src/Common/Types.ts index 690b9ac2d..4ed5b080f 100644 --- a/src/Common/Types.ts +++ b/src/Common/Types.ts @@ -18,7 +18,7 @@ import React, { ReactNode, CSSProperties, ReactElement } from 'react' import { Placement } from 'tippy.js' import { UserGroupDTO } from '@Pages/GlobalConfigurations' import { ImageComment, ReleaseTag } from './ImageTags.Types' -import { ACTION_STATE, DEPLOYMENT_WINDOW_TYPE, DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.' +import { ACTION_STATE, ConsequenceType, DEPLOYMENT_WINDOW_TYPE, DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.' import { RegistryType, RuntimeParamsListItemType, Severity } from '../Shared' /** @@ -607,10 +607,7 @@ export interface CommonNodeAttr { isVirtualEnvironment?: boolean deploymentAppType?: DeploymentAppTypes isCITriggerBlocked?: boolean - ciBlockState?: { - action: any - metadataField: string - } + ciBlockState?: ConsequenceType appReleaseTagNames?: string[] tagsEditable?: boolean isGitOpsRepoNotConfigured?: boolean From 2e4ccc50731113ec5dcfc0f725811b046c28c79e Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Mon, 21 Oct 2024 23:41:01 +0530 Subject: [PATCH 41/52] Update version in package-lock.json and package.json --- 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 25737f590..f08a30742 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.2-beta-6", + "version": "0.5.2-beta-9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.2-beta-6", + "version": "0.5.2-beta-9", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index ec2424a41..e3d11be60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.2-beta-6", + "version": "0.5.2-beta-9", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 64f026bdba1982cbcc0dabf663d19a25358a1648 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Tue, 22 Oct 2024 11:55:37 +0530 Subject: [PATCH 42/52] Update version in package-lock.json and package.json --- 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 1a5841757..947e85d82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-1", + "version": "0.5.8-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-1", + "version": "0.5.8-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 11a8b0bd6..6b90aa90c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-1", + "version": "0.5.8-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From ceb1f6489a0b612d85fd172a504245043cf9ab31 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:02:31 +0530 Subject: [PATCH 43/52] fix: button width issue in toast --- src/Shared/Components/Button/Button.component.tsx | 2 +- src/Shared/Services/ToastManager/toastManager.scss | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Shared/Components/Button/Button.component.tsx b/src/Shared/Components/Button/Button.component.tsx index 18f2ec28e..7c4fa4409 100644 --- a/src/Shared/Components/Button/Button.component.tsx +++ b/src/Shared/Components/Button/Button.component.tsx @@ -172,7 +172,7 @@ const Button = ({ diff --git a/src/Shared/Services/ToastManager/toastManager.scss b/src/Shared/Services/ToastManager/toastManager.scss index 1263b125a..deaa36eb2 100644 --- a/src/Shared/Services/ToastManager/toastManager.scss +++ b/src/Shared/Services/ToastManager/toastManager.scss @@ -49,6 +49,7 @@ // Override the style for the action button button.button, a.button { color: var(--N0); + width: fit-content; svg *[stroke^="#"] { stroke: var(--N0); From 89dc9f920e6bcd0aad96056efe51c4df897a9665 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 23 Oct 2024 10:37:20 +0530 Subject: [PATCH 44/52] chore: add a comment for CDPipeline build stage --- src/Common/Policy.Types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index 0ccb54a77..b18617026 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -30,6 +30,7 @@ export enum ApplyPolicyToStage { POST_CD = 'POST_CD', } +// FIXME: The name build is getting is used in CDPipeline. // This enum is mapping values from BuildStageVariable export enum PluginRequiredStage { PRE_STAGE = 'preBuildStage', From 463d2eb2896f3cd757b7b06cb073f0e4397bd53b Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:32:16 +0530 Subject: [PATCH 45/52] fix: add prevent default on selection of plugin --- src/Shared/Components/Plugin/PluginCard.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Shared/Components/Plugin/PluginCard.tsx b/src/Shared/Components/Plugin/PluginCard.tsx index 60ee27a04..62c022c0c 100644 --- a/src/Shared/Components/Plugin/PluginCard.tsx +++ b/src/Shared/Components/Plugin/PluginCard.tsx @@ -33,6 +33,8 @@ const PluginCard = ({ pluginDataStore.pluginVersionStore[latestPluginId] const handleSelection = (e: React.MouseEvent | React.KeyboardEvent) => { + // Added to ensure that the event is not bubbled to the div in case of click on the checkbox + e.preventDefault() if ('key' in e && e.key !== 'Enter' && e.key !== ' ') { return } From 840effffca45ee307f59011eb290e10ca9400999 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 23 Oct 2024 12:15:13 +0530 Subject: [PATCH 46/52] fix: remove isLatest from plugin info due to volatile nature --- src/Shared/Components/Plugin/types.ts | 7 ++----- src/Shared/Components/Plugin/utils.tsx | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 8c2c68c3d..972c2f8d2 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -104,7 +104,7 @@ export interface PluginListFiltersType extends Pick { latestVersionId: MinimalPluginVersionDataDTO['id'] pluginVersions: MinimalPluginVersionDataDTO[] @@ -112,10 +112,7 @@ interface ParentPluginType interface DetailedPluginVersionType extends Pick, - Pick< - DetailedPluginVersionDTO, - 'tags' | 'isLatest' | 'inputVariables' | 'outputVariables' | 'updatedBy' | 'docLink' - >, + Pick, Pick { parentPluginId: ParentPluginType['id'] } diff --git a/src/Shared/Components/Plugin/utils.tsx b/src/Shared/Components/Plugin/utils.tsx index e8b6c1b21..271939a7c 100644 --- a/src/Shared/Components/Plugin/utils.tsx +++ b/src/Shared/Components/Plugin/utils.tsx @@ -84,7 +84,6 @@ export const parsePluginDetailsDTOIntoPluginStore = (pluginData: ParentPluginDTO plugin.type === PluginCreationType.SHARED ? pluginVersionData.updatedBy : DEFAULT_PLUGIN_CREATED_BY, outputVariables: pluginVersionData.outputVariables || [], inputVariables: pluginVersionData.inputVariables || [], - isLatest: pluginVersionData.isLatest || false, tags: sortedUniqueTags, parentPluginId: plugin.id, icon: plugin.icon || '', From 486034e1bddd98bdcd26a470063c1f89ba650bc3 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 23 Oct 2024 13:25:59 +0530 Subject: [PATCH 47/52] chore: update devtron-fe-common-lib version to 0.5.8-beta-4 --- 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 947e85d82..0892335a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-2", + "version": "0.5.8-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-2", + "version": "0.5.8-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 6b90aa90c..6cd6a7dee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-2", + "version": "0.5.8-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From e3bb51b225f7c15e24ea23ef5d37fd0aaf6dec12 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Wed, 23 Oct 2024 13:28:58 +0530 Subject: [PATCH 48/52] chore: update devtron-fe-common-lib version to 0.5.8-beta-5 --- 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 0892335a4..cee9ce365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-4", + "version": "0.5.8-beta-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-4", + "version": "0.5.8-beta-5", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 6cd6a7dee..91159b5cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-4", + "version": "0.5.8-beta-5", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 5871194a56259541d04e5e72e0c142a65272f371 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:49:56 +0530 Subject: [PATCH 49/52] fix: group env options by cluster --- package-lock.json | 4 +- package.json | 2 +- .../useGetResourceKindsOptions/service.ts | 61 ++++++++++++------- .../Hooks/useGetResourceKindsOptions/types.ts | 11 +++- .../useGetResourceKindsOptions.tsx | 9 ++- 5 files changed, 57 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index cee9ce365..8f161cb4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-5", + "version": "0.5.8-beta-8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-5", + "version": "0.5.8-beta-8", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 91159b5cb..f9c5cf7c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-5", + "version": "0.5.8-beta-8", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Hooks/useGetResourceKindsOptions/service.ts b/src/Shared/Hooks/useGetResourceKindsOptions/service.ts index c67f29585..88b5a9278 100644 --- a/src/Shared/Hooks/useGetResourceKindsOptions/service.ts +++ b/src/Shared/Hooks/useGetResourceKindsOptions/service.ts @@ -18,11 +18,11 @@ import { ResponseType, Teams } from '@Common/Types' import { getTeamListMin } from '@Common/Common.service' import { get } from '@Common/Api' import { ClusterType } from '@Shared/Services' -import { EnvironmentType, EnvListMinDTO } from '@Shared/types' +import { EnvListMinDTO } from '@Shared/types' import { EnvironmentTypeEnum } from '@Shared/constants' import { ROUTES } from '@Common/Constants' import { stringComparatorBySortOrder } from '@Shared/Helpers' -import { AppsGroupedByProjectsType, ClusterDTO } from './types' +import { AppsGroupedByProjectsType, ClusterDTO, EnvironmentsGroupedByClustersType } from './types' export const getAppOptionsGroupedByProjects = async (): Promise => { const { result } = (await get(ROUTES.APP_LIST_MIN)) as ResponseType @@ -70,30 +70,47 @@ export const getClusterOptions = async (): Promise => { .sort((a, b) => stringComparatorBySortOrder(a.name, b.name)) } -export const getEnvironmentOptions = async (): Promise => { +export const getEnvironmentOptionsGroupedByClusters = async (): Promise => { const { result } = (await get(ROUTES.ENVIRONMENT_LIST_MIN)) as ResponseType if (!result) { return [] } - return result - .map( - ({ - id, - environment_name: name, - isVirtualEnvironment, - cluster_name: cluster, - default: isDefault, - namespace, - }) => ({ - id, - name, - isVirtual: isVirtualEnvironment ?? false, - cluster, - environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction, - namespace, - }), - ) - .sort((a, b) => stringComparatorBySortOrder(a.name, b.name)) + const sortedEnvList = result.map( + ({ + id, + environment_name: name, + isVirtualEnvironment, + cluster_name: cluster, + default: isDefault, + namespace, + }) => ({ + id, + name, + isVirtual: isVirtualEnvironment ?? false, + cluster, + environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction, + namespace, + }), + ) + + const envGroupedByCluster = Object.values( + sortedEnvList.reduce< + Record + >((acc, env) => { + if (!acc[env.cluster]) { + acc[env.cluster] = { + clusterName: env.cluster, + envList: [], + } + } + + acc[env.cluster].envList.push(env) + + return acc + }, {}), + ).sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName)) + + return envGroupedByCluster } diff --git a/src/Shared/Hooks/useGetResourceKindsOptions/types.ts b/src/Shared/Hooks/useGetResourceKindsOptions/types.ts index 7c72b8492..f87d9db7e 100644 --- a/src/Shared/Hooks/useGetResourceKindsOptions/types.ts +++ b/src/Shared/Hooks/useGetResourceKindsOptions/types.ts @@ -16,9 +16,9 @@ // ====== Service Types: Start ====== // -import { ResourceKindType } from '@Shared/types' +import { EnvironmentType, ResourceKindType } from '@Shared/types' import { ServerErrors } from '@Common/ServerError' -import { getAppOptionsGroupedByProjects, getClusterOptions, getEnvironmentOptions, getProjectOptions } from './service' +import { getAppOptionsGroupedByProjects, getClusterOptions, getProjectOptions } from './service' export interface AppType { name: string @@ -30,6 +30,11 @@ export type AppsGroupedByProjectsType = { appList: AppType[] }[] +export type EnvironmentsGroupedByClustersType = { + clusterName: EnvironmentType['cluster'] + envList: EnvironmentType[] +}[] + export interface ClusterDTO { id: number cluster_name: string @@ -54,7 +59,7 @@ export interface UseGetResourceKindOptionsReturnType { [ResourceKindType.devtronApplication]: Awaited> [ResourceKindType.project]: Awaited> [ResourceKindType.cluster]: Awaited> - [ResourceKindType.environment]: Awaited> + [ResourceKindType.environment]: EnvironmentsGroupedByClustersType } resourcesOptionsError: ServerErrors refetchResourcesOptions: () => void diff --git a/src/Shared/Hooks/useGetResourceKindsOptions/useGetResourceKindsOptions.tsx b/src/Shared/Hooks/useGetResourceKindsOptions/useGetResourceKindsOptions.tsx index 104eaa689..4bd2f3829 100644 --- a/src/Shared/Hooks/useGetResourceKindsOptions/useGetResourceKindsOptions.tsx +++ b/src/Shared/Hooks/useGetResourceKindsOptions/useGetResourceKindsOptions.tsx @@ -17,7 +17,12 @@ import { useMemo } from 'react' import { ResourceKindType } from '@Shared/types' import { useAsync } from '@Common/Helper' -import { getAppOptionsGroupedByProjects, getClusterOptions, getEnvironmentOptions, getProjectOptions } from './service' +import { + getAppOptionsGroupedByProjects, + getClusterOptions, + getEnvironmentOptionsGroupedByClusters, + getProjectOptions, +} from './service' import { UseGetResourceKindOptionsReturnType, UseGetResourceKindsOptionsProps } from './types' import { getResourcesToFetchMap } from './utils' @@ -43,7 +48,7 @@ const useGetResourceKindsOptions = ({ resourcesToFetchMap[ResourceKindType.devtronApplication] ? getAppOptionsGroupedByProjects() : null, resourcesToFetchMap[ResourceKindType.project] ? getProjectOptions() : null, resourcesToFetchMap[ResourceKindType.cluster] ? getClusterOptions() : null, - resourcesToFetchMap[ResourceKindType.environment] ? getEnvironmentOptions() : null, + resourcesToFetchMap[ResourceKindType.environment] ? getEnvironmentOptionsGroupedByClusters() : null, ]), [resourcesToFetchMap], resourcesToFetch.length > 0, From c117dbce00a6741a5e7efaa613f5e4accc784f36 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:09:24 +0530 Subject: [PATCH 50/52] fix: formatting issues --- src/Shared/Components/SelectPicker/common.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/Components/SelectPicker/common.tsx b/src/Shared/Components/SelectPicker/common.tsx index f912ec8d4..40213de23 100644 --- a/src/Shared/Components/SelectPicker/common.tsx +++ b/src/Shared/Components/SelectPicker/common.tsx @@ -227,7 +227,7 @@ export const SelectPickerMultiValueLabel = ['multiSelectProps'], 'getIsOptionValid'>) => { const { data, selectProps } = props const isOptionValid = getIsOptionValid(data) - const iconToDisplay = isOptionValid ? (data.startIcon || data.endIcon) ?? null : + const iconToDisplay = isOptionValid ? ((data.startIcon || data.endIcon) ?? null) : return (
From b341c9edfaf89e6ee8e144fbf3294d9834d4aef2 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:26:23 +0530 Subject: [PATCH 51/52] fix: add sorting for parent plugin list and env list --- src/Shared/Components/Plugin/service.tsx | 10 ++++-- .../useGetResourceKindsOptions/service.ts | 36 ++++++++++--------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index 4461da9d2..1dc8ae23f 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -119,5 +119,11 @@ export const getAvailablePluginTags = async (appId: number): Promise = export const getParentPluginList = async ( params?: Partial, -): Promise> => - get(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params)) +): Promise> => { + const response = await get(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params)) + + return { + ...response, + result: (response?.result ?? []).sort((a, b) => stringComparatorBySortOrder(a.name, b.name)), + } +} diff --git a/src/Shared/Hooks/useGetResourceKindsOptions/service.ts b/src/Shared/Hooks/useGetResourceKindsOptions/service.ts index 88b5a9278..e4c9ebf64 100644 --- a/src/Shared/Hooks/useGetResourceKindsOptions/service.ts +++ b/src/Shared/Hooks/useGetResourceKindsOptions/service.ts @@ -77,23 +77,25 @@ export const getEnvironmentOptionsGroupedByClusters = async (): Promise ({ - id, - name, - isVirtual: isVirtualEnvironment ?? false, - cluster, - environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction, - namespace, - }), - ) + const sortedEnvList = result + .map( + ({ + id, + environment_name: name, + isVirtualEnvironment, + cluster_name: cluster, + default: isDefault, + namespace, + }) => ({ + id, + name, + isVirtual: isVirtualEnvironment ?? false, + cluster, + environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction, + namespace, + }), + ) + .sort((a, b) => stringComparatorBySortOrder(a.name, b.name)) const envGroupedByCluster = Object.values( sortedEnvList.reduce< From 0ebde9190a401d29159c2a830ae214c7902ccb4a Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:47:25 +0530 Subject: [PATCH 52/52] chore: bump version to 0.6.1-beta-10 --- 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 34d4c3109..d8ed334fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.1-beta-9", + "version": "0.6.1-beta-10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.1-beta-9", + "version": "0.6.1-beta-10", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index da23e05d0..9194fd114 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.1-beta-9", + "version": "0.6.1-beta-10", "description": "Supporting common component library", "type": "module", "main": "dist/index.js",