diff --git a/web/satellite/src/components/accessGrants/AccessGrants.vue b/web/satellite/src/components/accessGrants/AccessGrants.vue index f99a98b2c..503475a14 100644 --- a/web/satellite/src/components/accessGrants/AccessGrants.vue +++ b/web/satellite/src/components/accessGrants/AccessGrants.vue @@ -152,10 +152,6 @@ - @@ -172,9 +168,10 @@ import { AccessType } from '@/types/createAccessGrant'; import { useNotify, useRouter } from '@/utils/hooks'; import { useAccessGrantsStore } from '@/store/modules/accessGrantsStore'; import { useProjectsStore } from '@/store/modules/projectsStore'; +import { useAppStore } from '@/store/modules/appStore'; +import { MODALS } from '@/utils/constants/appStatePopUps'; import AccessGrantsItem from '@/components/accessGrants/AccessGrantsItem.vue'; -import ConfirmDeletePopup from '@/components/accessGrants/ConfirmDeletePopup.vue'; import VButton from '@/components/common/VButton.vue'; import VLoader from '@/components/common/VLoader.vue'; import VHeader from '@/components/common/VHeader.vue'; @@ -188,12 +185,12 @@ const FIRST_PAGE = 1; const analytics: AnalyticsHttpApi = new AnalyticsHttpApi(); +const appStore = useAppStore(); const agStore = useAccessGrantsStore(); const projectsStore = useProjectsStore(); const notify = useNotify(); const router = useRouter(); -const isDeleteClicked = ref(false); const activeDropdown = ref(-1); const areGrantsFetching = ref(true); @@ -272,16 +269,10 @@ function openDropdown(key: number): void { * Holds on button click login for deleting access grant process. */ function onDeleteClick(grant: AccessGrant): void { + agStore.setAccessNameToDelete(grant.name); agStore.toggleSelection(grant); - isDeleteClicked.value = true; -} -/** - * Clears access grants selection. - */ -function onClearSelection(): void { - isDeleteClicked.value = false; - agStore.clearSelection(); + appStore.updateActiveModal(MODALS.deleteAccessGrant); } /** @@ -293,7 +284,7 @@ async function fetch(searchQuery: string): Promise { try { await agStore.getAccessGrants(FIRST_PAGE, projectsStore.state.selectedProject.id); } catch (error) { - await notify.error(`Unable to fetch accesses: ${error.message}`, AnalyticsErrorEventSource.ACCESS_GRANTS_PAGE); + notify.error(`Unable to fetch accesses: ${error.message}`, AnalyticsErrorEventSource.ACCESS_GRANTS_PAGE); } } @@ -350,7 +341,7 @@ onMounted(async () => { }); onBeforeUnmount(() => { - onClearSelection(); + agStore.clearSelection(); }); diff --git a/web/satellite/src/components/modals/DeleteAccessGrantModal.vue b/web/satellite/src/components/modals/DeleteAccessGrantModal.vue new file mode 100644 index 000000000..90609c51e --- /dev/null +++ b/web/satellite/src/components/modals/DeleteAccessGrantModal.vue @@ -0,0 +1,168 @@ +// Copyright (C) 2023 Storj Labs, Inc. +// See LICENSE for copying information. + + + + + + diff --git a/web/satellite/src/store/modules/accessGrantsStore.ts b/web/satellite/src/store/modules/accessGrantsStore.ts index 3655dac25..8761e065f 100644 --- a/web/satellite/src/store/modules/accessGrantsStore.ts +++ b/web/satellite/src/store/modules/accessGrantsStore.ts @@ -31,6 +31,7 @@ class AccessGrantsState { public edgeCredentials: EdgeCredentials = new EdgeCredentials(); public accessGrantsWebWorker: Worker | null = null; public isAccessGrantsWebWorkerReady = false; + public accessNameToDelete = ''; } export const useAccessGrantsStore = defineStore('accessGrants', () => { @@ -114,6 +115,10 @@ export const useAccessGrantsStore = defineStore('accessGrants', () => { state.cursor.order = order; } + function setAccessNameToDelete(name: string): void { + state.accessNameToDelete = name; + } + function setDurationPermission(permission: DurationPermission): void { state.permissionNotBefore = permission.notBefore; state.permissionNotAfter = permission.notAfter; @@ -223,6 +228,7 @@ export const useAccessGrantsStore = defineStore('accessGrants', () => { getEdgeCredentials, setSearchQuery, setSortingBy, + setAccessNameToDelete, setSortingDirection, toggleSortingDirection, setDurationPermission, diff --git a/web/satellite/src/utils/constants/appStatePopUps.ts b/web/satellite/src/utils/constants/appStatePopUps.ts index 73cf0f1c2..32d6b41ec 100644 --- a/web/satellite/src/utils/constants/appStatePopUps.ts +++ b/web/satellite/src/utils/constants/appStatePopUps.ts @@ -30,6 +30,7 @@ import PricingPlanModal from '@/components/modals/PricingPlanModal.vue'; import NewCreateProjectModal from '@/components/modals/NewCreateProjectModal.vue'; import EditSessionTimeoutModal from '@/components/modals/EditSessionTimeoutModal.vue'; import UpgradeAccountModal from '@/components/modals/upgradeAccountFlow/UpgradeAccountModal.vue'; +import DeleteAccessGrantModal from '@/components/modals/DeleteAccessGrantModal.vue'; export const APP_STATE_DROPDOWNS = { ACCOUNT: 'isAccountDropdownShown', @@ -76,6 +77,7 @@ enum Modals { NEW_CREATE_PROJECT = 'newCreateProject', EDIT_SESSION_TIMEOUT = 'editSessionTimeout', UPGRADE_ACCOUNT = 'upgradeAccount', + DELETE_ACCESS_GRANT = 'deleteAccessGrant', } // modals could be of VueConstructor type or Object (for composition api components). @@ -106,4 +108,5 @@ export const MODALS: Record = { [Modals.NEW_CREATE_PROJECT]: NewCreateProjectModal, [Modals.EDIT_SESSION_TIMEOUT]: EditSessionTimeoutModal, [Modals.UPGRADE_ACCOUNT]: UpgradeAccountModal, + [Modals.DELETE_ACCESS_GRANT]: DeleteAccessGrantModal, }; diff --git a/web/satellite/static/images/modals/deleteAccessGrant/delete.svg b/web/satellite/static/images/modals/deleteAccessGrant/delete.svg new file mode 100644 index 000000000..a342876a4 --- /dev/null +++ b/web/satellite/static/images/modals/deleteAccessGrant/delete.svg @@ -0,0 +1,4 @@ + + + +