Skip to content

Commit 400f0de

Browse files
Feedback / pre-release notice (#340)
Co-authored-by: Grace <145345672+microbit-grace@users.noreply.github.com>
1 parent 3d92b45 commit 400f0de

File tree

9 files changed

+160
-43
lines changed

9 files changed

+160
-43
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@microbit-foundation:registry=https://npm.pkg.github.com/microbit-foundation

lang/ui.en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,10 @@
659659
"defaultMessage": "Edit in MakeCode",
660660
"description": "Edit in MakeCode button text"
661661
},
662+
"feedback": {
663+
"defaultMessage": "Feedback",
664+
"description": "Action to open a feedback dialog"
665+
},
662666
"footer.connectButton": {
663667
"defaultMessage": "Connect",
664668
"description": ""
@@ -779,10 +783,6 @@
779783
"defaultMessage": "Project loaded",
780784
"description": "Toast when a new project is loaded"
781785
},
782-
"prototype.warning": {
783-
"defaultMessage": "This is a prototype version and is subject to change without notice",
784-
"description": ""
785-
},
786786
"reconnectFailed.bluetooth1": {
787787
"defaultMessage": "The connection to the micro:bit could not be re-established.",
788788
"description": ""

src/components/DefaultPageLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import HelpMenu from "./HelpMenu";
2929
import LanguageMenuItem from "./LanguageMenuItem";
3030
import LoadProjectMenuItem from "./LoadProjectMenuItem";
3131
import OpenButton from "./OpenButton";
32-
import PrototypeVersionWarning from "./PrototypeVersionWarning";
32+
import PreReleaseNotice from "./PreReleaseNotice";
3333
import SaveDialogs from "./SaveDialogs";
3434
import SettingsMenu from "./SettingsMenu";
3535
import ToolbarMenu from "./ToolbarMenu";
@@ -196,7 +196,7 @@ const DefaultPageLayout = ({
196196
</>
197197
}
198198
/>
199-
{flags.prototypeWarning && <PrototypeVersionWarning />}
199+
{flags.preReleaseNotice && <PreReleaseNotice />}
200200
<Flex flexGrow={1} flexDir="column">
201201
{children}
202202
</Flex>

src/components/FeedbackForm.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* (c) 2021, Micro:bit Educational Foundation and contributors
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
import {
7+
Modal,
8+
ModalBody,
9+
ModalContent,
10+
ModalOverlay,
11+
ModalCloseButton,
12+
} from "@chakra-ui/modal";
13+
import { useEffect, useRef } from "react";
14+
15+
interface FeedbackFormProps {
16+
isOpen: boolean;
17+
onClose: () => void;
18+
finalFocusRef?: React.RefObject<HTMLButtonElement>;
19+
}
20+
21+
/**
22+
* Temporary embedded Jotform for the alpha release.
23+
*/
24+
const FeedbackForm = ({
25+
isOpen,
26+
onClose,
27+
finalFocusRef = undefined,
28+
}: FeedbackFormProps) => {
29+
const iframeRef = useRef<HTMLIFrameElement>(null);
30+
useEffect(() => {
31+
const listener = (message: MessageEvent) => {
32+
if (
33+
message.origin === "https://form.jotform.com" &&
34+
typeof message.data === "string"
35+
) {
36+
const args = message.data.split(":");
37+
// There are many other cases in their big blob of script
38+
// but I think this is all we need to care about.
39+
if (args[0] === "setHeight" && iframeRef.current) {
40+
iframeRef.current.style.height = args[1] + "px";
41+
}
42+
}
43+
};
44+
window.addEventListener("message", listener);
45+
return () => {
46+
window.removeEventListener("message", listener);
47+
};
48+
});
49+
return (
50+
<Modal
51+
isOpen={isOpen}
52+
onClose={onClose}
53+
size="2xl"
54+
finalFocusRef={finalFocusRef}
55+
>
56+
<ModalOverlay>
57+
<ModalContent>
58+
<ModalCloseButton />
59+
<ModalBody>
60+
<iframe
61+
ref={iframeRef}
62+
title="Feedback"
63+
src="https://form.jotform.com/242763044737359"
64+
frameBorder="0"
65+
height="620px"
66+
width="100%"
67+
scrolling="no"
68+
/>
69+
</ModalBody>
70+
</ModalContent>
71+
</ModalOverlay>
72+
</Modal>
73+
);
74+
};
75+
76+
export default FeedbackForm;

src/components/HelpMenu.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import { useRef } from "react";
1313
import { MdOutlineCookie } from "react-icons/md";
1414
import {
1515
RiExternalLinkLine,
16+
RiFeedbackLine,
1617
RiInformationLine,
1718
RiQuestionLine,
1819
} from "react-icons/ri";
1920
import { FormattedMessage, useIntl } from "react-intl";
21+
import FeedbackForm from "./FeedbackForm";
2022
import { useDeployment } from "../deployment";
2123
import AboutDialog from "./AboutDialog";
2224

@@ -29,17 +31,21 @@ interface HelpMenuProps {
2931
*/
3032
const HelpMenu = ({ isMobile, ...rest }: HelpMenuProps) => {
3133
const aboutDialogDisclosure = useDisclosure();
34+
const feedbackDisclosure = useDisclosure();
3235
const intl = useIntl();
3336
const MenuButtonRef = useRef(null);
3437
const deployment = useDeployment();
35-
3638
return (
3739
<Box display={isMobile ? { base: "block", lg: "none" } : undefined}>
3840
<AboutDialog
3941
isOpen={aboutDialogDisclosure.isOpen}
4042
onClose={aboutDialogDisclosure.onClose}
4143
finalFocusRef={MenuButtonRef}
4244
/>
45+
<FeedbackForm
46+
isOpen={feedbackDisclosure.isOpen}
47+
onClose={feedbackDisclosure.onClose}
48+
/>
4349
<Menu {...rest}>
4450
<MenuButton
4551
as={IconButton}
@@ -69,6 +75,12 @@ const HelpMenu = ({ isMobile, ...rest }: HelpMenuProps) => {
6975
>
7076
<FormattedMessage id="help-support" />
7177
</MenuItem>
78+
<MenuItem
79+
icon={<RiFeedbackLine />}
80+
onClick={feedbackDisclosure.onOpen}
81+
>
82+
<FormattedMessage id="feedback" />
83+
</MenuItem>
7284
<MenuDivider />
7385
</>
7486
)}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* (c) 2021, Micro:bit Educational Foundation and contributors
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
import { Button } from "@chakra-ui/button";
7+
import { Flex, HStack, Text } from "@chakra-ui/layout";
8+
import { useDisclosure } from "@chakra-ui/react";
9+
import { RiFeedbackFill } from "react-icons/ri";
10+
import FeedbackForm from "./FeedbackForm";
11+
import { FormattedMessage } from "react-intl";
12+
13+
const PreReleaseNotice = () => {
14+
const feedbackDialogDisclosure = useDisclosure();
15+
return (
16+
<>
17+
<FeedbackForm
18+
isOpen={feedbackDialogDisclosure.isOpen}
19+
onClose={feedbackDialogDisclosure.onClose}
20+
/>
21+
<Flex
22+
bgColor="gray.800"
23+
color="white"
24+
p={1}
25+
pl={3}
26+
pr={3}
27+
justifyContent="center"
28+
gap={8}
29+
as="section"
30+
aria-label="Release information"
31+
role="region"
32+
>
33+
<Text fontSize="sm" textAlign="center" fontWeight="semibold" p={1}>
34+
This is a beta version and is subject to change without notice
35+
</Text>
36+
<HStack>
37+
<Button
38+
leftIcon={<RiFeedbackFill />}
39+
variant="link"
40+
color="white"
41+
colorScheme="whiteAlpha"
42+
fontWeight="bold"
43+
size="xs"
44+
p={1}
45+
onClick={feedbackDialogDisclosure.onOpen}
46+
>
47+
<FormattedMessage id="feedback" />
48+
</Button>
49+
</HStack>
50+
</Flex>
51+
</>
52+
);
53+
};
54+
55+
export default PreReleaseNotice;

src/components/PrototypeVersionWarning.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/flags.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export type Flag =
1616
*/
1717
| "devtools"
1818
/**
19-
* Flag to add a prototype warning. Enabled for staging site and production stages.
19+
* Flag to add a beta warning. Enabled for review and staging site stages.
2020
*/
21-
| "prototypeWarning"
21+
| "preReleaseNotice"
2222
/**
2323
* Example flags used for testing.
2424
*/
@@ -33,7 +33,7 @@ interface FlagMetadata {
3333
const allFlags: FlagMetadata[] = [
3434
// Alphabetical order.
3535
{ name: "devtools", defaultOnStages: ["local"] },
36-
{ name: "prototypeWarning", defaultOnStages: ["staging", "production"] },
36+
{ name: "preReleaseNotice", defaultOnStages: ["review", "staging"] },
3737
{ name: "exampleOptInA", defaultOnStages: ["review", "staging"] },
3838
{ name: "exampleOptInB", defaultOnStages: [] },
3939
];

src/messages/ui.en.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,12 @@
11451145
"value": "Edit in MakeCode"
11461146
}
11471147
],
1148+
"feedback": [
1149+
{
1150+
"type": 0,
1151+
"value": "Feedback"
1152+
}
1153+
],
11481154
"footer.connectButton": [
11491155
{
11501156
"type": 0,
@@ -1331,12 +1337,6 @@
13311337
"value": "Project loaded"
13321338
}
13331339
],
1334-
"prototype.warning": [
1335-
{
1336-
"type": 0,
1337-
"value": "This is a prototype version and is subject to change without notice"
1338-
}
1339-
],
13401340
"reconnectFailed.bluetooth1": [
13411341
{
13421342
"type": 0,

0 commit comments

Comments
 (0)