1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(app): migrate app parent view to react [EE-5361] (#10086)

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2023-08-27 23:01:35 +02:00 committed by GitHub
parent 531f88b947
commit 841ca1ebd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1448 additions and 810 deletions

View file

@ -83,11 +83,14 @@ async function getApplicationsForNamespace(
}
// if not known, get the type of an application (Deployment, DaemonSet, StatefulSet or naked pod) by name
export async function getApplication(
export async function getApplication<
T extends Application | string = Application
>(
environmentId: EnvironmentId,
namespace: string,
name: string,
appKind?: AppKind
appKind?: AppKind,
yaml?: boolean
) {
try {
// if resourceType is known, get the application by type and name
@ -96,14 +99,15 @@ export async function getApplication(
case 'Deployment':
case 'DaemonSet':
case 'StatefulSet':
return await getApplicationByKind(
return await getApplicationByKind<T>(
environmentId,
namespace,
appKind,
name
name,
yaml
);
case 'Pod':
return await getPod(environmentId, namespace, name);
return await getPod(environmentId, namespace, name, yaml);
default:
throw new Error('Unknown resource type');
}
@ -115,21 +119,24 @@ export async function getApplication(
environmentId,
namespace,
'Deployment',
name
name,
yaml
),
getApplicationByKind<DaemonSet>(
environmentId,
namespace,
'DaemonSet',
name
name,
yaml
),
getApplicationByKind<StatefulSet>(
environmentId,
namespace,
'StatefulSet',
name
name,
yaml
),
getPod(environmentId, namespace, name),
getPod(environmentId, namespace, name, yaml),
]);
if (isFulfilled(deployment)) {
@ -225,15 +232,21 @@ async function patchApplicationByKind<T extends Application>(
}
}
async function getApplicationByKind<T extends Application>(
async function getApplicationByKind<
T extends Application | string = Application
>(
environmentId: EnvironmentId,
namespace: string,
appKind: 'Deployment' | 'DaemonSet' | 'StatefulSet',
name: string
name: string,
yaml?: boolean
) {
try {
const { data } = await axios.get<T>(
buildUrl(environmentId, namespace, `${appKind}s`, name)
buildUrl(environmentId, namespace, `${appKind}s`, name),
{
headers: { Accept: yaml ? 'application/yaml' : 'application/json' },
}
);
return data;
} catch (e) {