Skip to content

Add compliance component. #975

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

Merged
merged 7 commits into from
Sep 21, 2022
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _steps:
install_dependencies: &install_dependencies
run: npm ci --cache .npm-cache && sudo npm config set @microbit-foundation:registry https://npm.pkg.github.com/microbit-foundation && sudo npm i -g @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1
install_theme: &install_theme
run: npm config set @microbit-foundation:registry https://npm.pkg.github.com/microbit-foundation && npm install --no-save @microbit-foundation/[email protected].183
run: npm config set @microbit-foundation:registry https://npm.pkg.github.com/microbit-foundation && npm install --no-save @microbit-foundation/[email protected].192
update_version: &update_version
run: npm run ci:update-version
build: &build
Expand Down
1 change: 1 addition & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
html,
body,
#root,
.WorkbenchContainer,
.Workbench {
width: 100%;
/* --ios-vvh set by VisualViewPortCSSVariables on iOS only. */
Expand Down
1 change: 1 addition & 0 deletions src/common/zIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export const splitViewHideButton = 4;
// z-index above the xterm.js's layers (currently 10 but given some margin for increases as it can vary with config)
export const zIndexAboveTerminal = 20;
export const zIndexOverlay = 30;
export const zIndexAboveDialogs = 1500;
8 changes: 8 additions & 0 deletions src/deployment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
*/
import { ReactNode } from "react";
import { IconType } from "react-icons/lib";
import { Logging } from "../logging/logging";

// This is configured via a webpack alias, defaulting to ./default
Expand All @@ -13,6 +14,13 @@ export const deployment: DeploymentConfig = d;
export interface DeploymentConfig {
squareLogo?: ReactNode;
horizontalLogo?: ReactNode;
Compliance?: ({
zIndex,
externalLinkIcon,
}: {
zIndex: number;
externalLinkIcon: IconType;
}) => JSX.Element;

chakraTheme: any;

Expand Down
23 changes: 20 additions & 3 deletions src/workbench/Workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { Box, Flex } from "@chakra-ui/layout";
import { useMediaQuery } from "@chakra-ui/react";
import { ReactNode, useCallback, useEffect, useRef, useState } from "react";
import { RiExternalLinkLine } from "react-icons/ri";
import { useIntl } from "react-intl";
import {
hideSidebarMediaQuery,
Expand All @@ -20,6 +21,8 @@ import {
SplitViewSized,
} from "../common/SplitView";
import { SizedMode } from "../common/SplitView/SplitView";
import { zIndexAboveDialogs } from "../common/zIndex";
import { useDeployment } from "../deployment";
import { ConnectionStatus } from "../device/device";
import { useConnectionStatus } from "../device/device-hooks";
import EditorArea from "../editor/EditorArea";
Expand Down Expand Up @@ -116,9 +119,23 @@ const Workbench = () => {
)}
</Box>
);

const inIframe = () => {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
};
const deployment = useDeployment();
const Compliance = deployment.Compliance ?? (() => null);
return (
<>
<Flex className="WorkbenchContainer" flexDir="column">
{!inIframe() && (
<Compliance
zIndex={zIndexAboveDialogs}
externalLinkIcon={RiExternalLinkLine}
/>
)}
<Flex className="Workbench">
<SplitView
direction="row"
Expand Down Expand Up @@ -161,7 +178,7 @@ const Workbench = () => {
</SplitView>
</Flex>
<Overlay />
</>
</Flex>
);
};

Expand Down