-
Notifications
You must be signed in to change notification settings - Fork 49
feat: display repo license info IN-1099 #1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f33bcd8
feat: map repo licenses in project endpoint IN-1099
gaspergrom 860195b
feat: display repo licenses in project about section IN-1099
gaspergrom df00b6b
fix: improve licenses display IN-1099
gaspergrom a414967
fix: licenses popover height and single-repo tooltip IN-1099
gaspergrom aa967e2
fix: hide license popover for single-repo projects IN-1099
gaspergrom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
frontend/app/components/modules/project/components/overview/about-section/licenses.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| <!-- | ||
| Copyright (c) 2025 The Linux Foundation and each contributor. | ||
| SPDX-License-Identifier: MIT | ||
| --> | ||
| <template> | ||
| <div | ||
| v-if="activeLicenses.length > 0" | ||
| class="flex flex-col gap-3 text-xs" | ||
| > | ||
| <div class="text-neutral-400 font-semibold">License(s)</div> | ||
| <div class="flex flex-col gap-3"> | ||
| <div class="flex flex-wrap gap-1.5"> | ||
| <template | ||
| v-for="license of displayedLicenses" | ||
| :key="license" | ||
| > | ||
| <div | ||
| v-if="isRepoSelected || isSingleRepoProject" | ||
| class="bg-white border border-neutral-200 h-6 rounded-full px-2.5 flex items-center gap-1 cursor-default shrink-0" | ||
| > | ||
| <lfx-icon | ||
| name="scale-balanced" | ||
| :size="12" | ||
| class="text-neutral-500" | ||
| /> | ||
| <div class="text-neutral-900 font-normal whitespace-nowrap">{{ formatLicense(license) }}</div> | ||
| </div> | ||
| <lfx-tooltip | ||
| v-else-if="isSharedByAllRepos(license)" | ||
| content="License shared by all repositories" | ||
| placement="top" | ||
| > | ||
| <div | ||
| class="bg-white border border-neutral-200 h-6 rounded-full px-2.5 flex items-center gap-1 cursor-default shrink-0" | ||
| > | ||
| <lfx-icon | ||
| name="scale-balanced" | ||
| :size="12" | ||
| class="text-neutral-500" | ||
| /> | ||
| <div class="text-neutral-900 font-normal whitespace-nowrap">{{ formatLicense(license) }}</div> | ||
| </div> | ||
| </lfx-tooltip> | ||
| <lfx-popover | ||
| v-else | ||
| trigger-event="hover" | ||
| placement="bottom-start" | ||
|
joanagmaia marked this conversation as resolved.
|
||
| :spacing="6" | ||
| > | ||
| <div | ||
| class="bg-white border border-neutral-200 h-6 rounded-full px-2.5 flex items-center gap-1 cursor-default shrink-0" | ||
| > | ||
| <lfx-icon | ||
| name="scale-balanced" | ||
| :size="12" | ||
| class="text-neutral-500" | ||
| /> | ||
| <div class="text-neutral-900 font-normal whitespace-nowrap">{{ formatLicense(license) }}</div> | ||
| </div> | ||
| <template #content> | ||
| <div | ||
| class="bg-white border border-neutral-100 rounded-xl shadow-lg p-2 flex flex-col max-h-56 overflow-y-auto" | ||
| > | ||
| <div | ||
| v-for="repo of getReposForLicense(license)" | ||
| :key="repo.url" | ||
| class="flex items-center pl-2 py-2 gap-3 w-full rounded-lg cursor-pointer hover:bg-neutral-50" | ||
| @click="filterByRepo(repo.slug)" | ||
| > | ||
| <lfx-icon | ||
| name="book" | ||
| :size="12" | ||
| class="text-neutral-500 shrink-0" | ||
| /> | ||
| <span | ||
| class="text-neutral-900 text-xs font-medium w-52 overflow-hidden text-ellipsis whitespace-nowrap pr-4" | ||
| >{{ normalizeRepoName(repo) }}</span | ||
| > | ||
| </div> | ||
|
joanagmaia marked this conversation as resolved.
|
||
| </div> | ||
| </template> | ||
| </lfx-popover> | ||
| </template> | ||
| </div> | ||
| <button | ||
| v-if="activeLicenses.length > 5" | ||
| class="text-xs text-brand-500 font-normal self-start" | ||
| @click="isExpanded = !isExpanded" | ||
| > | ||
| {{ isExpanded ? 'Show less' : 'Show more' }} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { storeToRefs } from 'pinia'; | ||
| import { computed, ref } from 'vue'; | ||
| import { useRouter, useRoute } from 'nuxt/app'; | ||
| import { useProjectStore } from '~~/app/components/modules/project/store/project.store'; | ||
| import { normalizeRepoName } from '~/components/shared/utils/helper'; | ||
| import LfxIcon from '~/components/uikit/icon/icon.vue'; | ||
| import LfxTooltip from '~/components/uikit/tooltip/tooltip.vue'; | ||
| import LfxPopover from '~/components/uikit/popover/popover.vue'; | ||
|
|
||
| const { projectRepos, selectedRepositories } = storeToRefs(useProjectStore()); | ||
| const router = useRouter(); | ||
| const route = useRoute(); | ||
|
|
||
| const isExpanded = ref(false); | ||
|
|
||
| const isRepoSelected = computed(() => selectedRepositories.value.length > 0); | ||
|
|
||
| const isSingleRepoProject = computed(() => projectRepos.value.length <= 1); | ||
|
|
||
| const activeRepos = computed(() => (isRepoSelected.value ? selectedRepositories.value : projectRepos.value)); | ||
|
Comment on lines
+112
to
+116
|
||
|
|
||
| const activeLicenses = computed(() => { | ||
| const seen = new Set<string>(); | ||
| const result: string[] = []; | ||
| for (const repo of activeRepos.value) { | ||
| for (const license of repo.licenses || []) { | ||
| if (!seen.has(license) && license !== 'NONE') { | ||
| seen.add(license); | ||
| result.push(license); | ||
| } | ||
| } | ||
| } | ||
| return result.sort((a, b) => (a === 'NOASSERTION' ? 1 : b === 'NOASSERTION' ? -1 : 0)); | ||
| }); | ||
|
|
||
| const displayedLicenses = computed(() => (isExpanded.value ? activeLicenses.value : activeLicenses.value.slice(0, 5))); | ||
|
|
||
| const isSharedByAllRepos = (license: string): boolean => | ||
| projectRepos.value.length > 1 && projectRepos.value.every((repo) => repo.licenses?.includes(license)); | ||
|
|
||
| const getReposForLicense = (license: string) => projectRepos.value.filter((repo) => repo.licenses?.includes(license)); | ||
|
|
||
| const formatLicense = (license: string) => (license === 'NOASSERTION' ? 'Other' : license); | ||
|
|
||
| const filterByRepo = (repoSlug: string) => { | ||
| router.push({ query: { ...route.query, repos: repoSlug } }); | ||
| }; | ||
| </script> | ||
|
|
||
| <script lang="ts"> | ||
| export default { | ||
| name: 'LfxProjectLicenses', | ||
| }; | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.