From 9ea38b28ec77c66480bce786c1c0b5bbfa47efb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Wed, 13 May 2026 09:36:58 +0100 Subject: [PATCH] feat: delete repos from collections IN-1118 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../details/collection-project-item.vue | 41 ++++++++++++++++++- .../collection/views/collection-details.vue | 41 +++++++++++++++++++ frontend/types/collection.ts | 1 + 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/modules/collection/components/details/collection-project-item.vue b/frontend/app/components/modules/collection/components/details/collection-project-item.vue index a3cc690cb..c8f2d180e 100644 --- a/frontend/app/components/modules/collection/components/details/collection-project-item.vue +++ b/frontend/app/components/modules/collection/components/details/collection-project-item.vue @@ -6,7 +6,7 @@ SPDX-License-Identifier: MIT @@ -113,6 +113,24 @@ SPDX-License-Identifier: MIT - - + + + @@ -136,6 +154,18 @@ SPDX-License-Identifier: MIT label="Archived" type="project" /> + (), { as: 'card', + canRemove: false, + isRemoving: false, }, ); +const emit = defineEmits<{ + remove: [repoUrl: string]; +}>(); + const router = useRouter(); const status = computed(() => { diff --git a/frontend/app/components/modules/collection/views/collection-details.vue b/frontend/app/components/modules/collection/views/collection-details.vue index db94cc27e..50ed26625 100644 --- a/frontend/app/components/modules/collection/views/collection-details.vue +++ b/frontend/app/components/modules/collection/views/collection-details.vue @@ -29,7 +29,10 @@ SPDX-License-Identifier: MIT v-for="project in flatData" :key="project.slug" :project="project" + :can-remove="isOwner" + :is-removing="removingRepoUrl === project.repoUrl" as="card" + @remove="handleRemoveRepo" /> @@ -70,6 +73,10 @@ SPDX-License-Identifier: MIT Contributor/Organization dependency Achievements + @@ -77,7 +84,10 @@ SPDX-License-Identifier: MIT v-for="project in flatData" :key="project.slug" :project="project" + :can-remove="isOwner" + :is-removing="removingRepoUrl === project.repoUrl" as="row" + @remove="handleRemoveRepo" /> @@ -202,6 +212,7 @@ import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { storeToRefs } from 'pinia'; import LfxCollectionProjectItem from '../components/details/collection-project-item.vue'; import LfxCollectionProjectItemLoading from '../components/details/collection-project-item-loading.vue'; +import { useConfirmStore } from '~/components/shared/modules/confirm/store/confirm.store'; import type { Collection, CollectionType } from '~~/types/collection'; import LfxCollectionHeader from '~/components/modules/collection/components/details/header.vue'; @@ -268,6 +279,36 @@ const collectionType = computed(() => { return currentCollection.value?.ssoUserId ? CollectionTypeEnum.COMMUNITY : CollectionTypeEnum.CURATED; }); +const isOwner = computed(() => collectionType.value === CollectionTypeEnum.MY_COLLECTIONS); + +const { openConfirmModal } = useConfirmStore(); +const removingRepoUrl = ref(null); + +const handleRemoveRepo = async (repoUrl: string) => { + const confirmed = await openConfirmModal({ + title: 'Remove repository', + message: `Are you sure you want to remove this repository from the collection?`, + confirmLabel: 'Remove', + cancelLabel: 'Cancel', + }); + + if (!confirmed || !currentCollection.value) return; + + const currentUrls = currentCollection.value.repositoryUrls ?? []; + const updatedUrls = currentUrls.filter((url) => url !== repoUrl); + + removingRepoUrl.value = repoUrl; + try { + const updated = await COLLECTIONS_API_SERVICE.updateCollection(currentCollection.value.id, { + name: currentCollection.value.name, + repositoryUrls: updatedUrls, + }); + handleCollectionUpdated(updated); + } finally { + removingRepoUrl.value = null; + } +}; + const sort = ref(collectionSort || 'contributorCount_desc'); const isLFOnly = ref(onlyLFProjects === 'true'); diff --git a/frontend/types/collection.ts b/frontend/types/collection.ts index 5a4a884c0..eee3b682d 100644 --- a/frontend/types/collection.ts +++ b/frontend/types/collection.ts @@ -34,4 +34,5 @@ export interface Collection { isPrivate?: boolean; ssoUserId?: string | null; likeCount?: number; + repositoryUrls?: string[]; }