From 3e135987c8b7771d0f8824435fca368110c8e4db Mon Sep 17 00:00:00 2001 From: TyroneAEM <147942284+TyroneAEM@users.noreply.github.com> Date: Thu, 14 Mar 2024 09:37:40 -0500 Subject: [PATCH] ASSETS-88890 : Hide "Edit in Express" icon for Licensed Content (#45) * scripts/metadata.js : Added function isLicensedContent(assetJSON) which returns true for licensed content, and false for no licensed content blocks/adp-asset-details-panel/adp-asset-details-panel.js : Hides the express button for licensed content * /blocks/adp-asset-details-modal/adp-asset-details-modal.js: Hides the express button for licensed content --- blocks/adp-asset-details-modal/adp-asset-details-modal.js | 5 +++-- blocks/adp-asset-details-panel/adp-asset-details-panel.js | 5 +++-- scripts/metadata.js | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/blocks/adp-asset-details-modal/adp-asset-details-modal.js b/blocks/adp-asset-details-modal/adp-asset-details-modal.js index f8b47391..36d923a0 100644 --- a/blocks/adp-asset-details-modal/adp-asset-details-modal.js +++ b/blocks/adp-asset-details-modal/adp-asset-details-modal.js @@ -9,7 +9,7 @@ import { import { closeModal } from '../../scripts/shared.js'; import { authorizeURL, getAssetMetadata } from '../../scripts/polaris.js'; import { - getAssetName, getAssetMimeType, getAssetTitle, + getAssetName, getAssetMimeType, getAssetTitle, isLicensedContent, } from '../../scripts/metadata.js'; // eslint-disable-next-line import/no-cycle import { disableActionButtons } from '../adp-asset-details-panel/adp-asset-details-panel.js'; @@ -96,7 +96,8 @@ function createHeaderPanel(modal) { // ensure express button only shows for valid asset types const expressBtn = modal.querySelector('.action-edit-asset'); const validCheck = fileValidity(format); - if (isCCEConfigured() && validCheck.isValid) { + if (isCCEConfigured() && validCheck.isValid && !isLicensedContent(assetJSON)) { + //Only show express button for content that is not licensed. expressBtn.classList.remove('hidden'); } else if (!expressBtn.classList.contains('hidden')) { expressBtn.classList.add('hidden'); diff --git a/blocks/adp-asset-details-panel/adp-asset-details-panel.js b/blocks/adp-asset-details-panel/adp-asset-details-panel.js index 4e35bb06..45b693fd 100644 --- a/blocks/adp-asset-details-panel/adp-asset-details-panel.js +++ b/blocks/adp-asset-details-panel/adp-asset-details-panel.js @@ -6,7 +6,7 @@ import { openDownloadModal } from '../adp-download-modal/adp-download-modal.js'; import { openAssetDetailsModal } from '../adp-asset-details-modal/adp-asset-details-modal.js'; import { fetchMetadataAndCreateHTML } from '../../scripts/metadata-html-builder.js'; import { - getAssetMimeType, getAssetTitle, getAssetName, getAssetHeight, getAssetWidth, + getAssetMimeType, getAssetTitle, getAssetName, getAssetHeight, getAssetWidth, isLicensedContent, } from '../../scripts/metadata.js'; import { getAssetMetadata, @@ -74,7 +74,8 @@ export async function openAssetDetailsPanel(assetId, resultsManagerObj) { // ensure express button only shows for valid asset types const expressBtn = assetDetailsPanel.querySelector('.action-edit-asset'); const validCheck = fileValidity(fileFormat); - if (isCCEConfigured() && validCheck.isValid) { + if (isCCEConfigured() && validCheck.isValid && !isLicensedContent(assetJSON)) { + //Only show express button for content that is not licensed. expressBtn.classList.remove('hidden'); } else if (!expressBtn.classList.contains('hidden')) { expressBtn.classList.add('hidden'); diff --git a/scripts/metadata.js b/scripts/metadata.js index b9e42091..bbd3684c 100644 --- a/scripts/metadata.js +++ b/scripts/metadata.js @@ -180,6 +180,14 @@ export function getAssetSize(assetJSON) { return getMetadataValue('size', assetJSON); } +/** + * Is licensed content + * Returns true for gmo:licensedContent != 'no' + */ +export function isLicensedContent(assetJSON) { + return getMetadataValue('gmo:licensedContent', assetJSON) !== 'no'; +} + /** * Predefined metadata fields that have special handling, can have compound values and a * special formatter.