Skip to content

Commit

Permalink
Make the operator section navigable (#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Mar 10, 2020
1 parent f278440 commit e77620e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
19 changes: 18 additions & 1 deletion dashboard/src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("settings", () => {

it("renders settings with reposPerNamespace", () => {
const wrapper = shallow(
<Header {...defaultProps} featureFlags={{ reposPerNamespace: true }} />,
<Header {...defaultProps} featureFlags={{ reposPerNamespace: true, operators: false }} />,
);
const settingsbar = wrapper.find(".header__nav__submenu").first();
const items = settingsbar.find("NavLink").map(p => p.props());
Expand All @@ -64,6 +64,23 @@ describe("settings", () => {
expect(item.to).toBe(expectedItems[index].to);
});
});

it("renders operators link", () => {
const wrapper = shallow(
<Header {...defaultProps} featureFlags={{ reposPerNamespace: true, operators: true }} />,
);
const settingsbar = wrapper.find(".header__nav__submenu").first();
const items = settingsbar.find("NavLink").map(p => p.props());
const expectedItems = [
{ children: "App Repositories", to: "/config/ns/default/repos" },
{ children: "Service Brokers", to: "/config/brokers" },
{ children: "Operators", to: "/operators/ns/default" },
];
items.forEach((item, index) => {
expect(item.children).toBe(expectedItems[index].children);
expect(item.to).toBe(expectedItems[index].to);
});
});
});

it("updates state when the path changes", () => {
Expand Down
9 changes: 7 additions & 2 deletions dashboard/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface IHeaderProps {
setNamespace: (ns: string) => void;
createNamespace: (ns: string) => Promise<boolean>;
getNamespace: (ns: string) => void;
featureFlags: { reposPerNamespace: boolean };
featureFlags: { reposPerNamespace: boolean; operators: boolean };
}

interface IHeaderState {
Expand All @@ -34,7 +34,7 @@ interface IHeaderState {

class Header extends React.Component<IHeaderProps, IHeaderState> {
public static defaultProps = {
featureFlags: { reposPerNamespace: false },
featureFlags: { reposPerNamespace: false, operators: false },
};

// Defines the route
Expand Down Expand Up @@ -148,6 +148,11 @@ class Header extends React.Component<IHeaderProps, IHeaderState> {
<li role="none">
<NavLink to="/config/brokers">Service Brokers</NavLink>
</li>
{this.props.featureFlags.operators && (
<li role="none">
<NavLink to={`/operators/ns/${namespace.current}`}>Operators</NavLink>
</li>
)}
</ul>
</li>
<li>
Expand Down

0 comments on commit e77620e

Please sign in to comment.