Skip to content

Commit

Permalink
chore: Remove footer and move links to status bar MAASENG-2058 (#5193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndv99 committed Oct 13, 2023
1 parent 87d2ad3 commit 407743f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 141 deletions.
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" };

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">
<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

0 comments on commit 407743f

Please sign in to comment.