Skip to content

Commit 47fc942

Browse files
committed
feat: use search params in delete helm app api
1 parent 29e0f53 commit 47fc942

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/components/charts/charts.service.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { get, post, put, trash, sortCallback, ResponseType } from '@devtron-labs/devtron-fe-common-lib'
17+
import { get, post, put, trash, sortCallback, ResponseType, getUrlWithSearchParams } from '@devtron-labs/devtron-fe-common-lib'
1818
import { DELETE_ACTION, Routes } from '../../config'
1919
import { getAPIOptionsWithTriggerTimeout, handleUTCTime } from '../common'
20-
import { ChartValuesType, ChartGroup, HelmTemplateChartRequest, HelmProjectUpdatePayload } from './charts.types'
20+
import { ChartValuesType, ChartGroup, HelmTemplateChartRequest, HelmProjectUpdatePayload, DeleteInstalledChartParamsType } from './charts.types'
2121
import { SavedValueListResponse } from './SavedValues/types'
2222

2323
interface RootObject {
@@ -57,19 +57,22 @@ export function deleteInstalledChart(
5757
isGitops?: boolean,
5858
deleteAction?: DELETE_ACTION,
5959
) {
60-
let URL: string = `app-store/deployment/application/delete/${installedAppId}`
61-
if (isGitops) {
62-
if (deleteAction === DELETE_ACTION.DELETE) {
63-
URL += `?partialDelete=true`
64-
} else if (deleteAction === DELETE_ACTION.NONCASCADE_DELETE) {
65-
URL += `?partialDelete=true&cascade=false`
66-
} else if (deleteAction === DELETE_ACTION.FORCE_DELETE) {
67-
URL += `?force=true`
60+
const baseUrl: string = `app-store/deployment/application/delete/${installedAppId}`
61+
let params: DeleteInstalledChartParamsType = {}
62+
const url = getUrlWithSearchParams(baseUrl, params)
63+
if (deleteAction === DELETE_ACTION.FORCE_DELETE) {
64+
params = {
65+
forceDelete: true
66+
}
67+
} else if (isGitops) {
68+
deleteAction === DELETE_ACTION.NONCASCADE_DELETE ? params = {
69+
partialDelete: true,
70+
cascade: false
71+
} : params = {
72+
partialDelete: true
6873
}
69-
} else if (!isGitops && deleteAction === DELETE_ACTION.FORCE_DELETE) {
70-
URL += `?force=true`
7174
}
72-
return trash(URL)
75+
return trash(url)
7376
}
7477

7578
export function getChartValuesTemplateList(chartId: number | string): Promise<SavedValueListResponse> {

src/components/charts/charts.types.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,9 @@ export interface ChartHeaderFilterProps {
401401
isGrid: boolean
402402
setIsGrid: (isGrid: boolean) => void
403403
}
404+
405+
export interface DeleteInstalledChartParamsType {
406+
forceDelete?: true
407+
partialDelete?: true
408+
cascade?: false
409+
}

0 commit comments

Comments
 (0)