Browse Source

feat(gui-v2): integrate project delete

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2723/head
Pranav C 2 years ago
parent
commit
e7ebc79cc5
  1. 1
      packages/nc-gui-v2/components.d.ts
  2. 8
      packages/nc-gui-v2/components/cell/Url.vue
  3. 21
      packages/nc-gui-v2/pages/index/index/index.vue
  4. 14
      packages/nc-gui-v2/pages/projects/index.vue

1
packages/nc-gui-v2/components.d.ts vendored

@ -7,6 +7,7 @@ export {}
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
ADivider: typeof import('ant-design-vue/es')['Divider']
ADropdown: typeof import('ant-design-vue/es')['Dropdown'] ADropdown: typeof import('ant-design-vue/es')['Dropdown']
ALayout: typeof import('ant-design-vue/es')['Layout'] ALayout: typeof import('ant-design-vue/es')['Layout']
ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent'] ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent']

8
packages/nc-gui-v2/components/cell/Url.vue

@ -3,15 +3,15 @@ import { computed, ref } from '#imports'
import { ColumnInj } from '~/components' import { ColumnInj } from '~/components'
import { isValidURL } from '~/utils/urlUtils' import { isValidURL } from '~/utils/urlUtils'
interface Props {
modelValue: string
}
const { modelValue: value } = defineProps<Props>() const { modelValue: value } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const column = inject(ColumnInj) const column = inject(ColumnInj)
const editEnabled = inject<boolean>('editEnabled') const editEnabled = inject<boolean>('editEnabled')
interface Props {
modelValue: string
}
const localState = computed({ const localState = computed({
get: () => value, get: () => value,
set: (val) => { set: (val) => {

21
packages/nc-gui-v2/pages/index/index/index.vue

@ -14,6 +14,8 @@ interface Props {
const { projects } = defineProps<Props>() const { projects } = defineProps<Props>()
const emit = defineEmits(['delete-project'])
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const { getColorByIndex } = useColors(true) const { getColorByIndex } = useColors(true)
@ -72,18 +74,18 @@ const formatTitle = (title: string) =>
<MdiStarOutline class="star-icon" @click.stop /> <MdiStarOutline class="star-icon" @click.stop />
<v-menu> <a-dropdown @click.stop>
<template #activator="{ props }"> <MdiMenuDown class="menu-icon" />
<MdiMenuDown class="menu-icon" @click.stop="props.onClick" /> <template #overlay>
</template> <div
class="grid grid-cols-6 cursor-pointer flex items-center p-2 border-1 bg-white dark:bg-slate-800 hover:bg-gray-200"
<v-list class="!py-0 flex flex-col bg-white rounded-lg shadow-md border-1 border-gray-300"> @click.stop="emit('delete-project', project)"
<div class="grid grid-cols-6 cursor-pointer hover:bg-gray-200 flex items-center p-2" @click.stop> >
<MdiDeleteOutline class="col-span-2 mr-1 mt-[1px] text-red text-lg" /> <MdiDeleteOutline class="col-span-2 mr-1 mt-[1px] text-red text-lg" />
<div class="col-span-4 text-sm xl:text-md">{{ $t('general.delete') }}</div> <div class="col-span-4 text-sm xl:text-md">{{ $t('general.delete') }}</div>
</div> </div>
</v-list> </template>
</v-menu> </a-dropdown>
</div> </div>
<div class="prose-lg font-semibold"> <div class="prose-lg font-semibold">
@ -104,6 +106,7 @@ const formatTitle = (title: string) =>
content: ''; content: '';
z-index: -1; z-index: -1;
} }
.thumbnail:hover::after { .thumbnail:hover::after {
@apply shadow-2xl transform scale-110; @apply shadow-2xl transform scale-110;
} }

14
packages/nc-gui-v2/pages/projects/index.vue

@ -1,5 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ProjectType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { navigateTo } from '#app' import { navigateTo } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MaterialSymbolsFormatListBulletedRounded from '~icons/material-symbols/format-list-bulleted-rounded' import MaterialSymbolsFormatListBulletedRounded from '~icons/material-symbols/format-list-bulleted-rounded'
import MaterialSymbolsGridView from '~icons/material-symbols/grid-view' import MaterialSymbolsGridView from '~icons/material-symbols/grid-view'
import MdiPlus from '~icons/mdi/plus' import MdiPlus from '~icons/mdi/plus'
@ -32,10 +35,19 @@ const navDrawerOptions = [
const route = useRoute() const route = useRoute()
const { $api, $state } = useNuxtApp() const { $api, $state } = useNuxtApp()
const toast = useToast()
const response = await $api.project.list({}) const response = await $api.project.list({})
const projects = $ref(response.list) const projects = $ref(response.list)
const activePage = $ref(navDrawerOptions[0].title) const activePage = $ref(navDrawerOptions[0].title)
const deleteProject = async (project: ProjectType) => {
try {
await $api.project.delete(project.id as string)
projects.splice(projects.indexOf(project), 1)
} catch (e) {
toast.error(await extractSdkResponseErrorMsg(e))
}
}
</script> </script>
<template> <template>
@ -119,7 +131,7 @@ const activePage = $ref(navDrawerOptions[0].title)
<a-divider class="!mb-4 lg:(!mb-8)" /> <a-divider class="!mb-4 lg:(!mb-8)" />
<NuxtPage :projects="projects" /> <NuxtPage :projects="projects" @delete-project="deleteProject" />
</v-container> </v-container>
</NuxtLayout> </NuxtLayout>
</template> </template>

Loading…
Cancel
Save