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

chore: Remove footer and move links to status bar MAASENG-2058 #5193

Merged
merged 5 commits into from
Oct 13, 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
71 changes: 0 additions & 71 deletions src/app/base/components/Footer/Footer.test.tsx

This file was deleted.

65 changes: 0 additions & 65 deletions src/app/base/components/Footer/Footer.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/app/base/components/Footer/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/app/base/components/PageContent/PageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { matchPath, useLocation } from "react-router-dom-v5-compat";

import AppSidePanel from "../AppSidePanel";
import ErrorBoundary from "../ErrorBoundary/ErrorBoundary";
import Footer from "../Footer";
import MainContentSection from "../MainContentSection";
import SecondaryNavigation from "../SecondaryNavigation";

Expand Down Expand Up @@ -78,8 +77,6 @@ const PageContent = ({
>
<ErrorBoundary>{children}</ErrorBoundary>
</MainContentSection>
<hr />
<Footer />
</div>
</main>
<AppSidePanel content={sidePanelContent} title={sidePanelTitle} />
Expand Down
50 changes: 50 additions & 0 deletions src/app/base/components/StatusBar/StatusBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
import { screen, renderWithMockStore } from "testing/utils";

let state: RootState;
const originalEnv = process.env;

beforeEach(() => {
jest.useFakeTimers("modern");
// Thu, 31 Dec. 2020 23:00:00 UTC
Expand All @@ -40,6 +42,7 @@ beforeEach(() => {

afterEach(() => {
jest.useRealTimers();
process.env = originalEnv;
});

it("can show if a machine is currently commissioning", () => {
Expand Down Expand Up @@ -208,3 +211,50 @@ it("displays last image sync timestamp for a rack or region+rack controller", ()
`Last image sync: ${controller.last_image_sync}`
);
});

it("displays the feedback link when analytics enabled and not in development environment", () => {
process.env = { ...originalEnv, NODE_ENV: "production" };
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these changes to process.env persist beyond these tests? I would suggest reverting it after each test in this suite is run to prevent it from causing problems elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, thanks for spotting this. Will follow up with a commit to reset this after each test


state.config = configStateFactory({
items: [
...state.config.items,
configFactory({ name: ConfigNames.ENABLE_ANALYTICS, value: true }),
],
});

renderWithMockStore(<StatusBar />, { state });

expect(
screen.getByRole("button", { name: "Give feedback" })
).toBeInTheDocument();
});

it("hides the feedback link when analytics disabled", () => {
process.env = { ...originalEnv, NODE_ENV: "production" };
state.config = configStateFactory({
items: [
...state.config.items,
configFactory({ name: ConfigNames.ENABLE_ANALYTICS, value: false }),
],
});
renderWithMockStore(<StatusBar />, { state });

expect(
screen.queryByRole("button", { name: "Give feedback" })
).not.toBeInTheDocument();
});

it("hides the feedback link in development environment", () => {
process.env = { ...originalEnv, NODE_ENV: "development" };
state.config = configStateFactory({
items: [
...state.config.items,
configFactory({ name: ConfigNames.ENABLE_ANALYTICS, value: true }),
],
});
renderWithMockStore(<StatusBar />, { state });

expect(
screen.queryByRole("button", { name: "Give feedback" })
).not.toBeInTheDocument();
});
34 changes: 34 additions & 0 deletions src/app/base/components/StatusBar/StatusBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { ReactNode } from "react";

import { Button, Link } from "@canonical/react-components";
import { useSelector } from "react-redux";

import { useUsabilla } from "app/base/hooks";
import configSelectors from "app/store/config/selectors";
import controllerSelectors from "app/store/controller/selectors";
import {
Expand Down Expand Up @@ -53,6 +55,7 @@ export const StatusBar = (): JSX.Element | null => {
const activeMachine = useSelector(machineSelectors.active);
const version = useSelector(versionSelectors.get);
const maasName = useSelector(configSelectors.maasName);
const allowUsabilla = useUsabilla();

if (!(maasName && version)) {
return null;
Expand Down Expand Up @@ -95,6 +98,37 @@ export const StatusBar = (): JSX.Element | null => {
:&nbsp;
<span data-testid="status-bar-version">{version}</span>
</div>
<ul className="p-inline-list--middot u-no-margin--bottom">
<li className="p-inline-list__item">
<Link
href={`${process.env.REACT_APP_BASENAME}/docs/`}
rel="noreferrer"
target="_blank"
>
Local documentation
</Link>
</li>
<li className="p-inline-list__item">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these links open in place or in a new tab? Please advise @dgtlntv

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1. I copied the original implementation directly, which opens them in the same tab, but some UX guidance would be really helpful here

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I'll go ahead and approve this pending UX review

Copy link
Member

Choose a reason for hiding this comment

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

Good point! I think opening in a new tab would be better!

<Link
href="https://www.ubuntu.com/legal"
rel="noreferrer"
target="_blank"
>
Legal information
</Link>
</li>
{allowUsabilla ? (
<li className="p-inline-list__item">
<Button
appearance="link"
className="u-no-margin u-no-padding"
onClick={() => window.usabilla_live("click")}
>
Give feedback
</Button>
</li>
) : null}
</ul>
{status && (
<div
className="p-status-bar__secondary u-flex--grow u-flex--wrap"
Expand Down
2 changes: 1 addition & 1 deletion src/scss/_patterns_status-bar.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@mixin maas-status-bar {
.p-status-bar {
background-color: #cce0f5;
background-color: #f7f7f7;
bottom: 0;
left: 0;
padding: $spv--small 0;
Expand Down