From 58d97958b59bd36d20a78bf9bbae840558b91cce Mon Sep 17 00:00:00 2001 From: Sharmee Date: Thu, 5 Dec 2024 18:18:46 +0530 Subject: [PATCH 1/4] MWPW-163379: Fix edit url from Helix admin API for DA --- .../preflight/img/document-authoring.svg | 6 ++++++ libs/blocks/preflight/panels/general.js | 19 ++++++++++++++++--- libs/blocks/preflight/preflight.css | 12 +++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 libs/blocks/preflight/img/document-authoring.svg diff --git a/libs/blocks/preflight/img/document-authoring.svg b/libs/blocks/preflight/img/document-authoring.svg new file mode 100644 index 0000000000..6543cb8af3 --- /dev/null +++ b/libs/blocks/preflight/img/document-authoring.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/libs/blocks/preflight/panels/general.js b/libs/blocks/preflight/panels/general.js index 603cb72561..c32d94e81a 100644 --- a/libs/blocks/preflight/panels/general.js +++ b/libs/blocks/preflight/panels/general.js @@ -7,6 +7,7 @@ const NOT_FOUND = { preview: { lastModified: DEF_NOT_FOUND }, live: { lastModified: DEF_NOT_FOUND }, }; +const DA_DOMAIN = 'da.live'; const content = signal({}); @@ -17,6 +18,14 @@ function getAdminUrl(url, type) { return type === 'status' ? `${base}?editUrl=auto` : base; } +function getDAEditUrl(sourceUrl) { + if (!sourceUrl) { + return ''; + } + const daEditUrl = sourceUrl.replace('markup:https://content.da.live', 'https://da.live/edit#'); + return daEditUrl; +} + async function getStatus(url) { const adminUrl = getAdminUrl(url, 'status'); const resp = await fetch(adminUrl); @@ -25,7 +34,10 @@ async function getStatus(url) { const preview = json.preview.lastModified || DEF_NEVER; const live = json.live.lastModified || DEF_NEVER; const publish = await userCanPublishPage(json, false); - const edit = json.edit.url; + let edit = json.edit.url; + if (!json.edit.url && json.preview.sourceLocation && json.preview.sourceLocation.includes(DA_DOMAIN)) { + edit = getDAEditUrl(json.preview.sourceLocation); + } return { url, edit, preview, live, publish }; } @@ -165,13 +177,14 @@ function Item({ name, item, idx }) { const { publishText, disablePublish } = usePublishProps(item); const isChecked = item.checked ? ' is-checked' : ''; const isFetching = item.edit ? '' : ' is-fetching'; + const editIcon = item.edit && item.edit.includes(DA_DOMAIN) ? 'da-icon' : 'sharepoint-icon'; if (!item.url) return undefined; return html`
handleChange(e.target, name, idx)}>

${prettyPath(item.url)}

-

${item.edit && html`EDIT`}

+

${item.edit && html`EDIT`}

${item.action === 'preview' ? 'Previewing' : prettyDate(item.preview)}

${isChecked && disablePublish ? html`${disablePublish}` : publishText} @@ -240,4 +253,4 @@ export default function General() { `}

`; -} +} \ No newline at end of file diff --git a/libs/blocks/preflight/preflight.css b/libs/blocks/preflight/preflight.css index 5c2c2f7e78..31cccd0504 100644 --- a/libs/blocks/preflight/preflight.css +++ b/libs/blocks/preflight/preflight.css @@ -170,13 +170,19 @@ p.preflight-content-heading-edit { } a.preflight-edit { - background: url('./img/word-icon.svg'); - background-repeat: no-repeat; display: block; text-indent: -1000px; overflow: hidden; height: 32px; } +a.preflight-edit.sharepoint-icon { + background: url('./img/word-icon.svg'); + background-repeat: no-repeat; +} +a.preflight-edit.da-icon { + background: url('./img/document-authoring.svg'); + background-repeat: no-repeat; +} .preflight-group-row.preflight-group-detail.not-found::before { background-image: url('./img/red-error.svg'); @@ -664,4 +670,4 @@ img[data-alt-check]::after { .lcp-tooltip-modal.show { visibility: visible; -} +} \ No newline at end of file From fbac35b8c6d98fef3b4c0d20bea8d0445d1110a3 Mon Sep 17 00:00:00 2001 From: Sharmee Date: Thu, 5 Dec 2024 19:07:34 +0530 Subject: [PATCH 2/4] MWPW-163379 : Addressing review comments --- libs/blocks/preflight/panels/general.js | 2 +- libs/blocks/preflight/preflight.css | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/blocks/preflight/panels/general.js b/libs/blocks/preflight/panels/general.js index c32d94e81a..ad3a7be08f 100644 --- a/libs/blocks/preflight/panels/general.js +++ b/libs/blocks/preflight/panels/general.js @@ -253,4 +253,4 @@ export default function General() { `} `; -} \ No newline at end of file +} diff --git a/libs/blocks/preflight/preflight.css b/libs/blocks/preflight/preflight.css index 31cccd0504..c704e7d4bf 100644 --- a/libs/blocks/preflight/preflight.css +++ b/libs/blocks/preflight/preflight.css @@ -175,10 +175,12 @@ a.preflight-edit { overflow: hidden; height: 32px; } + a.preflight-edit.sharepoint-icon { background: url('./img/word-icon.svg'); background-repeat: no-repeat; } + a.preflight-edit.da-icon { background: url('./img/document-authoring.svg'); background-repeat: no-repeat; @@ -670,4 +672,4 @@ img[data-alt-check]::after { .lcp-tooltip-modal.show { visibility: visible; -} \ No newline at end of file +} From 1ef498d2eba5225c55aacf645e1eb8d0dd721d08 Mon Sep 17 00:00:00 2001 From: Sharmee Date: Thu, 5 Dec 2024 23:43:50 +0530 Subject: [PATCH 3/4] MWPW: updating with review comments --- libs/blocks/preflight/panels/general.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/blocks/preflight/panels/general.js b/libs/blocks/preflight/panels/general.js index ad3a7be08f..e1a326a430 100644 --- a/libs/blocks/preflight/panels/general.js +++ b/libs/blocks/preflight/panels/general.js @@ -19,11 +19,7 @@ function getAdminUrl(url, type) { } function getDAEditUrl(sourceUrl) { - if (!sourceUrl) { - return ''; - } - const daEditUrl = sourceUrl.replace('markup:https://content.da.live', 'https://da.live/edit#'); - return daEditUrl; + return sourceUrl?.replace('markup:https://content.da.live', 'https://da.live/edit#') || ''; } async function getStatus(url) { @@ -35,7 +31,10 @@ async function getStatus(url) { const live = json.live.lastModified || DEF_NEVER; const publish = await userCanPublishPage(json, false); let edit = json.edit.url; - if (!json.edit.url && json.preview.sourceLocation && json.preview.sourceLocation.includes(DA_DOMAIN)) { + if ( + !json.edit.url + && json.preview.sourceLocation + && json.preview.sourceLocation.includes(DA_DOMAIN)) { edit = getDAEditUrl(json.preview.sourceLocation); } return { url, edit, preview, live, publish }; From 3973197665c642b40f0990a7a96c1cadf756e7a6 Mon Sep 17 00:00:00 2001 From: Sharmee Date: Fri, 13 Dec 2024 15:23:15 +0530 Subject: [PATCH 4/4] MWPW-163379: Implementing suggestions --- libs/blocks/preflight/panels/general.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libs/blocks/preflight/panels/general.js b/libs/blocks/preflight/panels/general.js index e1a326a430..b34f0f7d7c 100644 --- a/libs/blocks/preflight/panels/general.js +++ b/libs/blocks/preflight/panels/general.js @@ -18,10 +18,6 @@ function getAdminUrl(url, type) { return type === 'status' ? `${base}?editUrl=auto` : base; } -function getDAEditUrl(sourceUrl) { - return sourceUrl?.replace('markup:https://content.da.live', 'https://da.live/edit#') || ''; -} - async function getStatus(url) { const adminUrl = getAdminUrl(url, 'status'); const resp = await fetch(adminUrl); @@ -30,13 +26,10 @@ async function getStatus(url) { const preview = json.preview.lastModified || DEF_NEVER; const live = json.live.lastModified || DEF_NEVER; const publish = await userCanPublishPage(json, false); - let edit = json.edit.url; - if ( - !json.edit.url - && json.preview.sourceLocation - && json.preview.sourceLocation.includes(DA_DOMAIN)) { - edit = getDAEditUrl(json.preview.sourceLocation); - } + const { sourceLocation } = json.preview; + const edit = json.edit?.url + || (sourceLocation?.includes(DA_DOMAIN) && sourceLocation?.replace('markup:https://content.da.live', 'https://da.live/edit#')) + || ''; return { url, edit, preview, live, publish }; }