feat: add back button

feat/knowledge-metabase
Joel 1 year ago
parent b74f1b3c07
commit 2adc704463

@ -83,7 +83,7 @@ const Container = () => {
return ( return (
<div ref={containerRef} className='grow relative flex flex-col bg-background-body overflow-y-auto scroll-container'> <div ref={containerRef} className='grow relative flex flex-col bg-background-body overflow-y-auto scroll-container'>
<CreateModal onSave={(data) => { console.log(data) }} /> <CreateModal hasBack onSave={(data) => { console.log(data) }} />
<div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-background-body z-10 flex-wrap gap-y-2'> <div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-background-body z-10 flex-wrap gap-y-2'>
<TabSliderNew <TabSliderNew
value={activeTab} value={activeTab}

@ -9,7 +9,9 @@ import { RiCloseLine } from '@remixicon/react'
type Props = { type Props = {
title: string title: string
className?: string className?: string
beforeHeader?: React.ReactNode
onClose: () => void onClose: () => void
hideCloseBtn?: boolean
onConfirm: () => void onConfirm: () => void
children: React.ReactNode children: React.ReactNode
} }
@ -17,22 +19,27 @@ type Props = {
const ModalLikeWrap: FC<Props> = ({ const ModalLikeWrap: FC<Props> = ({
title, title,
className, className,
beforeHeader,
children, children,
onClose, onClose,
hideCloseBtn,
onConfirm, onConfirm,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
return ( return (
<div className={cn('w-[320px] px-3 pt-3.5 pb-4 bg-components-panel-bg shadow-xl rounded-2xl border-[0.5px] border-components-panel-border', className)}> <div className={cn('w-[320px] px-3 pt-3.5 pb-4 bg-components-panel-bg shadow-xl rounded-2xl border-[0.5px] border-components-panel-border', className)}>
{beforeHeader || null}
<div className='mb-1 flex h-6 items-center justify-between'> <div className='mb-1 flex h-6 items-center justify-between'>
<div className='system-xl-semibold text-text-primary'>{title}</div> <div className='system-xl-semibold text-text-primary'>{title}</div>
{!hideCloseBtn && (
<div <div
className='p-1.5 text-text-tertiary cursor-pointer' className='p-1.5 text-text-tertiary cursor-pointer'
onClick={onClose} onClick={onClose}
> >
<RiCloseLine className='size-4' /> <RiCloseLine className='size-4' />
</div> </div>
)}
</div> </div>
<div className='mt-2'>{children}</div> <div className='mt-2'>{children}</div>
<div className='mt-4 flex justify-end'> <div className='mt-4 flex justify-end'>

@ -7,15 +7,20 @@ import { DataType } from './types'
import Field from './field' import Field from './field'
import OptionCard from '../../workflow/nodes/_base/components/option-card' import OptionCard from '../../workflow/nodes/_base/components/option-card'
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import { RiArrowLeftLine } from '@remixicon/react'
const i18nPrefix = 'dataset.metadata.createMetadata' const i18nPrefix = 'dataset.metadata.createMetadata'
type Props = { type Props = {
onSave: (data: any) => void onSave: (data: any) => void
hasBack?: boolean
onBack?: () => void
} }
const CreateModal: FC<Props> = ({ const CreateModal: FC<Props> = ({
onSave, onSave,
hasBack,
onBack,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [type, setType] = useState(DataType.string) const [type, setType] = useState(DataType.string)
@ -38,6 +43,13 @@ const CreateModal: FC<Props> = ({
title={t(`${i18nPrefix}.title`)} title={t(`${i18nPrefix}.title`)}
onClose={() => { }} onClose={() => { }}
onConfirm={handleSave} onConfirm={handleSave}
hideCloseBtn={hasBack}
beforeHeader={hasBack && (
<div className='relative left-[-4px] mb-1 flex items-center py-1 space-x-1 text-text-accent cursor-pointer' onClick={onBack}>
<RiArrowLeftLine className='size-4' />
<div className='system-xs-semibold-uppercase'>{t(`${i18nPrefix}.back`)}</div>
</div>
)}
> >
<div className='space-y-3'> <div className='space-y-3'>
<Field label={t(`${i18nPrefix}.type`)}> <Field label={t(`${i18nPrefix}.type`)}>

@ -171,6 +171,7 @@ const translation = {
metadata: { metadata: {
createMetadata: { createMetadata: {
title: 'New Metadata', title: 'New Metadata',
back: 'Back',
type: 'Type', type: 'Type',
name: 'Name', name: 'Name',
namePlaceholder: 'Add metadata name', namePlaceholder: 'Add metadata name',

@ -171,6 +171,7 @@ const translation = {
metadata: { metadata: {
createMetadata: { createMetadata: {
title: '新建元数据', title: '新建元数据',
back: '返回',
type: '类型', type: '类型',
name: '名称', name: '名称',
namePlaceholder: '添加元数据名称', namePlaceholder: '添加元数据名称',

Loading…
Cancel
Save