Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix missing introduction and image in app template #4386

Merged
merged 3 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { request } from '../../../../utils';
import { AppDetailWrapper, LabelText, ImageWrapper, ImageItem } from './styles';

type Props = {
appDetail: AppDetail;
appDetail: AppDetail | null;
versionDetail: AppVersion[];
};

Expand All @@ -36,6 +36,7 @@ export function AppInfo({ appDetail, versionDetail }: Props): JSX.Element {
const [filterImages, setFilterImages] = useState<string[]>([]);

async function getList() {
if (!appDetail) return;
const { workspace } = appDetail;
// @ts-ignore
const list: string[] = await Promise.all(screenshots?.map(item => getImage(item, workspace)));
Expand Down
20 changes: 16 additions & 4 deletions packages/shared/src/components/Apps/AppInformation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,41 @@
* https://github.com/kubesphere/console/blob/master/LICENSE
*/

import React from 'react';
import React, { useEffect, useState } from 'react';
import { Card } from '@kubed/components';
import { useParams } from 'react-router-dom';

import { useCacheStore as useStore } from '../../../index';
import { AppInfo, LabelText } from './AppInfo';
import type { AppDetail } from '../../../types';
import { useAppVersionList } from '../../../stores/openpitrix';

import { isRadonDB } from '../../../utils';
import { openpitrixStore } from '../../../stores';

const { useAppVersionList, fetchAppDetail, fetchDMPDetail } = openpitrixStore;
export { AppInfo, LabelText };

export function AppInformation(): JSX.Element {
const { appName, workspace } = useParams();
const [selectedApp] = useStore<AppDetail>('selectedApp');
// const [selectedApp, setSelectedApp] = useStore<AppDetail>('selectedApp');
const [selectedAppState, setSelectedAppState] = useState<AppDetail | null>(null);

const { data: versions = [] } = useAppVersionList(
{ appName: appName, workspace },
{ status: 'active' },
{ autoFetch: !!appName },
);

useEffect(() => {
if (!appName) return;
(isRadonDB(appName) ? fetchDMPDetail : fetchAppDetail)({ appName, app_id: appName }).then(
setSelectedAppState,
);
}, [appName]);

return (
<Card sectionTitle={t('APP_INFORMATION')}>
<AppInfo appDetail={selectedApp} versionDetail={versions} />
<AppInfo appDetail={selectedAppState} versionDetail={versions} />
</Card>
);
}