|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
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' |
18 | 18 | import { DELETE_ACTION, Routes } from '../../config'
|
19 | 19 | import { getAPIOptionsWithTriggerTimeout, handleUTCTime } from '../common'
|
20 |
| -import { ChartValuesType, ChartGroup, HelmTemplateChartRequest, HelmProjectUpdatePayload } from './charts.types' |
| 20 | +import { ChartValuesType, ChartGroup, HelmTemplateChartRequest, HelmProjectUpdatePayload, DeleteInstalledChartParamsType } from './charts.types' |
21 | 21 | import { SavedValueListResponse } from './SavedValues/types'
|
22 | 22 |
|
23 | 23 | interface RootObject {
|
@@ -57,19 +57,22 @@ export function deleteInstalledChart(
|
57 | 57 | isGitops?: boolean,
|
58 | 58 | deleteAction?: DELETE_ACTION,
|
59 | 59 | ) {
|
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 |
68 | 73 | }
|
69 |
| - } else if (!isGitops && deleteAction === DELETE_ACTION.FORCE_DELETE) { |
70 |
| - URL += `?force=true` |
71 | 74 | }
|
72 |
| - return trash(URL) |
| 75 | + return trash(url) |
73 | 76 | }
|
74 | 77 |
|
75 | 78 | export function getChartValuesTemplateList(chartId: number | string): Promise<SavedValueListResponse> {
|
|
0 commit comments