Skip to content

Commit

Permalink
feat(merge): merge data modal
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Aug 31, 2023
1 parent 998b906 commit 9d4c8c7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/frontend/src/lib/import/MergeData.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script lang="ts">
import { mergeDataModal } from '$lib/store/modal'
import { Modal } from 'flowbite-svelte'
</script>

<Modal class="w-full" bind:open={$mergeDataModal.open}>merge</Modal>
3 changes: 3 additions & 0 deletions apps/frontend/src/lib/store/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const createOptionModal = createModal(CREATE_OPTION)
const UPDATE_OPTION = Symbol('UPDATE_OPTION')
export const updateOptionModal = createModal(UPDATE_OPTION)

const MERGE_DATA_MODAL = Symbol('MERGE_DATA_MODAL')
export const mergeDataModal = createModal(MERGE_DATA_MODAL)

const IMPORT_DATA_MODAL = Symbol('IMPORT_DATA_MODAL')
export const importDataModal = createModal(IMPORT_DATA_MODAL)

Expand Down
13 changes: 12 additions & 1 deletion apps/frontend/src/lib/table/TableMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { t } from '$lib/i18n'
import { webhookListDrawer } from '$lib/store/drawer'
import { erdModal, rlsModal } from '$lib/store/modal'
import { erdModal, mergeDataModal, rlsModal } from '$lib/store/modal'
import { currentRLSS } from '$lib/store/table'
import { Badge, Dropdown, DropdownItem } from 'flowbite-svelte'
import { hasPermission } from '$lib/store/authz'
Expand Down Expand Up @@ -47,4 +47,15 @@
{/if}
</DropdownItem>
{/if}
{#if $hasPermission('table:merge_data')}
<DropdownItem
on:click={() => {
mergeDataModal.open()
}}
class="text-xs font-normal inline-flex items-center gap-2"
>
<i class="ti ti-database-import text-gray-600 dark:text-gray-50" />
<span>{$t('merge data')}</span>
</DropdownItem>
{/if}
</Dropdown>
3 changes: 3 additions & 0 deletions apps/frontend/src/routes/(authed)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { DARK_THEME, LIGHT_THEME } from '$lib/store/ui.type'
import TablesNav from '$lib/table/TablesNav.svelte'
import { hasPermission } from '$lib/store/authz'
import MergeData from '$lib/import/MergeData.svelte'
$: navigation = [
{ name: $t('Tables', { ns: 'common' }), href: '/', icon: 'table', current: $page.url.pathname === '/' },
Expand Down Expand Up @@ -406,6 +407,8 @@
{#if $importDataModal.open}
<ImportData formData={$page.data.createTable} />
{/if}

<MergeData />
</div>

<Toast
Expand Down
5 changes: 5 additions & 0 deletions packages/authz/src/rbac/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const tableActions = z.enum([
'table:list_form',
'table:create_form',
'table:update_form',
'table:merge_data',
])
export const recordActions = z.enum(['record:create', 'record:update', 'record:delete', 'record:list_trash'])
export const webhookActions = z.enum(['webhook:create', 'webhook:update', 'webhook:delete'])
Expand Down Expand Up @@ -81,6 +82,7 @@ export const permissions: Record<IRoles, Record<PermissionAction, boolean>> = {
'table:set_view_field': true,
'table:delete_view': true,
'table:duplicate_view': true,
'table:merge_data': true,
'record:create': true,
'record:delete': true,
'record:update': true,
Expand Down Expand Up @@ -131,6 +133,7 @@ export const permissions: Record<IRoles, Record<PermissionAction, boolean>> = {
'table:set_view_field': true,
'table:delete_view': true,
'table:duplicate_view': true,
'table:merge_data': true,
'table:create_form': true,
'table:update_form': true,
'record:create': true,
Expand Down Expand Up @@ -185,6 +188,7 @@ export const permissions: Record<IRoles, Record<PermissionAction, boolean>> = {
'table:list_form': true,
'table:create_form': true,
'table:update_form': true,
'table:merge_data': true,
'record:create': true,
'record:delete': true,
'record:update': true,
Expand Down Expand Up @@ -237,6 +241,7 @@ export const permissions: Record<IRoles, Record<PermissionAction, boolean>> = {
'table:list_form': false,
'table:create_form': false,
'table:update_form': false,
'table:merge_data': false,
'record:create': false,
'record:delete': false,
'record:update': false,
Expand Down

0 comments on commit 9d4c8c7

Please sign in to comment.