From 7f9085f36130b6e3971371f5cd44eaf960e1ed6d Mon Sep 17 00:00:00 2001
From: jingyang <72259332+zjy365@users.noreply.github.com>
Date: Fri, 10 Jan 2025 16:09:49 +0800
Subject: [PATCH] feat: support multiple volumes (#5337)
* reverse db version
* feat: support multiple volumes
* add volumeMounts
* update form
* update
* update style
---
.../public/locales/en/common.json | 5 +-
.../public/locales/zh/common.json | 5 +-
.../applaunchpad/src/constants/editApp.ts | 3 ++
.../providers/applaunchpad/src/mock/apps.ts | 3 ++
.../app/detail/components/AppBaseInfo.tsx | 47 ++++++++++++++++-
.../app/edit/components/ConfigmapModal.tsx | 1 +
.../pages/app/edit/components/EditEnvs.tsx | 2 +-
.../src/pages/app/edit/components/Form.tsx | 50 +++++++++++++++++++
.../applaunchpad/src/pages/app/edit/index.tsx | 4 +-
.../providers/applaunchpad/src/types/app.d.ts | 7 ++-
.../providers/applaunchpad/src/utils/adapt.ts | 22 +++++++-
.../applaunchpad/src/utils/deployYaml2Json.ts | 7 +--
.../src/pages/api/platform/getVersion.ts | 2 +-
.../providers/dbprovider/src/store/static.ts | 5 +-
frontend/providers/template/src/api/delete.ts | 3 +-
.../src/pages/api/app/listOtherByName.ts | 38 ++++++++++++--
.../providers/template/src/types/resource.ts | 3 +-
17 files changed, 186 insertions(+), 21 deletions(-)
diff --git a/frontend/providers/applaunchpad/public/locales/en/common.json b/frontend/providers/applaunchpad/public/locales/en/common.json
index 0b7147775e8..0062715f00c 100644
--- a/frontend/providers/applaunchpad/public/locales/en/common.json
+++ b/frontend/providers/applaunchpad/public/locales/en/common.json
@@ -276,5 +276,6 @@
"add_configmap": "Add Configmaps",
"storage_path_placeholder": "For Example: /data"
},
- "guide_deploy_button": "Complete creation"
-}
\ No newline at end of file
+ "guide_deploy_button": "Complete creation",
+ "shared": "Shared"
+}
diff --git a/frontend/providers/applaunchpad/public/locales/zh/common.json b/frontend/providers/applaunchpad/public/locales/zh/common.json
index da5b88f3929..95df44ea1ac 100644
--- a/frontend/providers/applaunchpad/public/locales/zh/common.json
+++ b/frontend/providers/applaunchpad/public/locales/zh/common.json
@@ -277,5 +277,6 @@
"add_configmap": "新增配置文件",
"storage_path_placeholder": "如:/data"
},
- "guide_deploy_button": "完成创建"
-}
\ No newline at end of file
+ "guide_deploy_button": "完成创建",
+ "shared": "共享"
+}
diff --git a/frontend/providers/applaunchpad/src/constants/editApp.ts b/frontend/providers/applaunchpad/src/constants/editApp.ts
index 9b19828fbfc..6cf0e2a1915 100644
--- a/frontend/providers/applaunchpad/src/constants/editApp.ts
+++ b/frontend/providers/applaunchpad/src/constants/editApp.ts
@@ -23,6 +23,7 @@ export const editModeMap = (isEdit: boolean) => {
};
export const defaultEditVal: AppEditType = {
+ kind: 'deployment',
appName: 'hello-world',
imageName: 'nginx',
runCMD: '',
@@ -58,6 +59,8 @@ export const defaultEditVal: AppEditType = {
serverAddress: 'docker.io'
},
storeList: [],
+ volumes: [],
+ volumeMounts: [],
gpu: {
manufacturers: 'nvidia',
type: '',
diff --git a/frontend/providers/applaunchpad/src/mock/apps.ts b/frontend/providers/applaunchpad/src/mock/apps.ts
index f6809b3a744..af76efe453a 100644
--- a/frontend/providers/applaunchpad/src/mock/apps.ts
+++ b/frontend/providers/applaunchpad/src/mock/apps.ts
@@ -238,6 +238,9 @@ export const MOCK_PODS: PodDetailType[] = [
];
export const MOCK_APP_DETAIL: AppDetailType = {
+ kind: 'deployment',
+ volumes: [],
+ volumeMounts: [],
crYamlList: [],
id: '4bd50c41-149e-4da5-89d5-0308b9dd75c6',
createTime: '2022/1/22',
diff --git a/frontend/providers/applaunchpad/src/pages/app/detail/components/AppBaseInfo.tsx b/frontend/providers/applaunchpad/src/pages/app/detail/components/AppBaseInfo.tsx
index 5c6ec64d031..4448388b6ac 100644
--- a/frontend/providers/applaunchpad/src/pages/app/detail/components/AppBaseInfo.tsx
+++ b/frontend/providers/applaunchpad/src/pages/app/detail/components/AppBaseInfo.tsx
@@ -100,6 +100,30 @@ const AppBaseInfo = ({ app = MOCK_APP_DETAIL }: { app: AppDetailType }) => {
[app]
);
+ const persistentVolumes = useMemo(() => {
+ return app.volumes
+ .filter((item) => 'persistentVolumeClaim' in item)
+ .reduce(
+ (
+ acc: {
+ path: string;
+ name: string;
+ }[],
+ volume
+ ) => {
+ const mount = app.volumeMounts.find((m) => m.name === volume.name);
+ if (mount) {
+ acc.push({
+ path: mount.mountPath,
+ name: volume.name
+ });
+ }
+ return acc;
+ },
+ []
+ );
+ }, [app.volumes, app.volumeMounts]);
+
return (
{app?.source?.hasSource && (
@@ -383,7 +407,7 @@ const AppBaseInfo = ({ app = MOCK_APP_DETAIL }: { app: AppDetailType }) => {
borderRadius={'md'}
overflow={'hidden'}
bg={'#FFF'}
- {...(app.storeList.length > 0
+ {...(app.storeList.length > 0 || persistentVolumes.length > 0
? {
mb: 4,
border: theme.borders.base
@@ -415,6 +439,27 @@ const AppBaseInfo = ({ app = MOCK_APP_DETAIL }: { app: AppDetailType }) => {
))}
+ {persistentVolumes.map((item) => (
+
+
+
+
+ {item.path}
+
+
+
+ {t('shared')}
+
+
+ ))}
diff --git a/frontend/providers/applaunchpad/src/pages/app/edit/components/ConfigmapModal.tsx b/frontend/providers/applaunchpad/src/pages/app/edit/components/ConfigmapModal.tsx
index c5ede83d5bf..62a68556299 100644
--- a/frontend/providers/applaunchpad/src/pages/app/edit/components/ConfigmapModal.tsx
+++ b/frontend/providers/applaunchpad/src/pages/app/edit/components/ConfigmapModal.tsx
@@ -94,6 +94,7 @@ const ConfigmapModal = ({
{t('file value')}{' '}