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 subnets hightlight #1245

Merged
merged 2 commits into from
Jun 12, 2020
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
6 changes: 3 additions & 3 deletions shared/src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const Header = ({
window.ga("set", "dimension2", uuid);

const sendPageview = () => {
const path = window.location.pathname + window.location.hash;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use /l/ instead of /#/ so I've removed that as part of the url.

const path = window.location.pathname + window.location.search;
window.ga("send", "pageview", path);
};
if (rootScope) {
Expand Down Expand Up @@ -179,7 +179,7 @@ export const Header = ({

const generateNavItems = (links) => {
const hardwareLinks = links.filter((link) => link.inHardwareMenu);
const path = location.pathname + location.hash;
const path = location.pathname + location.search;

const linkItems = links.map((link) => (
<li
Expand Down Expand Up @@ -333,7 +333,7 @@ Header.propTypes = {
enableAnalytics: PropTypes.bool,
generateLocalLink: PropTypes.func,
location: PropTypes.shape({
hash: PropTypes.string,
search: PropTypes.string,
pathname: PropTypes.string.isRequired,
}).isRequired,
logout: PropTypes.func.isRequired,
Expand Down
24 changes: 22 additions & 2 deletions shared/src/components/Header/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ describe("Header", () => {
basename="/MAAS"
completedIntro={true}
location={{
hash: "l/devices",
pathname: "/MAAS/",
pathname: "/MAAS/l/devices",
}}
logout={jest.fn()}
/>
Expand All @@ -125,4 +124,25 @@ describe("Header", () => {
expect(selected.exists()).toBe(true);
expect(selected.text()).toEqual("Devices");
});

it("can highlight a url with a query param", () => {
const wrapper = shallow(
<Header
authUser={{
is_superuser: true,
username: "koala",
}}
basename="/MAAS"
completedIntro={true}
location={{
search: "?by=fabric",
pathname: "/MAAS/l/networks",
}}
logout={jest.fn()}
/>
);
const selected = wrapper.find(".p-navigation__link.is-selected");
expect(selected.exists()).toBe(true);
expect(selected.text()).toEqual("Subnets");
});
});