You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by so...@apache.org on 2022/04/21 07:28:54 UTC
[dolphinscheduler] branch dev updated: [Fix][UI][V1.0.0-Beta]Fix data not update bug for workflow version switch (#9642)
This is an automated email from the ASF dual-hosted git repository.
songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 303ee1bf15 [Fix][UI][V1.0.0-Beta]Fix data not update bug for workflow version switch (#9642)
303ee1bf15 is described below
commit 303ee1bf15189f641f77c8eb55a6ccd9fc851d25
Author: Devosend <de...@gmail.com>
AuthorDate: Thu Apr 21 15:28:48 2022 +0800
[Fix][UI][V1.0.0-Beta]Fix data not update bug for workflow version switch (#9642)
---
.../workflow/definition/components/use-table.ts | 230 +++++++++++----------
.../definition/components/version-modal.tsx | 11 +-
2 files changed, 127 insertions(+), 114 deletions(-)
diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts b/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts
index c56854dcf8..29b9de0213 100644
--- a/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts
@@ -35,118 +35,8 @@ export function useTable(
const { t } = useI18n()
const router: Router = useRouter()
- const columns: TableColumns<any> = [
- {
- title: '#',
- key: 'id',
- width: 50,
- render: (_row, index) => index + 1
- },
- {
- title: t('project.workflow.version'),
- key: 'version',
- render: (_row) => {
- if (_row.version === variables.row.version) {
- return h(
- NTag,
- { type: 'success', size: 'small' },
- {
- default: () =>
- `V${_row.version} ${t('project.workflow.current_version')}`
- }
- )
- } else {
- return `V${_row.version}`
- }
- }
- },
- {
- title: t('project.workflow.description'),
- key: 'description'
- },
- {
- title: t('project.workflow.create_time'),
- key: 'operateTime'
- },
- {
- title: t('project.workflow.operation'),
- key: 'operation',
- className: styles.operation,
- render: (_row) => {
- return h(NSpace, null, {
- default: () => [
- h(
- NPopconfirm,
- {
- onPositiveClick: () => {
- handleSwitchVersion(_row.version)
- }
- },
- {
- trigger: () =>
- h(
- NTooltip,
- {},
- {
- trigger: () =>
- h(
- NButton,
- {
- circle: true,
- type: 'info',
- size: 'tiny',
- disabled: _row.version === variables.row.version
- },
- {
- icon: () => h(ExclamationCircleOutlined)
- }
- ),
- default: () => t('project.workflow.switch_version')
- }
- ),
- default: () => t('project.workflow.confirm_switch_version')
- }
- ),
- h(
- NPopconfirm,
- {
- onPositiveClick: () => {
- handleDeleteVersion(_row.version)
- }
- },
- {
- trigger: () =>
- h(
- NTooltip,
- {},
- {
- trigger: () =>
- h(
- NButton,
- {
- circle: true,
- type: 'error',
- size: 'tiny',
- disabled: _row.version === variables.row.version
- },
- {
- icon: () => h(DeleteOutlined)
- }
- ),
- default: () => t('project.workflow.delete')
- }
- ),
- default: () => t('project.workflow.delete_confirm')
- }
- )
- ]
- })
- }
- }
- ]
-
const variables = reactive({
- columns,
+ columns: [],
row: {} as any,
tableData: [],
page: ref(1),
@@ -156,6 +46,118 @@ export function useTable(
loadingRef: ref(false)
})
+ const createColumns = (variables: any) => {
+ variables.columns = [
+ {
+ title: '#',
+ key: 'id',
+ width: 50,
+ render: (_row, index) => index + 1
+ },
+ {
+ title: t('project.workflow.version'),
+ key: 'version',
+ render: (_row) => {
+ if (_row.version === variables.row.version) {
+ return h(
+ NTag,
+ { type: 'success', size: 'small' },
+ {
+ default: () =>
+ `V${_row.version} ${t('project.workflow.current_version')}`
+ }
+ )
+ } else {
+ return `V${_row.version}`
+ }
+ }
+ },
+ {
+ title: t('project.workflow.description'),
+ key: 'description'
+ },
+ {
+ title: t('project.workflow.create_time'),
+ key: 'operateTime'
+ },
+ {
+ title: t('project.workflow.operation'),
+ key: 'operation',
+ className: styles.operation,
+ render: (_row) => {
+ return h(NSpace, null, {
+ default: () => [
+ h(
+ NPopconfirm,
+ {
+ onPositiveClick: () => {
+ handleSwitchVersion(_row.version)
+ }
+ },
+ {
+ trigger: () =>
+ h(
+ NTooltip,
+ {},
+ {
+ trigger: () =>
+ h(
+ NButton,
+ {
+ circle: true,
+ type: 'info',
+ size: 'tiny',
+ disabled: _row.version === variables.row.version
+ },
+ {
+ icon: () => h(ExclamationCircleOutlined)
+ }
+ ),
+ default: () => t('project.workflow.switch_version')
+ }
+ ),
+ default: () => t('project.workflow.confirm_switch_version')
+ }
+ ),
+ h(
+ NPopconfirm,
+ {
+ onPositiveClick: () => {
+ handleDeleteVersion(_row.version)
+ }
+ },
+ {
+ trigger: () =>
+ h(
+ NTooltip,
+ {},
+ {
+ trigger: () =>
+ h(
+ NButton,
+ {
+ circle: true,
+ type: 'error',
+ size: 'tiny',
+ disabled: _row.version === variables.row.version
+ },
+ {
+ icon: () => h(DeleteOutlined)
+ }
+ ),
+ default: () => t('project.workflow.delete')
+ }
+ ),
+ default: () => t('project.workflow.delete_confirm')
+ }
+ )
+ ]
+ })
+ }
+ }
+ ] as TableColumns<any>
+ }
+
const getTableData = (row: any) => {
if (variables.loadingRef) return
variables.loadingRef = true
@@ -178,9 +180,9 @@ export function useTable(
const handleSwitchVersion = (version: number) => {
switchVersion(variables.projectCode, variables.row.code, version).then(
() => {
+ variables.row.version = version
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
- getTableData(variables.row)
}
)
}
@@ -190,6 +192,9 @@ export function useTable(
() => {
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
+ if (variables.tableData.length === 1 && variables.page > 1) {
+ variables.page -= 1
+ }
getTableData(variables.row)
}
)
@@ -197,6 +202,7 @@ export function useTable(
return {
variables,
+ createColumns,
getTableData
}
}
diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx b/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx
index 3d761296c1..3db070c41b 100644
--- a/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx
+++ b/dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx
@@ -41,7 +41,7 @@ export default defineComponent({
props,
emits: ['update:show', 'update:row', 'updateList'],
setup(props, ctx) {
- const { variables, getTableData } = useTable(ctx)
+ const { variables, createColumns, getTableData } = useTable(ctx)
const { importState } = useForm()
const { handleImportDefinition } = useModal(importState, ctx)
@@ -66,9 +66,16 @@ export default defineComponent({
watch(
() => props.show,
- () => requestData()
+ () => {
+ createColumns(variables)
+ requestData()
+ }
)
+ watch(useI18n().locale, () => {
+ createColumns(variables)
+ })
+
return {
hideModal,
handleImport,