瀏覽代碼

refactor(context-menu): conditionally render export option based on pipeline ID

tags/2.0.0-beta.1
twwu 1 月之前
父節點
當前提交
55b936003f

+ 5
- 2
web/app/components/workflow/panel/version-history-panel/context-menu/use-context-menu.ts 查看文件

import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { VersionHistoryContextMenuOptions } from '../../../types' import { VersionHistoryContextMenuOptions } from '../../../types'
import type { ContextMenuProps } from './index' import type { ContextMenuProps } from './index'
import { useStore } from '@/app/components/workflow/store'


const useContextMenu = (props: ContextMenuProps) => { const useContextMenu = (props: ContextMenuProps) => {
const { const {
isNamedVersion, isNamedVersion,
} = props } = props
const { t } = useTranslation() const { t } = useTranslation()
const pipelineId = useStore(s => s.pipelineId)


const deleteOperation = { const deleteOperation = {
key: VersionHistoryContextMenuOptions.delete, key: VersionHistoryContextMenuOptions.delete,
key: VersionHistoryContextMenuOptions.edit, key: VersionHistoryContextMenuOptions.edit,
name: t('workflow.versionHistory.nameThisVersion'), name: t('workflow.versionHistory.nameThisVersion'),
}, },
{
// todo: pipeline support export specific version DSL
...(!pipelineId ? [{
key: VersionHistoryContextMenuOptions.exportDSL, key: VersionHistoryContextMenuOptions.exportDSL,
name: t('app.export'), name: t('app.export'),
},
}] : []),
{ {
key: VersionHistoryContextMenuOptions.copyId, key: VersionHistoryContextMenuOptions.copyId,
name: t('workflow.versionHistory.copyId'), name: t('workflow.versionHistory.copyId'),

Loading…
取消
儲存