fix: type issues (#8413)

pull/8428/head
Mert E 2 weeks ago committed by GitHub
parent 2d1c743f84
commit 08dfcfa7d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 54
      packages/nc-gui/components/dlg/WorkspaceDelete.vue
  2. 7
      packages/nc-gui/components/workspace/CollaboratorsList.vue
  3. 190
      packages/nc-gui/components/workspace/Settings.vue
  4. 4
      packages/nc-gui/components/workspace/View.vue

@ -1,54 +0,0 @@
<script lang="ts" setup>
const props = defineProps<{
visible: boolean
workspaceId: string
}>()
const emits = defineEmits(['update:visible'])
const visible = useVModel(props, 'visible', emits)
const workspaceStore = useWorkspace()
const { deleteWorkspace: _deleteWorkspace, loadWorkspaces, navigateToWorkspace } = workspaceStore
const { workspaces, workspacesList } = storeToRefs(workspaceStore)
const { refreshCommandPalette } = useCommandPalette()
const workspace = computed(() => workspaces.value.get(props.workspaceId))
const onDelete = async () => {
if (!workspace.value) return
try {
await _deleteWorkspace(workspace.value.id!)
await loadWorkspaces()
if (!workspacesList.value?.[0]?.id) {
return await navigateToWorkspace()
}
await navigateToWorkspace(workspacesList.value?.[0]?.id)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
} finally {
refreshCommandPalette()
}
}
</script>
<template>
<GeneralDeleteModal v-model:visible="visible" :entity-name="$t('objects.workspace')" :on-delete="onDelete">
<template #entity-preview>
<div v-if="workspace" class="flex flex-row items-center py-2.25 px-2.75 bg-gray-50 rounded-lg text-gray-700 mb-4">
<GeneralIcon icon="workspace" />
<div
class="capitalize text-ellipsis overflow-hidden select-none w-full pl-2.25"
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }"
>
{{ workspace.title }}
</div>
</div>
</template>
</GeneralDeleteModal>
</template>

