0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): optimize loading screens in app guides (#4441)

This commit is contained in:
Charles Zhao 2023-09-06 23:42:11 +08:00 committed by GitHub
parent edfb0e9950
commit 6565dad0e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 39 deletions

View file

@ -52,7 +52,7 @@ const mapToUriOriginFormatArrays = (value?: string[]) =>
function ApplicationDetails() {
const { id, guideId, tab } = useParams();
const { navigate, match } = useTenantPathname();
const isGuideView = id && guideId && match(`/applications/${id}/guide/${guideId}`);
const isGuideView = !!id && !!guideId && match(`/applications/${id}/guide/${guideId}`);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { data, error, mutate } = useSWR<ApplicationResponse, RequestError>(
@ -145,6 +145,18 @@ function ApplicationDetails() {
setIsReadmeOpen(false);
};
if (isGuideView) {
return (
<GuideModal
guideId={guideId}
app={data}
onClose={(id) => {
navigate(`/applications/${id}`);
}}
/>
);
}
return (
<DetailsPage
backLink="/applications"
@ -242,15 +254,6 @@ function ApplicationDetails() {
</>
)}
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && isDirty} />
{isGuideView && (
<GuideModal
guideId={guideId}
app={data}
onClose={(id) => {
navigate(`/applications/${id}`);
}}
/>
)}
</DetailsPage>
);
}

View file

@ -51,7 +51,7 @@ export const GuideContext = createContext<GuideContextType>({
type Props = {
className?: string;
guideId: string;
app: ApplicationResponse;
app?: ApplicationResponse;
isCompact?: boolean;
onClose: () => void;
};
@ -67,7 +67,8 @@ function Guide({ className, guideId, app, isCompact, onClose }: Props) {
const memorizedContext = useMemo(
() =>
conditional(
!!guide && {
!!guide &&
!!app && {
metadata: guide.metadata,
Logo: guide.Logo,
app,
@ -88,7 +89,9 @@ function Guide({ className, guideId, app, isCompact, onClose }: Props) {
return (
<>
<OverlayScrollbar className={classNames(styles.content, className)}>
{memorizedContext ? (
{!app && <StepsSkeleton />}
{!!app && !guide && <NotFound className={styles.notFound} />}
{memorizedContext && (
<GuideContext.Provider value={memorizedContext}>
<MDXProvider
components={{
@ -121,8 +124,6 @@ function Guide({ className, guideId, app, isCompact, onClose }: Props) {
</Suspense>
</MDXProvider>
</GuideContext.Provider>
) : (
<NotFound className={styles.notFound} />
)}
</OverlayScrollbar>
{memorizedContext && (

View file

@ -15,21 +15,14 @@ type Props = {
};
function GuideModal({ guideId, app, onClose }: Props) {
if (!app) {
return null;
}
const closeModal = () => {
if (app) {
onClose(app.id);
}
};
return (
<Modal
shouldCloseOnEsc
isOpen={Boolean(app)}
className={modalStyles.fullScreen}
onRequestClose={closeModal}
>
<Modal shouldCloseOnEsc isOpen className={modalStyles.fullScreen} onRequestClose={closeModal}>
<div className={styles.modalContainer}>
<GuideHeader onClose={closeModal} />
<Guide className={styles.guide} guideId={guideId} app={app} onClose={closeModal} />

View file

@ -1,4 +1,5 @@
@use '@/scss/underscore' as _;
@use '@/scss/dimensions' as dim;
.step {
display: flex;
@ -6,6 +7,8 @@
padding: _.unit(5) _.unit(6);
border-radius: 16px;
background-color: var(--color-layer-1);
max-width: dim.$guide-main-content-max-width;
margin: 0 auto;
.index {
@include _.shimmering-animation;