Skip to content

Commit 3428a15

Browse files
committed
Add notification about Monaco
1 parent fe2ceac commit 3428a15

File tree

5 files changed

+25
-56
lines changed

5 files changed

+25
-56
lines changed

ui/frontend/Notifications.tsx

+10-30
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,29 @@ import * as selectors from './selectors';
99

1010
import styles from './Notifications.module.css';
1111

12-
const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/';
13-
const SURVEY_URL = 'https://blog.rust-lang.org/2021/12/08/survey-launch.html';
12+
const MONACO_EDITOR_URL = 'https://microsoft.github.io/monaco-editor/';
1413

1514
const Notifications: React.SFC = () => {
1615
return (
1716
<Portal>
1817
<div className={styles.container}>
19-
<Rust2021IsDefaultNotification />
20-
<RustSurvey2021Notification />
18+
<MonacoEditorAvailableNotification />
2119
</div>
2220
</Portal>
2321
);
2422
};
2523

26-
const Rust2021IsDefaultNotification: React.SFC = () => {
27-
const showRust2021IsDefault = useSelector(selectors.showRust2021IsDefaultSelector);
24+
const MonacoEditorAvailableNotification: React.SFC = () => {
25+
const monicoEditorAvailable = useSelector(selectors.showMonicoEditorAvailableSelector);
2826

2927
const dispatch = useDispatch();
30-
const seenRust2021IsDefault = useCallback(() => dispatch(actions.seenRust2021IsDefault()), [dispatch]);
28+
const seenMonicoEditorAvailable = useCallback(() => dispatch(actions.seenMonicoEditorAvailable()), [dispatch]);
3129

32-
return showRust2021IsDefault && (
33-
<Notification onClose={seenRust2021IsDefault}>
34-
As of Rust 1.56, the default edition of Rust is now Rust
35-
2021. Learn more about editions in the <a href={EDITION_URL}>Edition Guide</a>.
36-
To specify which edition to use, use the advanced compilation options menu.
37-
</Notification>
38-
);
39-
};
40-
41-
42-
const RustSurvey2021Notification: React.SFC = () => {
43-
const showRustSurvey2021 = useSelector(selectors.showRustSurvey2021Selector);
44-
45-
const dispatch = useDispatch();
46-
const seenRustSurvey2021 = useCallback(() => dispatch(actions.seenRustSurvey2021()), [dispatch]);
47-
48-
return showRustSurvey2021 && (
49-
<Notification onClose={seenRustSurvey2021}>
50-
Please help us take a look at who the Rust community is
51-
composed of, how the Rust project is doing, and how we can
52-
improve the Rust programming experience by completing the <a
53-
href={SURVEY_URL}>2021 State of Rust Survey</a>. Whether or
54-
not you use Rust today, we want to know your opinions.
30+
return monicoEditorAvailable && (
31+
<Notification onClose={seenMonicoEditorAvailable}>
32+
The <a href={MONACO_EDITOR_URL}>Monaco Editor</a>, the code editor
33+
that powers VS Code, is now available in the playground. Choose
34+
your preferred editor from the Config menu.
5535
</Notification>
5636
);
5737
};

ui/frontend/actions.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,7 @@ export function performVersionsLoad(): ThunkAction {
705705
const notificationSeen = (notification: Notification) =>
706706
createAction(ActionType.NotificationSeen, { notification });
707707

708-
export const seenRust2021IsDefault = () => notificationSeen(Notification.Rust2021IsDefault);
709-
export const seenRustSurvey2021 = () => notificationSeen(Notification.RustSurvey2021);
708+
export const seenMonicoEditorAvailable = () => notificationSeen(Notification.MonacoEditorAvailable);
710709

711710
export const browserWidthChanged = (isSmall: boolean) =>
712711
createAction(ActionType.BrowserWidthChanged, { isSmall });

ui/frontend/reducers/notifications.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@ interface State {
55
seenRustSurvey2018: boolean; // expired
66
seenRust2018IsDefault: boolean; // expired
77
seenRustSurvey2020: boolean; // expired
8-
seenRust2021IsDefault: boolean;
9-
seenRustSurvey2021: boolean;
8+
seenRust2021IsDefault: boolean; // expired
9+
seenRustSurvey2021: boolean; // expired
10+
seenMonacoEditorAvailable: boolean;
1011
}
1112

1213
const DEFAULT: State = {
1314
seenRustSurvey2018: true,
1415
seenRust2018IsDefault: true,
1516
seenRustSurvey2020: true,
16-
seenRust2021IsDefault: false,
17-
seenRustSurvey2021: false,
17+
seenRust2021IsDefault: true,
18+
seenRustSurvey2021: true,
19+
seenMonacoEditorAvailable: false,
1820
};
1921

2022
export default function notifications(state = DEFAULT, action: Action): State {
2123
switch (action.type) {
2224
case ActionType.NotificationSeen: {
2325
switch (action.notification) {
24-
case Notification.Rust2021IsDefault: {
25-
return { ...state, seenRust2021IsDefault: true };
26-
}
27-
case Notification.RustSurvey2021: {
28-
return { ...state, seenRustSurvey2021: true };
26+
case Notification.MonacoEditorAvailable: {
27+
return { ...state, seenMonacoEditorAvailable: true };
2928
}
3029
}
3130
}

ui/frontend/selectors/index.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,15 @@ const notificationsSelector = (state: State) => state.notifications;
250250

251251
const NOW = new Date();
252252

253-
const RUST_2021_DEFAULT_END = new Date('2022-01-01T00:00:00Z');
254-
const RUST_2021_DEFAULT_OPEN = NOW <= RUST_2021_DEFAULT_END;
255-
export const showRust2021IsDefaultSelector = createSelector(
253+
const MONACO_EDITOR_AVAILABLE_END = new Date('2022-02-15T00:00:00Z');
254+
const MONACO_EDITOR_AVAILABLE_OPEN = NOW <= MONACO_EDITOR_AVAILABLE_END;
255+
export const showMonicoEditorAvailableSelector = createSelector(
256256
notificationsSelector,
257-
notifications => RUST_2021_DEFAULT_OPEN && !notifications.seenRust2021IsDefault,
258-
);
259-
260-
const RUST_SURVEY_2021_END = new Date('2021-12-22T00:00:00Z');
261-
const RUST_SURVEY_2021_OPEN = NOW <= RUST_SURVEY_2021_END;
262-
export const showRustSurvey2021Selector = createSelector(
263-
notificationsSelector,
264-
notifications => RUST_SURVEY_2021_OPEN && !notifications.seenRustSurvey2021,
257+
notifications => MONACO_EDITOR_AVAILABLE_OPEN && !notifications.seenMonacoEditorAvailable,
265258
);
266259

267260
export const anyNotificationsToShowSelector = createSelector(
268-
showRust2021IsDefaultSelector,
269-
showRustSurvey2021Selector,
261+
showMonicoEditorAvailableSelector,
270262
(...allNotifications) => allNotifications.some(n => n),
271263
);
272264

ui/frontend/types.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ export enum Focus {
120120
}
121121

122122
export enum Notification {
123-
Rust2021IsDefault = 'rust-2021-is-default',
124-
RustSurvey2021 = 'rust-survey-2021',
123+
MonacoEditorAvailable = 'monaco-editor-available',
125124
}
126125

127126
export type AceResizeKey = [Focus, number];

0 commit comments

Comments
 (0)