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

Get the welcome video via the deployment rather than the CMS #1157

Merged
merged 1 commit into from
Mar 26, 2024
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm install --no-save @microbit-foundation/[email protected].37 @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1
- run: npm install --no-save @microbit-foundation/[email protected].38 @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1
if: github.repository_owner == 'microbit-foundation'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "Benvingut a l'Editor Python de la micro:bit",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Amplia",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "Willkommen zum micro:bit Python-Editor",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Vergrößern",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,10 @@
"defaultMessage": "Welcome to the micro:bit Python Editor",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Zoom in",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.es-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "Bienvenido al Editor de Python de micro:bit",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Aumentar zoom",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "Bienvenue dans l'éditeur Python micro:bit",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Zoom avant",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "micro:bit Pythonエディターへようこそ",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "拡大",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "micro:bit Python 편집기에 오신 것을 환영합니다",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "글꼴 크게",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "Welkom bij de micro:bit Python Editor",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "Inzoomen",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "欢迎使用 micro:bit Python 编辑器",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "放大",
"description": "Text label for zoom in button"
Expand Down
4 changes: 4 additions & 0 deletions lang/ui.zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,10 @@
"defaultMessage": "歡迎使用 micro:bit Python 編輯器",
"description": "Title for the welcome dialog"
},
"welcome-video-alt": {
"defaultMessage": "video introducing the Python Editor",
"description": "iframe title for the welcome video"
},
"zoom-in-action": {
"defaultMessage": "放大",
"description": "Text label for zoom in button"
Expand Down
63 changes: 20 additions & 43 deletions src/common/YoutubeVideoEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,33 @@
import { AspectRatio, Box, Text } from "@chakra-ui/react";
import Spinner from "./Spinner";
import { AspectRatio, Box } from "@chakra-ui/react";

export interface YoutubeVideo {
alt: string;
attribution: string;
caption: string;
youtubeId: string;
}

interface YoutubeVideoProps {
youTubeVideo: YoutubeVideo | undefined;
alt: string;
youtubeId: string;
}

const YoutubeVideoEmbed = ({ youTubeVideo }: YoutubeVideoProps) => {
const { alt, attribution, caption, youtubeId } = youTubeVideo || {};
const YoutubeVideoEmbed = ({ alt, youtubeId }: YoutubeVideoProps) => {
return (
<>
{youTubeVideo ? (
<Box as="figure">
<AspectRatio ratio={16 / 9}>
<iframe
// Avoid youtube cookie. rel=0 should limit related videos to our channel.
// Once we have translated videos we can try e.g. cc_lang_pref=fr
// but we'll need to check our codes match theirs.
title="welcome video"
src={`https://www.youtube-nocookie.com/embed/${
youtubeId ? encodeURIComponent(youtubeId.trim()) : ""
}?rel=0&cc_load_policy=1`}
allow="encrypted-media"
frameBorder="0"
allowFullScreen
>
<Text>{alt || ""}</Text>
</iframe>
</AspectRatio>
{caption && (
<Text as="figcaption" mt="5px" fontSize="sm">
{caption}
</Text>
)}
{attribution && (
<Text as="figcaption" mt="5px" fontSize="sm">
{attribution}
</Text>
)}
</Box>
) : (
<AspectRatio ratio={16 / 9}>
<Spinner />
</AspectRatio>
)}
</>
<Box as="figure">
<AspectRatio ratio={16 / 9}>
<iframe
// Avoid youtube cookie. rel=0 should limit related videos to our channel.
// Once we have translated videos we can try e.g. cc_lang_pref=fr
// but we'll need to check our codes match theirs.
title={alt}
src={`https://www.youtube-nocookie.com/embed/${
youtubeId ? encodeURIComponent(youtubeId.trim()) : ""
}?rel=0&cc_load_policy=1`}
allow="encrypted-media"
frameBorder="0"
allowFullScreen
/>
</AspectRatio>
</Box>
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/deployment/default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const stubConsentContext = createContext<CookieConsent | undefined>(

const defaultDeploymentFactory: DeploymentConfigFactory = () => ({
chakraTheme: theme,
// This isn't ideal as it's the branded version. You can just remove the field to remove the welcome dialog.
welcomeVideoYouTubeId: "mREwMW69qKc",
logging: new NullLogging(),
compliance: {
ConsentProvider: ({ children }: { children: ReactNode }) => (
Expand Down
1 change: 1 addition & 0 deletions src/deployment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface CookieConsent {
}

export interface DeploymentConfig {
welcomeVideoYouTubeId?: string;
squareLogo?: ReactNode;
horizontalLogo?: ReactNode;
compliance: {
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,12 @@
"value": "Benvingut a l'Editor Python de la micro:bit"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,12 @@
"value": "Willkommen zum micro:bit Python-Editor"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,12 @@
"value": "Welcome to the micro:bit Python Editor"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.es-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,12 @@
"value": "Bienvenido al Editor de Python de micro:bit"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,12 @@
"value": "Bienvenue dans l'éditeur Python micro:bit"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,12 @@
"value": "micro:bit Pythonエディターへようこそ"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,12 @@
"value": "micro:bit Python 편집기에 오신 것을 환영합니다"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,12 @@
"value": "Welkom bij de micro:bit Python Editor"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,12 @@
"value": "欢迎使用 micro:bit Python 编辑器"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/ui.zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,12 @@
"value": "歡迎使用 micro:bit Python 編輯器"
}
],
"welcome-video-alt": [
{
"type": 0,
"value": "video introducing the Python Editor"
}
],
"zoom-in-action": [
{
"type": 0,
Expand Down
27 changes: 15 additions & 12 deletions src/workbench/PreReleaseNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Flex, HStack, Text } from "@chakra-ui/layout";
import { useCallback, useEffect, useState } from "react";
import { RiFeedbackFill, RiInformationFill } from "react-icons/ri";
import { useStorage } from "../common/use-storage";
import { useCookieConsent } from "../deployment";
import { useCookieConsent, useDeployment } from "../deployment";
import { flags } from "../flags";

export type ReleaseNoticeState = "info" | "feedback" | "closed";
Expand Down Expand Up @@ -56,6 +56,7 @@ export const useReleaseDialogState = (): [
};

const PreReleaseNotice = ({ onDialogChange }: PreReleaseNoticeProps) => {
const { welcomeVideoYouTubeId: hasInfoDialog } = useDeployment();
const openInfoDialog = useCallback(() => {
onDialogChange("info");
}, [onDialogChange]);
Expand All @@ -78,17 +79,19 @@ const PreReleaseNotice = ({ onDialogChange }: PreReleaseNoticeProps) => {
Beta release
</Text>
<HStack>
<Button
leftIcon={<RiInformationFill />}
variant="link"
color="white"
colorScheme="whiteAlpha"
size="xs"
p={1}
onClick={openInfoDialog}
>
More
</Button>
{hasInfoDialog && (
<Button
leftIcon={<RiInformationFill />}
variant="link"
color="white"
colorScheme="whiteAlpha"
size="xs"
p={1}
onClick={openInfoDialog}
>
More
</Button>
)}
<Button
leftIcon={<RiFeedbackFill />}
variant="link"
Expand Down
Loading
Loading