0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

refactor(console): show connector readme content in drawer

This commit is contained in:
Charles Zhao 2022-06-22 17:42:09 +08:00
parent 060ff2125f
commit 2c66397c35
No known key found for this signature in database
GPG key ID: 4858774754C92DF2
8 changed files with 47 additions and 28 deletions

View file

@ -9,19 +9,25 @@
max-width: 900px; max-width: 900px;
min-width: 770px; min-width: 770px;
outline: none; outline: none;
background: var(--color-layer-1); background: var(--color-base);
overflow-y: auto;
.headline { .wrapper {
display: flex; display: flex;
justify-content: right; flex-direction: column;
height: 100%;
> svg { .header {
cursor: pointer; display: flex;
align-items: center;
flex-shrink: 0;
background-color: var(--color-layer-1);
height: 64px;
padding: 0 _.unit(6);
} }
.closeIcon { .body {
color: var(--color-icon); flex: 1;
overflow-y: auto;
} }
} }
} }

View file

@ -1,18 +1,23 @@
import { AdminConsoleKey } from '@logto/phrases';
import React from 'react'; import React from 'react';
import ReactModal from 'react-modal'; import ReactModal from 'react-modal';
import Close from '@/icons/Close'; import Close from '@/icons/Close';
import CardTitle from '../CardTitle';
import IconButton from '../IconButton'; import IconButton from '../IconButton';
import Spacer from '../Spacer';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
type Props = { type Props = {
title?: AdminConsoleKey;
subtitle?: AdminConsoleKey;
isOpen: boolean; isOpen: boolean;
onClose?: () => void;
children: React.ReactNode; children: React.ReactNode;
onClose?: () => void;
}; };
const Drawer = ({ isOpen, onClose, children }: Props) => { const Drawer = ({ title, subtitle, isOpen, children, onClose }: Props) => {
return ( return (
<ReactModal <ReactModal
shouldCloseOnOverlayClick shouldCloseOnOverlayClick
@ -23,14 +28,18 @@ const Drawer = ({ isOpen, onClose, children }: Props) => {
closeTimeoutMS={300} closeTimeoutMS={300}
onRequestClose={onClose} onRequestClose={onClose}
> >
{onClose && ( <div className={styles.wrapper}>
<div className={styles.headline}> {title && (
<IconButton size="large" onClick={onClose}> <div className={styles.header}>
<Close className={styles.closeIcon} /> <CardTitle size="small" title={title} subtitle={subtitle} />
</IconButton> <Spacer />
</div> <IconButton size="large" onClick={onClose}>
)} <Close />
<div>{children}</div> </IconButton>
</div>
)}
<div className={styles.body}>{children}</div>
</div>
</ReactModal> </ReactModal>
); );
}; };

View file

@ -97,6 +97,10 @@ const ApplicationDetails = () => {
toast.success(t('application_details.save_success')); toast.success(t('application_details.save_success'));
}); });
const onCloseDrawer = () => {
setIsReadmeOpen(false);
};
const isAdvancedSettings = location.pathname.includes('advanced-settings'); const isAdvancedSettings = location.pathname.includes('advanced-settings');
return ( return (
@ -129,14 +133,8 @@ const ApplicationDetails = () => {
setIsReadmeOpen(true); setIsReadmeOpen(true);
}} }}
/> />
<Drawer isOpen={isReadmeOpen}> <Drawer isOpen={isReadmeOpen} onClose={onCloseDrawer}>
<Guide <Guide isCompact app={data} onClose={onCloseDrawer} />
isCompact
app={data}
onClose={() => {
setIsReadmeOpen(false);
}}
/>
</Drawer> </Drawer>
<ActionMenu <ActionMenu
buttonProps={{ icon: <More className={styles.moreIcon} />, size: 'large' }} buttonProps={{ icon: <More className={styles.moreIcon} />, size: 'large' }}

View file

@ -95,5 +95,5 @@
} }
.readme { .readme {
margin-top: _.unit(-6); padding: 0 _.unit(6);
} }

View file

@ -152,6 +152,8 @@ const ConnectorDetails = () => {
}} }}
/> />
<Drawer <Drawer
title="connectors.title"
subtitle="connectors.subtitle"
isOpen={isReadMeOpen} isOpen={isReadMeOpen}
onClose={() => { onClose={() => {
setIsReadMeOpen(false); setIsReadMeOpen(false);

View file

@ -32,7 +32,7 @@ const ConnectorRow = ({ type, connectors, onClickSetup }: Props) => {
}; };
return ( return (
<tr className={conditional(showSetupButton && tableStyles.clickable)} onClick={handleClickRow}> <tr className={conditional(!showSetupButton && tableStyles.clickable)} onClick={handleClickRow}>
<td> <td>
<ConnectorName type={type} connectors={connectors} onClickSetup={onClickSetup} /> <ConnectorName type={type} connectors={connectors} onClickSetup={onClickSetup} />
</td> </td>

View file

@ -274,6 +274,8 @@ const translation = {
native: 'Native', native: 'Native',
}, },
add_multi_platform: ' supports multiple platform, select a platform to continue', add_multi_platform: ' supports multiple platform, select a platform to continue',
drawer_title: 'Connector Guide',
drawer_subtitle: 'Follow the instructions to integrate your connector',
}, },
connector_details: { connector_details: {
back_to_connectors: 'Back to Connectors', back_to_connectors: 'Back to Connectors',

View file

@ -269,6 +269,8 @@ const translation = {
native: '原生', native: '原生',
}, },
add_multi_platform: ' 支持多平台,请选择一个平台继续', add_multi_platform: ' 支持多平台,请选择一个平台继续',
drawer_title: '连接器配置指南',
drawer_subtitle: '请参考下列连接器配置指南',
}, },
connector_details: { connector_details: {
back_to_connectors: '返回连接器', back_to_connectors: '返回连接器',