@ -66,8 +66,7 @@ const selectAll = computed({
const updateCollaborator = async (collab: any, roles: WorkspaceUserRoles) => {
try {
console.log()
await _updateCollaborator(collab.id, roles, currentWorkspace.value.id)
await _updateCollaborator(collab.id, roles, currentWorkspace.value?.id)
message.success('Successfully updated user role')
collaborators.value?.forEach((collaborator) => {
@ -95,7 +94,7 @@ onMounted(async () => {
</script>
<template>
<DlgInviteDlg v-model:model-value="inviteDlg" :workspace-id="currentWorkspace.id" type="workspace" />
<DlgInviteDlg v-model:model-value="inviteDlg" :workspace-id="currentWorkspace?.id" type="workspace" />
<div class="nc-collaborator-table-container mt-4 h-[calc(100vh-10rem)]">
<div class="w-full flex justify-between mt-6.5 mb-2">
<a-input v-model:value="userSearchText" class="!max-w-90 !rounded-md mr-4" placeholder="Search members">
@ -212,7 +211,7 @@ onMounted(async () => {
<NcMenuItem
class="!text-red-500 !hover:bg-red-50"
@click="removeCollaborator(collab.id, currentWorkspace.id)"
@click="removeCollaborator(collab.id, currentWorkspace?.id)"
>
<MaterialSymbolsDeleteOutlineRounded />
Remove user

@ -1,191 +1,3 @@
<script lang="ts" setup>
import { ref, storeToRefs, useGlobal, useI18n, useWorkspace, watch } from '#imports'
const props = defineProps<{
workspaceId?: string
}>()
const { signOut } = useGlobal()
const { t } = useI18n()
const { deleteWorkspace, navigateToWorkspace, updateWorkspace } = useWorkspace()
const { workspacesList, activeWorkspace, workspaces } = storeToRefs(useWorkspace())
const formValidator = ref()
const isConfirmed = ref(false)
const isDeleting = ref(false)
const isErrored = ref(false)
const isTitleUpdating = ref(false)
const isCancelButtonVisible = ref(false)
const form = ref({
title: '',
})
const formRules = {
title: [
{ required: true, message: t('msg.info.wsNameRequired') },
{ min: 3, message: t('msg.info.wsNameMinLength') },
{ max: 50, message: t('msg.info.wsNameMaxLength') },
],
}
const currentWorkspace = computed(() => {
return props.workspaceId ? workspaces.value.get(props.workspaceId) : activeWorkspace.value
})
const onDelete = async () => {
isDeleting.value = true
try {
await deleteWorkspace(currentWorkspace.value.id, { skipStateUpdate: true })
isConfirmed.value = false
isDeleting.value = false
// We only remove the delete workspace from the list after the api call is successful
workspaces.value.delete(currentWorkspace.value.id)
if (workspacesList.value.length > 1) {
// WorkspaceId is provided from the admin Panel. If deleted navigate to the workspace list page
if (!props.workspaceId) {
await navigateToWorkspace(workspacesList.value[0].id)
} else {
// #TODO: @DarkPhoenix2704
// Navigate BackPage
}
} else {
// As signin page will clear the workspaces, we need to check if there are more than one workspace
await signOut(false)
setTimeout(() => {
window.location.href = '/'
}, 100)
}
} finally {
isDeleting.value = false
}
}
const titleChange = async () => {
const valid = await formValidator.value.validate()
if (!valid) return
if (isTitleUpdating.value) return
isTitleUpdating.value = true
isErrored.value = false
try {
await updateWorkspace(currentWorkspace.value.id, {
title: form.value.title,
})
} catch (e: any) {
console.error(e)
} finally {
isTitleUpdating.value = false
isCancelButtonVisible.value = false
}
}
watch(
() => currentWorkspace.value.id,
() => {
form.value.title = currentWorkspace.value.title
},
{
immediate: true,
},
)
watch(
() => form.value.title,
async () => {
try {
isCancelButtonVisible.value = form.value.title !== currentWorkspace.value?.title
isErrored.value = !(await formValidator.value.validate())
} catch (e: any) {
isErrored.value = true
}
},
)
const onCancel = () => {
form.value.title = currentWorkspace.value?.title
}
</script>
<template>
<div class="flex flex-col items-center nc-workspace-settings-settings">
<div class="item flex flex-col w-full">
<div class="font-medium text-base">{{ $t('labels.changeWsName') }}</div>
<a-form ref="formValidator" layout="vertical" no-style :model="form" class="w-full" @finish="titleChange">
<div class="text-gray-500 mt-6 mb-1.5">{{ `${t('objects.workspace')} ${t('general.name')}` }}</div>
<a-form-item name="title" :rules="formRules.title">
<a-input
v-model:value="form.title"
class="w-full !rounded-md !py-1.5"
placeholder="Workspace name"
data-testid="nc-workspace-settings-settings-rename-input"
/>
</a-form-item>
<div class="flex flex-row w-full justify-end mt-8 gap-4">
<NcButton
v-if="isCancelButtonVisible"
type="secondary"
html-type="submit"
data-testid="nc-workspace-settings-settings-rename-cancel"
@click="onCancel"
>
<template #loading> {{ $t('title.renamingWs') }} </template>
{{ $t('general.cancel') }}
</NcButton>
<NcButton
v-e="['c:workspace:settings:rename']"
type="primary"
html-type="submit"
:disabled="isErrored || (form.title && form.title === currentWorkspace.title)"
:loading="isDeleting"
data-testid="nc-workspace-settings-settings-rename-submit"
>
<template #loading> {{ $t('title.renamingWs') }} </template>
{{ $t('title.renameWs') }}
</NcButton>
</div>
</a-form>
</div>
<div class="item flex flex-col">
<div class="font-medium text-base">{{ $t('title.deleteWs') }}</div>
<div class="text-gray-500 mt-2">{{ $t('msg.info.wsDeleteDlg') }}</div>
<div class="flex flex-row mt-8 gap-x-2">
<a-checkbox v-model:checked="isConfirmed" />
<div class="flex">{{ $t('msg.info.userConfirmation') }}</div>
</div>
<div class="flex flex-row w-full justify-end mt-8">
<NcButton
v-e="['c:workspace:settings:delete']"
type="danger"
:disabled="!isConfirmed"
:loading="isDeleting"
@click="onDelete"
>
<template #loading> {{ $t('title.deletingWs') }} </template>
{{ $t('title.deleteWs') }}
</NcButton>
</div>
</div>
</div>
<span />
</template>
<style lang="scss" scoped>
.item-card {
@apply p-6 rounded-2xl border-1 max-w-180 mt-10 min-w-100 w-full;
}
</style>

@ -44,7 +44,7 @@ const tab = computed({
watch(
() => currentWorkspace.value?.title,
(title: string) => {
(title) => {
if (!title) return
const capitalizedTitle = title.charAt(0).toUpperCase() + title.slice(1)
@ -60,7 +60,7 @@ onMounted(() => {
until(() => currentWorkspace.value?.id)
.toMatch((v) => !!v)
.then(async () => {
await loadCollaborators({} as any, currentWorkspace.value.id)
await loadCollaborators({} as any, currentWorkspace.value!.id)
})
})
</script>

Loading…
Cancel
Save