From affeec82f0f868d7e8260896584497dd4ea6465f Mon Sep 17 00:00:00 2001 From: Erb3 <49862976+Erb3@users.noreply.github.com> Date: Mon, 10 Feb 2025 17:37:49 +0100 Subject: [PATCH] License UI redesign + composition API (#3225) * refactor(frontend): revamp license page - Add more understandable UI - Field titles - Field description - Use more semantically correct elements - Make paragraph not a label - Rephrase some parts - Fields no longer jump around - Split SPDX-identifier and license name into two seperate fields, for readability - Sort imports - fmt * feat(frontend): encourage license URL on custom license * refactor(frontend): license page to composition + ts - Move to Vue composition API - Move to TypeScript - Move away from vue-multiselect to the dropdown component - Use `formatProjectType` function for typesafety - Remove unused form error highlighting code - Creating typings for built-in licenses - Move standard licenses to licenses.ts util - There are other license-related utils I want to move there eventually - Fix typo in Project license type definition * chore(frontend): fmt * chore(frontend): fmt * feat(frontend): require URL and name for custom license * refactor(frontend): give license or-later checkbox own row * chore(frontend): fmt --- .../pages/[type]/[id]/settings/license.vue | 474 ++++++++---------- packages/utils/index.ts | 6 +- packages/utils/licenses.ts | 76 +++ packages/utils/types.ts | 3 +- 4 files changed, 299 insertions(+), 260 deletions(-) create mode 100644 packages/utils/licenses.ts diff --git a/apps/frontend/src/pages/[type]/[id]/settings/license.vue b/apps/frontend/src/pages/[type]/[id]/settings/license.vue index aa5e86a48..cd946ad1d 100644 --- a/apps/frontend/src/pages/[type]/[id]/settings/license.vue +++ b/apps/frontend/src/pages/[type]/[id]/settings/license.vue @@ -1,61 +1,128 @@ - diff --git a/packages/utils/index.ts b/packages/utils/index.ts index 42f6495dd..7e2bfa3d1 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -1,8 +1,8 @@ +export * from './billing' export * from './highlight' +export * from './licenses' export * from './parse' export * from './projects' +export * from './types' export * from './users' export * from './utils' -export * from './billing' - -export * from './types' diff --git a/packages/utils/licenses.ts b/packages/utils/licenses.ts new file mode 100644 index 000000000..b8df1e25d --- /dev/null +++ b/packages/utils/licenses.ts @@ -0,0 +1,76 @@ +export interface BuiltinLicense { + friendly: string + short: string + requiresOnlyOrLater?: boolean +} + +export const builtinLicenses: BuiltinLicense[] = [ + { friendly: 'Custom', short: '' }, + { + friendly: 'All Rights Reserved/No License', + short: 'All-Rights-Reserved', + }, + { friendly: 'Apache License 2.0', short: 'Apache-2.0' }, + { + friendly: 'BSD 2-Clause "Simplified" License', + short: 'BSD-2-Clause', + }, + { + friendly: 'BSD 3-Clause "New" or "Revised" License', + short: 'BSD-3-Clause', + }, + { + friendly: 'CC Zero (Public Domain equivalent)', + short: 'CC0-1.0', + }, + { friendly: 'CC-BY 4.0', short: 'CC-BY-4.0' }, + { + friendly: 'CC-BY-SA 4.0', + short: 'CC-BY-SA-4.0', + }, + { + friendly: 'CC-BY-NC 4.0', + short: 'CC-BY-NC-4.0', + }, + { + friendly: 'CC-BY-NC-SA 4.0', + short: 'CC-BY-NC-SA-4.0', + }, + { + friendly: 'CC-BY-ND 4.0', + short: 'CC-BY-ND-4.0', + }, + { + friendly: 'CC-BY-NC-ND 4.0', + short: 'CC-BY-NC-ND-4.0', + }, + { + friendly: 'GNU Affero General Public License v3', + short: 'AGPL-3.0', + requiresOnlyOrLater: true, + }, + { + friendly: 'GNU Lesser General Public License v2.1', + short: 'LGPL-2.1', + requiresOnlyOrLater: true, + }, + { + friendly: 'GNU Lesser General Public License v3', + short: 'LGPL-3.0', + requiresOnlyOrLater: true, + }, + { + friendly: 'GNU General Public License v2', + short: 'GPL-2.0', + requiresOnlyOrLater: true, + }, + { + friendly: 'GNU General Public License v3', + short: 'GPL-3.0', + requiresOnlyOrLater: true, + }, + { friendly: 'ISC License', short: 'ISC' }, + { friendly: 'MIT License', short: 'MIT' }, + { friendly: 'Mozilla Public License 2.0', short: 'MPL-2.0' }, + { friendly: 'zlib License', short: 'Zlib' }, +] as const diff --git a/packages/utils/types.ts b/packages/utils/types.ts index 76962e9e5..7f7892d26 100644 --- a/packages/utils/types.ts +++ b/packages/utils/types.ts @@ -87,8 +87,7 @@ export interface Project { license: { id: string - name - string + name: string url?: string } }