Skip to content

Commit

Permalink
[feature] add button update and delete (apache#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoJiang521 authored and FlechazoW committed Aug 24, 2023
1 parent 5b9dccc commit 0438d39
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
1 change: 1 addition & 0 deletions seatunnel-ui/src/locales/en_US/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
operation: 'Operation',
click_to_view: 'Click to view',
delete: 'Delete',
delete_confirm: 'Are you sure delete ?',
confirm: 'Confirm',
cancel: 'Cancel',
create: 'Create',
Expand Down
1 change: 1 addition & 0 deletions seatunnel-ui/src/locales/zh_CN/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
operation: '操作',
click_to_view: '点击查看',
delete: '删除',
delete_confirm: '确认删除?',
confirm: '确定',
cancel: '取消',
create: '创建',
Expand Down
4 changes: 2 additions & 2 deletions seatunnel-ui/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/

import { createRouter, createWebHashHistory } from 'vue-router'
import {createRouter, createWebHistory} from 'vue-router'
import routes from './routes'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const router = createRouter({
history: createWebHashHistory(
history: createWebHistory(
import.meta.env.MODE === 'production' ? '/ui/' : '/'
),
routes
Expand Down
2 changes: 1 addition & 1 deletion seatunnel-ui/src/views/datasource/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const DatasourceList = defineComponent({
const { getColumns } = useColumns((id: string, type: 'edit' | 'delete') => {
if (type === 'edit') {
router.push({ name: 'datasource-edit', params: { id } })
} else {
} else if(type === 'delete'){
deleteRecord(id)
}
})
Expand Down
22 changes: 20 additions & 2 deletions seatunnel-ui/src/views/datasource/list/use-columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getTableColumn } from '@/common/table'

import { useTableOperation } from '@/hooks'
import { EditOutlined } from '@vicons/antd'
import ResourceAuth from '@/components/resource-auth'

export function useColumns(onCallback: Function) {
const { t } = useI18n()
Expand Down Expand Up @@ -80,7 +79,26 @@ export function useColumns(onCallback: Function) {
{
title: t('datasource.update_time'),
key: 'updateTime',
}
},
useTableOperation({
title: t('datasource.operation'),
key: 'operation',
buttons: [
{
text: t('datasource.edit'),
icon: h(EditOutlined),
onClick: (rowData) => void onCallback(rowData.id, 'edit')
},
{
isDelete: true,
text: t('datasource.delete'),
onPositiveClick: (rowData) => void onCallback(rowData.id, 'delete'),
negativeText: t('datasource.cancel'),
positiveText: t('datasource.confirm'),
popTips: t('datasource.delete_confirm')
}
]
})
]
}

Expand Down
43 changes: 18 additions & 25 deletions seatunnel-ui/src/views/virtual-tables/list/use-columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { h, ref, watch, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { EditOutlined } from '@vicons/antd'
import { NButton, NSpace } from 'naive-ui'
import {useTableOperation} from "@/hooks";
//import type { TableColumns, VirtualTableRecord } from '../types'

export function useColumns(onCallback: Function) {
Expand Down Expand Up @@ -70,33 +71,25 @@ export function useColumns(onCallback: Function) {
//render: (rowData: VirtualTableRecord) =>
// renderTableTime(rowData.createTime)
},
{
useTableOperation({
title: t('virtual_tables.operation'),
key: 'operation',
render: (row: any) =>
h(NSpace, null, {
default: () => [
h(
NButton,
{
text: true,
onClick: () => void onCallback(row.tableId, 'edit')
},
{
default: () => t('virtual_tables.edit')
}
),
h(
NButton,
{
text: true,
onClick: () => void onCallback(row.tableId, 'delete')
},
{ default: () => t('virtual_tables.delete') }
)
]
})
}
buttons: [
{
text: t('datasource.edit'),
icon: h(EditOutlined),
onClick: (rowData) => void onCallback(rowData.tableId, 'edit')
},
{
isDelete: true,
text: t('datasource.delete'),
onPositiveClick: (rowData) => void onCallback(rowData.tableId, 'delete'),
negativeText: t('datasource.cancel'),
positiveText: t('datasource.confirm'),
popTips: t('datasource.delete_confirm')
}
]
})
]
return columns
}
Expand Down

0 comments on commit 0438d39

Please sign in to comment.