Skip to content

Commit 8f27b8f

Browse files
authored
Merge pull request #575 from devtron-labs/feat/app-template-v2
feat: application template v2
2 parents 61ebe81 + 8048b8c commit 8f27b8f

File tree

11 files changed

+48
-20
lines changed

11 files changed

+48
-20
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.6.0-patch-2-beta-2",
3+
"version": "1.6.0-patch-2-beta-3",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const URLS = {
8989
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_CREATE: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/create`,
9090
// NOTE: using appId since we are re-using AppConfig component
9191
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_DETAIL: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/detail/:appId`,
92-
}
92+
} as const
9393

9494
export const ROUTES = {
9595
APP: 'app',
@@ -148,7 +148,8 @@ export const ROUTES = {
148148
CD_TRIGGER_POST: 'app/cd-pipeline/trigger',
149149
DELETE_RESOURCE: 'k8s/resource/delete',
150150
NODE_CAPACITY: 'k8s/capacity/node',
151-
}
151+
RESOURCE_TEMPLATE: 'resource/template',
152+
} as const
152153

153154
export enum KEY_VALUE {
154155
KEY = 'key',

src/Pages/Applications/DevtronApps/Details/AppConfigurations/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export enum GetTemplateAPIRouteType {
7070
CD_DEPLOY_CONFIG = 'cd-deploy-config',
7171
CD_ENV_LIST = 'cd-env-list',
7272
CONFIG_DEPLOYMENT_TEMPLATE = 'config/deployment-template',
73+
CONFIG_DATA = 'config-data',
7374
CONFIG_CM = 'config/config-map',
7475
CONFIG_CS = 'config/secret',
7576
WORKFLOW_LIST = 'workflow/list',

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiff.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export const DeploymentHistoryConfigDiff = ({
9696

9797
const [secretsData, ...configDatas] = await Promise.allSettled([
9898
!isSuperAdmin ? getCompareSecretsData([...payloads]) : null,
99-
...payloads.map((payload) => payload && getAppEnvDeploymentConfig({ params: payload })),
99+
...payloads.map(
100+
(payload) =>
101+
payload && getAppEnvDeploymentConfig({ params: payload, appId: null, isTemplateView: false }),
102+
),
100103
])
101104

102105
if (secretsData.status !== 'fulfilled' || !secretsData.value) {

src/Shared/Components/WorkflowOptionsModal/WorkflowOptionsModal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const WorkflowOptionsModal = ({
4646
resetChangeCIPayload,
4747
linkedCDSourceVariant,
4848
isAppGroup = false,
49-
getTemplateAPIRoute,
5049
isTemplateView,
5150
}: Readonly<WorkflowOptionsModalProps>) => {
5251
const [currentCIPipelineType, setCurrentCIPipelineType] = useState<CIPipelineNodeType | WorkflowNodeType.WEBHOOK>(
@@ -115,7 +114,6 @@ const WorkflowOptionsModal = ({
115114
// Only need to disable it in case of error
116115
setLoadingWebhook(true)
117116
saveCDPipeline(getSwitchToWebhookPayload(changeCIPayload), {
118-
getTemplateAPIRoute,
119117
isTemplateView,
120118
})
121119
.then((response) => {

src/Shared/Components/WorkflowOptionsModal/types.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { AppConfigProps, GetTemplateAPIRouteProps } from '@Pages/index'
17+
import { AppConfigProps } from '@Pages/index'
1818
import { ChangeCIPayloadType, CIPipelineNodeType, WorkflowType } from '@Shared/types'
1919

2020
interface LinkedCDSourceVariant {
@@ -45,5 +45,4 @@ export interface WorkflowOptionsModalProps extends Required<Pick<AppConfigProps,
4545
getWorkflows?: () => void
4646
linkedCDSourceVariant?: LinkedCDSourceVariant
4747
isAppGroup?: boolean
48-
getTemplateAPIRoute: (props: GetTemplateAPIRouteProps) => string
4948
}

src/Shared/Services/app.service.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { AppConfigProps, GetTemplateAPIRouteType } from '@Pages/index'
1718
import { ROUTES, ResponseType, get, getUrlWithSearchParams, showError } from '../../Common'
1819
import {
1920
CIMaterialInfoDTO,
@@ -23,6 +24,7 @@ import {
2324
AppEnvDeploymentConfigPayloadType,
2425
} from './app.types'
2526
import { getParsedCIMaterialInfo } from './utils'
27+
import { getTemplateAPIRoute } from '..'
2628

2729
export const getCITriggerInfo = async (params: GetCITriggerInfoParamsType): Promise<CIMaterialInfoType> => {
2830
try {
@@ -58,11 +60,26 @@ export const getArtifactInfo = async (
5860
export const getAppEnvDeploymentConfig = ({
5961
params,
6062
signal,
63+
isTemplateView,
64+
appId,
6165
}: {
6266
params: AppEnvDeploymentConfigPayloadType
6367
signal?: AbortSignal
64-
}): Promise<ResponseType<AppEnvDeploymentConfigDTO>> =>
65-
get(getUrlWithSearchParams(ROUTES.CONFIG_DATA, params), { signal })
68+
isTemplateView: AppConfigProps['isTemplateView']
69+
appId: string | number | null
70+
}): Promise<ResponseType<AppEnvDeploymentConfigDTO>> => {
71+
const url = isTemplateView
72+
? getTemplateAPIRoute({
73+
type: GetTemplateAPIRouteType.CONFIG_DATA,
74+
queryParams: {
75+
id: appId,
76+
...params,
77+
},
78+
})
79+
: getUrlWithSearchParams(ROUTES.CONFIG_DATA, params)
80+
81+
return get(url, { signal })
82+
}
6683

6784
export const getCompareSecretsData = async (
6885
params: AppEnvDeploymentConfigPayloadType[],

src/Shared/Services/common.service.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,17 @@
1515
*/
1616

1717
import { AppConfigProps, GetTemplateAPIRouteType } from '@Pages/index'
18-
import { WorkflowOptionsModalProps } from '@Shared/Components/WorkflowOptionsModal/types'
1918
import { getUrlWithSearchParams, post, ROUTES } from '../../Common'
2019
import { GetPolicyApiUrlProps, GetResourceApiUrlProps } from './types'
20+
import { getTemplateAPIRoute } from '..'
2121

2222
export const getResourceApiUrl = <T>({ baseUrl, kind, version, suffix, queryParams }: GetResourceApiUrlProps<T>) =>
2323
getUrlWithSearchParams(`${baseUrl}/${kind}/${version}${suffix ? `/${suffix}` : ''}`, queryParams)
2424

2525
export const getPolicyApiUrl = <T>({ kind, version, queryParams, suffix }: GetPolicyApiUrlProps<T>) =>
2626
getUrlWithSearchParams(`global/policy/${kind}/${version}${suffix ? `/${suffix}` : ''}`, queryParams)
2727

28-
export const saveCDPipeline = (
29-
request,
30-
{
31-
getTemplateAPIRoute,
32-
isTemplateView,
33-
}: Pick<WorkflowOptionsModalProps, 'getTemplateAPIRoute'> & Required<Pick<AppConfigProps, 'isTemplateView'>>,
34-
) => {
28+
export const saveCDPipeline = (request, { isTemplateView }: Required<Pick<AppConfigProps, 'isTemplateView'>>) => {
3529
const url = isTemplateView
3630
? getTemplateAPIRoute({
3731
type: GetTemplateAPIRouteType.CD_PIPELINE,

src/Shared/Services/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export * from './app.service'
2020
export * from './common.service'
2121
export * from './ToastManager'
2222
export * from './utils'
23+
export * from './template.service'

0 commit comments

Comments
 (0)