Skip to content

Commit 3b956ba

Browse files
Merge pull request #205 from devtron-labs/fix/plugin-version
feat: add prop to configure showError for mandatory plugins
2 parents dc6eaa2 + 3686ed8 commit 3b956ba

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/Common/Policy.Types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { PluginDataStoreType } from '../Shared'
1818
import { VariableType } from './CIPipeline.Types'
19+
import { ServerErrors } from './ServerError'
1920
import { ResponseType } from './Types'
2021

2122
export enum ApplyPolicyToStage {
@@ -62,6 +63,7 @@ export interface MandatoryPluginDataType {
6263
export interface ProcessPluginDataReturnType {
6364
mandatoryPluginData: MandatoryPluginDataType
6465
pluginDataStore: PluginDataStoreType
66+
mandatoryPluginsError?: ServerErrors
6567
}
6668

6769
export enum ConsequenceAction {

src/Shared/Components/Plugin/service.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const getPluginsDetail = async ({
1616
appId,
1717
parentPluginIds,
1818
pluginIds,
19+
shouldShowError = true,
1920
}: PluginDetailServiceParamsType): Promise<Pick<GetPluginStoreDataReturnType, 'pluginStore'>> => {
2021
try {
2122
const payload: PluginDetailPayloadType = {
@@ -34,7 +35,9 @@ export const getPluginsDetail = async ({
3435
pluginStore,
3536
}
3637
} catch (error) {
37-
showError(error)
38+
if (shouldShowError) {
39+
showError(error)
40+
}
3841
throw error
3942
}
4043
}

src/Shared/Components/Plugin/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export interface PluginDetailServiceParamsType {
6262
appId: number
6363
pluginIds?: number[]
6464
parentPluginIds?: number[]
65+
/**
66+
* @default true
67+
*/
68+
shouldShowError?: boolean
6569
}
6670

6771
export interface PluginDetailPayloadType extends Pick<PluginDetailServiceParamsType, 'appId'> {

src/Shared/Components/Plugin/utils.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const pluginTagSelectStyles = {
9999
}
100100

101101
/**
102-
* @description This method takes the initial plugin data store and updates only keys that are not present in the initial store with the values from the target store.
102+
* @description This method takes the initial plugin data store and updates the keys with the target parent plugin store and plugin version store
103103
*/
104104
export const getUpdatedPluginStore = (
105105
initialPluginDataStore: PluginDataStoreType,
@@ -109,15 +109,11 @@ export const getUpdatedPluginStore = (
109109
const clonedPluginDataStore = structuredClone(initialPluginDataStore)
110110

111111
Object.keys(targetParentPluginStore).forEach((key) => {
112-
if (!clonedPluginDataStore.parentPluginStore[key]) {
113-
clonedPluginDataStore.parentPluginStore[key] = targetParentPluginStore[key]
114-
}
112+
clonedPluginDataStore.parentPluginStore[key] = targetParentPluginStore[key]
115113
})
116114

117115
Object.keys(targetPluginVersionStore).forEach((key) => {
118-
if (!clonedPluginDataStore.pluginVersionStore[key]) {
119-
clonedPluginDataStore.pluginVersionStore[key] = targetPluginVersionStore[key]
120-
}
116+
clonedPluginDataStore.pluginVersionStore[key] = targetPluginVersionStore[key]
121117
})
122118

123119
return clonedPluginDataStore

0 commit comments

Comments
 (0)