-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration # Snapshots: Include snapshots for easier review. # Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have already rebased the commits and make the commit message conform to the project standard. - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] Any dependent changes have been merged and published in downstream modules
- Loading branch information
Showing
8 changed files
with
145 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { getFlowTemplates } from '@/client/api'; | ||
import CanvasWrapper from '@/pages/construct/flow/canvas/index'; | ||
import type { TableProps } from 'antd'; | ||
import { Button, Modal, Space, Table } from 'antd'; | ||
import { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type Props = { | ||
isFlowTemplateModalOpen: boolean; | ||
setIsFlowTemplateModalOpen: (value: boolean) => void; | ||
}; | ||
|
||
interface DataType { | ||
key: string; | ||
name: string; | ||
age: number; | ||
address: string; | ||
tags: string[]; | ||
} | ||
|
||
export const FlowTemplateModal: React.FC<Props> = ({ isFlowTemplateModalOpen, setIsFlowTemplateModalOpen }) => { | ||
const { t } = useTranslation(); | ||
const [dataSource, setDataSource] = useState([]); | ||
|
||
const onTemplateImport = (record: DataType) => { | ||
if (record?.name) { | ||
localStorage.setItem('importFlowData', JSON.stringify(record)); | ||
CanvasWrapper(); | ||
setIsFlowTemplateModalOpen(false); | ||
} | ||
}; | ||
|
||
const columns: TableProps<DataType>['columns'] = [ | ||
{ | ||
title: t('Template_Name'), | ||
dataIndex: 'name', | ||
key: 'name', | ||
}, | ||
{ | ||
title: t('Template_Action'), | ||
key: 'action', | ||
render: (_, record) => ( | ||
<Space size='middle'> | ||
<Button | ||
type='link' | ||
onClick={() => { | ||
onTemplateImport(record); | ||
}} | ||
block | ||
> | ||
{t('Import_From_Template')} | ||
</Button> | ||
</Space> | ||
), | ||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
getFlowTemplates().then(res => { | ||
console.log(res); | ||
setDataSource(res?.data?.data?.items); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Modal | ||
title={t('Import_From_Template')} | ||
open={isFlowTemplateModalOpen} | ||
onCancel={() => setIsFlowTemplateModalOpen(false)} | ||
cancelButtonProps={{ className: 'hidden' }} | ||
okButtonProps={{ className: 'hidden' }} | ||
> | ||
<Table dataSource={dataSource} columns={columns} />; | ||
</Modal> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters