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

Fix broken 'Go to location' link in Import Search #4175

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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',
Copy link
Member

@marcellamaki marcellamaki Jun 23, 2023

Choose a reason for hiding this comment

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

why is this deleted here? this is a curious question not an implication that "it shouldn't be" :)

Copy link
Member Author

Choose a reason for hiding this comment

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

By removing this from the map, it prevents the parent from being overwritten in convertContentNodeResponse, because it's now manually being set.

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