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

update(console): remove accordin panel #1904

Merged
merged 1 commit into from
Mar 1, 2023
Merged
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
141 changes: 33 additions & 108 deletions console/src/pages/Runtime/RuntimeOverviewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { useHistory, useParams, useLocation } from 'react-router-dom'
import { INavItem } from '@/components/BaseSidebar'
import { fetchRuntime, removeRuntime } from '@/domain/runtime/services/runtime'
import BaseSubLayout from '@/pages/BaseSubLayout'
import { formatTimestampDateTime } from '@/utils/datetime'
import Accordion from '@starwhale/ui/Accordion'
import { Panel } from 'baseui/accordion'
import { BaseNavTabs } from '@/components/BaseNavTabs'
import RuntimeVersionSelector from '@/domain/runtime/components/RuntimeVersionSelector'
import qs from 'qs'
Expand Down Expand Up @@ -77,60 +74,6 @@ export default function RuntimeOverviewLayout({ children }: IRuntimeLayoutProps)
return items
}, [projectId, runtimeId, t, runtime])

const header = React.useMemo(() => {
const items = [
{
label: t('Runtime Name'),
value: runtime?.name ?? '',
},
{
label: t('Version Name'),
value: runtime?.versionName ?? '',
},
{
label: t('Version Tag'),
value: runtime?.versionTag ?? '',
},
{
label: t('Created'),
value: runtime?.createdTime && formatTimestampDateTime(runtime.createdTime),
},
]

const info = (
<div
style={{
fontSize: '14px',
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(420px, 1fr))',
gap: '12px',
}}
>
{items.map((v) => (
<div key={v?.label} style={{ display: 'flex', gap: '12px' }}>
<div
style={{
lineHeight: '24px',
borderRadius: '4px',
color: 'rgba(2,16,43,0.60)',
}}
>
{v?.label}:
</div>
<div> {v?.value}</div>
</div>
))}
</div>
)
return (
<div className='mb-20'>
<Accordion accordion>
<Panel title={`${t('Runtime ID')}: ${runtime?.id ?? ''}`}>{info}</Panel>
</Accordion>
</div>
)
}, [runtime, t])

const navItems: INavItem[] = useMemo(() => {
const items = [
{
Expand Down Expand Up @@ -179,58 +122,40 @@ export default function RuntimeOverviewLayout({ children }: IRuntimeLayoutProps)
}, [projectId, runtimeId, history, t])

return (
<BaseSubLayout breadcrumbItems={breadcrumbItems} header={header} extra={extra}>
<Accordion
accordion
overrides={{
ToggleIcon: () => <></>,
ContentAnimationContainer: {
style: {
flex: 1,
display: 'flex',
flexDirection: 'column',
},
},
}}
>
<Panel title={t('Version and Files')} expanded>
<div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
{runtimeVersionId && (
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '10px' }}>
<div style={{ width: '280px' }}>
<RuntimeVersionSelector
projectId={projectId}
runtimeId={runtimeId}
value={runtimeVersionId}
onChange={(v: string) =>
history.push(
`/projects/${projectId}/runtimes/${runtimeId}/versions/${v}/${activeItemId}?${qs.stringify(
page
)}`
)
}
/>
</div>
<Button
icon='runtime'
kind='secondary'
onClick={() =>
history.push(`/projects/${projectId}/runtimes/${runtimeId}/versions`)
}
>
{t('History')}
</Button>
</div>
)}
{runtimeVersionId && (
<div style={{ marginBottom: '10px' }}>
<BaseNavTabs navItems={navItems} />{' '}
</div>
)}
<div style={{ flex: '1', display: 'flex', flexDirection: 'column' }}>{children}</div>
<BaseSubLayout breadcrumbItems={breadcrumbItems} extra={extra}>
<div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
{runtimeVersionId && (
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '20px' }}>
<div style={{ width: '280px' }}>
<RuntimeVersionSelector
projectId={projectId}
runtimeId={runtimeId}
value={runtimeVersionId}
onChange={(v: string) =>
history.push(
`/projects/${projectId}/runtimes/${runtimeId}/versions/${v}/${activeItemId}?${qs.stringify(
page
)}`
)
}
/>
</div>
<Button
icon='runtime'
kind='secondary'
onClick={() => history.push(`/projects/${projectId}/runtimes/${runtimeId}/versions`)}
>
{t('History')}
</Button>
</div>
)}
{runtimeVersionId && (
<div style={{ marginBottom: '10px' }}>
<BaseNavTabs navItems={navItems} />{' '}
</div>
</Panel>
</Accordion>
)}
<div style={{ flex: '1', display: 'flex', flexDirection: 'column' }}>{children}</div>
</div>
</BaseSubLayout>
)
}