Skip to content

Commit

Permalink
Merge pull request #4175 from bjester/go-to-location
Browse files Browse the repository at this point in the history
Fix broken 'Go to location' link in Import Search
  • Loading branch information
bjester authored Jun 26, 2023
2 parents da46564 + 5525b86 commit 3084d31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export function loadContentNode(context, id) {
* @param {string} id
* @param {string} nodeId - Note: this is `node_id` not `id`
* @param {string} rootId
* @param {string} parent - The `id` not `node_id` of the parent
* @return {Promise<{}>}
*/
export async function loadPublicContentNode(context, { id, nodeId, rootId }) {
export async function loadPublicContentNode(context, { id, nodeId, rootId, parent }) {
const publicNode = await publicApi.getContentNode(nodeId);
const localNode = publicApi.convertContentNodeResponse(id, rootId, publicNode);
const localNode = publicApi.convertContentNodeResponse(id, rootId, parent, publicNode);
context.commit('ADD_CONTENTNODE', localNode);
return localNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function fetchResourceSearchResults(context, params) {
id: node.id,
nodeId: node.node_id,
rootId: node.root_id,
parent: node.parent,
},
{ root: true }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const CONTENT_NODE_FIELD_MAP = {
node_id: 'id',
content_id: 'content_id',
channel_id: 'channel_id',
parent: 'parent',
title: 'title',
description: 'description',
kind: 'kind',
Expand Down Expand Up @@ -108,16 +107,19 @@ const CONTENT_NODE_FIELD_MAP = {
* Convert a content node from the public API into a content node for the Studio frontend
* @param {string} id - the actual ID of the node on Studio's side
* @param {string} root_id - the root content node ID
* @param {string} parent - the parent's ID
* @param {PublicContentNode} publicNode
* @return {{id}}
*/
export function convertContentNodeResponse(id, root_id, publicNode) {
export function convertContentNodeResponse(id, root_id, parent, publicNode) {
const contentNode = {
// the public API does not return the actual id, but 'node_id' as the id, so this requires
// us to know what the actual id is
id,
// The public API returns the channel ID as the root_id
root_id,
// the public API does not return the actual id, but 'node_id' as the id
parent,
};

// Convert the response node into a content node
Expand All @@ -130,7 +132,7 @@ export function convertContentNodeResponse(id, root_id, publicNode) {
}

// If the parent is the channel, then set the parent to the root_id
if (contentNode.parent === contentNode.channel_id) {
if (publicNode.parent === publicNode.channel_id) {
contentNode.parent = root_id;
}
return contentNode;
Expand Down

0 comments on commit 3084d31

Please sign in to comment.