From 1b8120b2146f3cd18dedcbd5196a94a911821dbb Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sat, 8 Jan 2022 15:03:37 -0500 Subject: [PATCH] Add notification about Monaco --- ui/frontend/Notifications.tsx | 40 +++++++-------------------- ui/frontend/actions.ts | 3 +- ui/frontend/reducers/notifications.ts | 17 ++++++------ ui/frontend/selectors/index.ts | 18 ++++-------- ui/frontend/types.ts | 3 +- 5 files changed, 25 insertions(+), 56 deletions(-) diff --git a/ui/frontend/Notifications.tsx b/ui/frontend/Notifications.tsx index bcb8540ec..89e8f16b8 100644 --- a/ui/frontend/Notifications.tsx +++ b/ui/frontend/Notifications.tsx @@ -9,49 +9,29 @@ import * as selectors from './selectors'; import styles from './Notifications.module.css'; -const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/'; -const SURVEY_URL = 'https://blog.rust-lang.org/2021/12/08/survey-launch.html'; +const MONACO_EDITOR_URL = 'https://microsoft.github.io/monaco-editor/'; const Notifications: React.SFC = () => { return (
- - +
); }; -const Rust2021IsDefaultNotification: React.SFC = () => { - const showRust2021IsDefault = useSelector(selectors.showRust2021IsDefaultSelector); +const MonacoEditorAvailableNotification: React.SFC = () => { + const monicoEditorAvailable = useSelector(selectors.showMonicoEditorAvailableSelector); const dispatch = useDispatch(); - const seenRust2021IsDefault = useCallback(() => dispatch(actions.seenRust2021IsDefault()), [dispatch]); + const seenMonicoEditorAvailable = useCallback(() => dispatch(actions.seenMonicoEditorAvailable()), [dispatch]); - return showRust2021IsDefault && ( - - As of Rust 1.56, the default edition of Rust is now Rust - 2021. Learn more about editions in the Edition Guide. - To specify which edition to use, use the advanced compilation options menu. - - ); -}; - - -const RustSurvey2021Notification: React.SFC = () => { - const showRustSurvey2021 = useSelector(selectors.showRustSurvey2021Selector); - - const dispatch = useDispatch(); - const seenRustSurvey2021 = useCallback(() => dispatch(actions.seenRustSurvey2021()), [dispatch]); - - return showRustSurvey2021 && ( - - Please help us take a look at who the Rust community is - composed of, how the Rust project is doing, and how we can - improve the Rust programming experience by completing the 2021 State of Rust Survey. Whether or - not you use Rust today, we want to know your opinions. + return monicoEditorAvailable && ( + + The Monaco Editor, the code editor + that powers VS Code, is now available in the playground. Choose + your preferred editor from the Config menu. ); }; diff --git a/ui/frontend/actions.ts b/ui/frontend/actions.ts index 1c6c21933..0cc7b3346 100644 --- a/ui/frontend/actions.ts +++ b/ui/frontend/actions.ts @@ -705,8 +705,7 @@ export function performVersionsLoad(): ThunkAction { const notificationSeen = (notification: Notification) => createAction(ActionType.NotificationSeen, { notification }); -export const seenRust2021IsDefault = () => notificationSeen(Notification.Rust2021IsDefault); -export const seenRustSurvey2021 = () => notificationSeen(Notification.RustSurvey2021); +export const seenMonicoEditorAvailable = () => notificationSeen(Notification.MonacoEditorAvailable); export const browserWidthChanged = (isSmall: boolean) => createAction(ActionType.BrowserWidthChanged, { isSmall }); diff --git a/ui/frontend/reducers/notifications.ts b/ui/frontend/reducers/notifications.ts index a1e2afd74..7261dd2a4 100644 --- a/ui/frontend/reducers/notifications.ts +++ b/ui/frontend/reducers/notifications.ts @@ -5,27 +5,26 @@ interface State { seenRustSurvey2018: boolean; // expired seenRust2018IsDefault: boolean; // expired seenRustSurvey2020: boolean; // expired - seenRust2021IsDefault: boolean; - seenRustSurvey2021: boolean; + seenRust2021IsDefault: boolean; // expired + seenRustSurvey2021: boolean; // expired + seenMonacoEditorAvailable: boolean; } const DEFAULT: State = { seenRustSurvey2018: true, seenRust2018IsDefault: true, seenRustSurvey2020: true, - seenRust2021IsDefault: false, - seenRustSurvey2021: false, + seenRust2021IsDefault: true, + seenRustSurvey2021: true, + seenMonacoEditorAvailable: false, }; export default function notifications(state = DEFAULT, action: Action): State { switch (action.type) { case ActionType.NotificationSeen: { switch (action.notification) { - case Notification.Rust2021IsDefault: { - return { ...state, seenRust2021IsDefault: true }; - } - case Notification.RustSurvey2021: { - return { ...state, seenRustSurvey2021: true }; + case Notification.MonacoEditorAvailable: { + return { ...state, seenMonacoEditorAvailable: true }; } } } diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts index da9b1e0e2..ab0b1d046 100644 --- a/ui/frontend/selectors/index.ts +++ b/ui/frontend/selectors/index.ts @@ -250,23 +250,15 @@ const notificationsSelector = (state: State) => state.notifications; const NOW = new Date(); -const RUST_2021_DEFAULT_END = new Date('2022-01-01T00:00:00Z'); -const RUST_2021_DEFAULT_OPEN = NOW <= RUST_2021_DEFAULT_END; -export const showRust2021IsDefaultSelector = createSelector( +const MONACO_EDITOR_AVAILABLE_END = new Date('2022-02-15T00:00:00Z'); +const MONACO_EDITOR_AVAILABLE_OPEN = NOW <= MONACO_EDITOR_AVAILABLE_END; +export const showMonicoEditorAvailableSelector = createSelector( notificationsSelector, - notifications => RUST_2021_DEFAULT_OPEN && !notifications.seenRust2021IsDefault, -); - -const RUST_SURVEY_2021_END = new Date('2021-12-22T00:00:00Z'); -const RUST_SURVEY_2021_OPEN = NOW <= RUST_SURVEY_2021_END; -export const showRustSurvey2021Selector = createSelector( - notificationsSelector, - notifications => RUST_SURVEY_2021_OPEN && !notifications.seenRustSurvey2021, + notifications => MONACO_EDITOR_AVAILABLE_OPEN && !notifications.seenMonacoEditorAvailable, ); export const anyNotificationsToShowSelector = createSelector( - showRust2021IsDefaultSelector, - showRustSurvey2021Selector, + showMonicoEditorAvailableSelector, (...allNotifications) => allNotifications.some(n => n), ); diff --git a/ui/frontend/types.ts b/ui/frontend/types.ts index ef232f1a8..64d8515a8 100644 --- a/ui/frontend/types.ts +++ b/ui/frontend/types.ts @@ -120,8 +120,7 @@ export enum Focus { } export enum Notification { - Rust2021IsDefault = 'rust-2021-is-default', - RustSurvey2021 = 'rust-survey-2021', + MonacoEditorAvailable = 'monaco-editor-available', } export type AceResizeKey = [Focus, number];