Skip to content
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

MWPW-163379: Fix edit url from Helix admin API for DA #3314

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/blocks/preflight/img/document-authoring.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions libs/blocks/preflight/panels/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({});

Expand All @@ -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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be simplified?

function getDAEditUrl(sourceUrl) {
  return sourceUrl?.replace('markup:https://content.da.live', 'https://da.live/edit#') || '';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharg1 made the suggested change


async function getStatus(url) {
const adminUrl = getAdminUrl(url, 'status');
const resp = await fetch(adminUrl);
Expand All @@ -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 };
}

Expand Down Expand Up @@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
const editIcon = item.edit && item.edit.includes(DA_DOMAIN) ? 'da-icon' : 'sharepoint-icon';
const editIcon = item.edit?.includes(DA_DOMAIN) ? 'da-icon' : 'sharepoint-icon';

if (!item.url) return undefined;

return html`
<div class="preflight-group-row preflight-group-detail${isChecked}${checkPublishing(item, isFetching)}"
onClick=${(e) => handleChange(e.target, name, idx)}>
<p><a href=${item.url.pathname} target=_blank>${prettyPath(item.url)}</a></p>
<p>${item.edit && html`<a href=${item.edit} class=preflight-edit target=_blank>EDIT</a>`}</p>
<p>${item.edit && html`<a href=${item.edit} class="preflight-edit ${editIcon}" target=_blank>EDIT</a>`}</p>
<p class=preflight-date-wrapper>${item.action === 'preview' ? 'Previewing' : prettyDate(item.preview)}</p>
<p class="preflight-date-wrapper">
${isChecked && disablePublish ? html`<span class=disabled-publish>${disablePublish}</span>` : publishText}
Expand Down Expand Up @@ -240,4 +253,4 @@ export default function General() {
`}
</div>
`;
}
}
sharmeeatadobe marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 9 additions & 3 deletions libs/blocks/preflight/preflight.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
sharmeeatadobe marked this conversation as resolved.
Show resolved Hide resolved
background: url('./img/word-icon.svg');
background-repeat: no-repeat;
}
sharmeeatadobe marked this conversation as resolved.
Show resolved Hide resolved
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');
Expand Down Expand Up @@ -664,4 +670,4 @@ img[data-alt-check]::after {

.lcp-tooltip-modal.show {
visibility: visible;
}
}
sharmeeatadobe marked this conversation as resolved.
Show resolved Hide resolved
Loading