From ed09ee7d47afb075f5aee52e0383ebf116926469 Mon Sep 17 00:00:00 2001 From: Liana Harris <46411498+LianaHarris360@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:36:13 -0500 Subject: [PATCH 1/2] About Licenses display changes + revise license URL return method to improve security --- .../QuickEditModal/EditSourceModal.vue | 2 - .../__tests__/EditSourceModal.spec.js | 5 -- .../channelEdit/components/edit/EditModal.vue | 6 -- .../frontend/channelEdit/getters.js | 4 - .../frontend/channelEdit/mutations.js | 4 - .../frontend/channelEdit/store.js | 2 - .../views/TreeView/TreeViewBase.vue | 6 -- .../shared/views/AboutLicensesModal.vue | 62 --------------- .../frontend/shared/views/LicenseDropdown.vue | 78 ++++++++++++++----- 9 files changed, 58 insertions(+), 111 deletions(-) delete mode 100644 contentcuration/contentcuration/frontend/shared/views/AboutLicensesModal.vue diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditSourceModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditSourceModal.vue index 523bd1ad11..839f19a896 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditSourceModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditSourceModal.vue @@ -2,7 +2,6 @@
{ generalActions = { showSnackbarSimple: jest.fn(), }; - generalGetters = { - isAboutLicensesModalOpen: () => false, - }; store = new Vuex.Store({ actions: generalActions, - getters: generalGetters, modules: { contentNode: { namespaced: true, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index 655b8fb6e1..2dba69cc0f 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -122,9 +122,6 @@ - - !state.connection.online, }), - ...mapGetters(['isAboutLicensesModalOpen']), ...mapGetters('contentNode', ['getContentNode']), ...mapGetters('currentChannel', ['currentChannel', 'canEdit', 'canManage', 'rootId']), rootNode() { diff --git a/contentcuration/contentcuration/frontend/shared/views/AboutLicensesModal.vue b/contentcuration/contentcuration/frontend/shared/views/AboutLicensesModal.vue deleted file mode 100644 index 2c11725383..0000000000 --- a/contentcuration/contentcuration/frontend/shared/views/AboutLicensesModal.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - \ No newline at end of file diff --git a/contentcuration/contentcuration/frontend/shared/views/LicenseDropdown.vue b/contentcuration/contentcuration/frontend/shared/views/LicenseDropdown.vue index 64b9ac92d8..d70ffff150 100644 --- a/contentcuration/contentcuration/frontend/shared/views/LicenseDropdown.vue +++ b/contentcuration/contentcuration/frontend/shared/views/LicenseDropdown.vue @@ -23,19 +23,38 @@ :class="{ 'with-trailing-input-icon': box }" :attach="attach" @focus="$emit('focus')" - > - - + /> +

+ +

+
+

+ {{ licenseItem.name }} +

+

+ {{ licenseItem.description }} +

+

+ +

+
- import { mapMutations } from 'vuex'; + import RequestForm from '../../settings/pages/Storage/RequestForm.vue'; import { getLicenseValidators, getLicenseDescriptionValidators, @@ -70,9 +89,12 @@ import { LicensesList } from 'shared/leUtils/Licenses'; import { constantsTranslationMixin } from 'shared/mixins'; import DropdownWrapper from 'shared/views/form/DropdownWrapper'; + import { crossComponentTranslator } from 'shared/i18n'; const MIXED_VALUE = 'mixed'; + const allowedHosts = ['creativecommons.org']; + export default { name: 'LicenseDropdown', components: { @@ -114,6 +136,12 @@ default: false, }, }, + data() { + return { + requestFormStrings: crossComponentTranslator(RequestForm), + showAboutLicense: false, + }; + }, computed: { license: { get() { @@ -178,17 +206,30 @@ ? getLicenseDescriptionValidators().map(translateValidator) : []; }, + licences() { + return LicensesList.filter(license => license.id).map(license => ({ + ...license, + name: this.translateConstant(license.license_name), + description: this.translateConstant(license.license_name + '_description'), + })); + }, }, methods: { - ...mapMutations({ - setShowAboutLicenses: 'SET_SHOW_ABOUT_LICENSES', - }), translate(item) { if (item.id === MIXED_VALUE) { return this.$tr('mixed'); } return (item.id && item.id !== '' && this.translateConstant(item.license_name)) || ''; }, + toggleAboutLicenseDisplay() { + this.showAboutLicense = !this.showAboutLicense; + }, + getLicenseUrl(license) { + const url = new URL(license.license_url); + const isCC = allowedHosts.includes(url.hostname); + const language = window.languageCode || 'en'; + return isCC ? `${license.license_url}deed.${language}` : license.license_url; + }, }, $trs: { mixed: 'Mixed', @@ -202,10 +243,6 @@