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: avoid reference to missing panel in root card #8297

Merged
merged 1 commit into from
Apr 7, 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
10 changes: 7 additions & 3 deletions lib/ProductOpener/KnowledgePanels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,15 @@ sub create_knowledge_panels ($product_ref, $target_lc, $target_cc, $options_ref)

create_health_card_panel($product_ref, $target_lc, $target_cc, $options_ref);
create_environment_card_panel($product_ref, $target_lc, $target_cc, $options_ref);
create_contribution_card_panel($product_ref, $target_lc, $target_cc, $options_ref);
my $has_contribution_card = create_contribution_card_panel($product_ref, $target_lc, $target_cc, $options_ref);

# Create the root panel that contains the panels we want to show directly on the product page
create_panel_from_json_template("root", "api/knowledge-panels/root.tt.json",
{}, $product_ref, $target_lc, $target_cc, $options_ref);
create_panel_from_json_template(
"root",
"api/knowledge-panels/root.tt.json",
{has_contribution_card => $has_contribution_card},
$product_ref, $target_lc, $target_cc, $options_ref
);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/KnowledgePanelsContribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sub create_contribution_card_panel ($product_ref, $target_lc, $target_cc, $optio
"api/knowledge-panels/contribution/contribution_card.tt.json",
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref);
}
return;
return !!@panels;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest return scalar @panels

}

# private sub to add tag names to data_quality_tags_by_actions: we just iterate to add tag name
Expand Down
14 changes: 8 additions & 6 deletions templates/api/knowledge-panels/root.tt.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"panel_element": {
"panel_id": "environment_card",
},
},
{
"element_type": "panel",
"panel_element": {
"panel_id": "contribution_card",
},
},
[% IF panel.has_contribution_card %]
{
"element_type": "panel",
"panel_element": {
"panel_id": "contribution_card",
},
},
[% END %]
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -1818,12 +1818,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2142,12 +2142,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,12 +1141,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,12 +1141,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1819,12 +1819,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2143,12 +2143,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,12 +1142,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,12 +1142,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,6 @@
"panel_element" : {
"panel_id" : "environment_card"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "contribution_card"
}
}
],
"expanded" : true,
Expand Down