feat: enhance workflow header with version display and publish status
This commit is contained in:
parent
be3b911daa
commit
4c5ab8ca32
@ -52,7 +52,6 @@ const Header: FC = () => {
|
|||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
const appDetail = useAppStore(s => s.appDetail)
|
||||||
const setAppDetail = useAppStore(s => s.setAppDetail)
|
const setAppDetail = useAppStore(s => s.setAppDetail)
|
||||||
const appSidebarExpand = useAppStore(s => s.appSidebarExpand)
|
|
||||||
const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures)
|
const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures)
|
||||||
const appID = appDetail?.id
|
const appID = appDetail?.id
|
||||||
const isChatMode = useIsChatMode()
|
const isChatMode = useIsChatMode()
|
||||||
@ -210,11 +209,6 @@ const Header: FC = () => {
|
|||||||
className='absolute top-0 left-0 z-10 flex items-center justify-between w-full px-3 h-14 bg-mask-top2bottom-gray-50-to-transparent'
|
className='absolute top-0 left-0 z-10 flex items-center justify-between w-full px-3 h-14 bg-mask-top2bottom-gray-50-to-transparent'
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{
|
|
||||||
appSidebarExpand === 'collapse' && (
|
|
||||||
<div className='system-xs-regular text-text-tertiary'>{appDetail?.name}</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
normal && <EditingTitle />
|
normal && <EditingTitle />
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,47 @@
|
|||||||
import { memo } from 'react'
|
import { memo, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useWorkflow } from '../hooks'
|
import { useWorkflow } from '../hooks'
|
||||||
import { useStore } from '../store'
|
import { useStore } from '../store'
|
||||||
import { ClockRefresh } from '@/app/components/base/icons/src/vender/line/time'
|
import { WorkflowVersion } from '../types'
|
||||||
|
import useTimestamp from '@/hooks/use-timestamp'
|
||||||
|
|
||||||
const RestoringTitle = () => {
|
const RestoringTitle = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { formatTimeFromNow } = useWorkflow()
|
const { formatTimeFromNow } = useWorkflow()
|
||||||
const publishedAt = useStore(state => state.publishedAt)
|
const { formatTime } = useTimestamp()
|
||||||
|
const currentVersion = useStore(state => state.currentVersion)
|
||||||
|
const isDraft = currentVersion?.version === WorkflowVersion.Draft
|
||||||
|
const publishStatus = isDraft ? t('workflow.common.unpublished') : t('workflow.common.published')
|
||||||
|
|
||||||
|
const versionName = useMemo(() => {
|
||||||
|
if (isDraft)
|
||||||
|
return t('workflow.versionHistory.currentDraft')
|
||||||
|
return currentVersion?.marked_name || t('workflow.versionHistory.defaultName')
|
||||||
|
}, [currentVersion, t, isDraft])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex items-center h-[18px] text-xs text-gray-500'>
|
<div className='flex flex-col gap-y-0.5'>
|
||||||
<ClockRefresh className='mr-1 w-3 h-3 text-gray-500' />
|
<div className='flex items-center gap-x-1'>
|
||||||
{t('workflow.common.latestPublished')}<span> </span>
|
<span className='text-text-primary system-sm-semibold'>
|
||||||
{formatTimeFromNow(publishedAt)}
|
{versionName}
|
||||||
|
</span>
|
||||||
|
<span className='px-1 py-0.5 rounded-[5px] border border-text-accent-secondary bg-components-badge-bg-dimm text-text-accent-secondary system-2xs-medium-uppercase'>
|
||||||
|
{t('workflow.common.viewOnly')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center gap-x-1 h-4 text-text-tertiary system-xs-regular'>
|
||||||
|
{
|
||||||
|
currentVersion && (
|
||||||
|
<>
|
||||||
|
<span>{publishStatus}</span>
|
||||||
|
<span>·</span>
|
||||||
|
<span>{`${formatTimeFromNow(currentVersion.created_at * 1000)} ${formatTime(currentVersion.created_at, 'HH:mm:ss')}`}</span>
|
||||||
|
<span>·</span>
|
||||||
|
<span>{currentVersion?.created_by?.name || ''}</span>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,11 @@ export type FetchWorkflowDraftResponse = {
|
|||||||
}
|
}
|
||||||
hash: string
|
hash: string
|
||||||
updated_at: number
|
updated_at: number
|
||||||
|
updated_by: {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
email: string
|
||||||
|
},
|
||||||
tool_published: boolean
|
tool_published: boolean
|
||||||
environment_variables?: EnvironmentVariable[]
|
environment_variables?: EnvironmentVariable[]
|
||||||
conversation_variables?: ConversationVariable[]
|
conversation_variables?: ConversationVariable[]
|
||||||
|
Loading…
Reference in New Issue
Block a user