Skip to content

Commit b3bd276

Browse files
committed
Add a notification for the Rust 2022 survey
1 parent 198da01 commit b3bd276

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

ui/frontend/Notifications.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,31 @@ import * as selectors from './selectors';
99

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

12-
const MONACO_EDITOR_URL = 'https://microsoft.github.io/monaco-editor/';
12+
const SURVEY_URL = 'https://blog.rust-lang.org/2022/12/05/survey-launch.html';
1313

1414
const Notifications: React.FC = () => {
1515
return (
1616
<Portal>
1717
<div className={styles.container}>
18-
<MonacoEditorAvailableNotification />
18+
<RustSurvey2022Notification />
1919
</div>
2020
</Portal>
2121
);
2222
};
2323

24-
const MonacoEditorAvailableNotification: React.FC = () => {
25-
const monacoEditorAvailable = useSelector(selectors.showMonacoEditorAvailableSelector);
24+
const RustSurvey2022Notification: React.SFC = () => {
25+
const showRustSurvey2022 = useSelector(selectors.showRustSurvey2022Selector);
2626

2727
const dispatch = useDispatch();
28-
const seenMonacoEditorAvailable = useCallback(() => dispatch(actions.seenMonacoEditorAvailable()), [dispatch]);
29-
30-
return monacoEditorAvailable ? (
31-
<Notification onClose={seenMonacoEditorAvailable}>
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.
28+
const seenRustSurvey2021 = useCallback(() => dispatch(actions.seenRustSurvey2022()), [dispatch]);
29+
30+
return showRustSurvey2022 ? (
31+
<Notification onClose={seenRustSurvey2021}>
32+
Please help us take a look at who the Rust community is
33+
composed of, how the Rust project is doing, and how we can
34+
improve the Rust programming experience by completing the <a
35+
href={SURVEY_URL}>2022 State of Rust Survey</a>. Whether or
36+
not you use Rust today, we want to know your opinions.
3537
</Notification>
3638
) : null;
3739
};

ui/frontend/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ export function performVersionsLoad(): ThunkAction {
802802
const notificationSeen = (notification: Notification) =>
803803
createAction(ActionType.NotificationSeen, { notification });
804804

805-
export const seenMonacoEditorAvailable = () => notificationSeen(Notification.MonacoEditorAvailable);
805+
export const seenRustSurvey2022 = () => notificationSeen(Notification.RustSurvey2022);
806806

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

ui/frontend/reducers/notifications.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ interface State {
77
seenRustSurvey2020: boolean; // expired
88
seenRust2021IsDefault: boolean; // expired
99
seenRustSurvey2021: boolean; // expired
10-
seenMonacoEditorAvailable: boolean;
10+
seenMonacoEditorAvailable: boolean; // expired
11+
seenRustSurvey2022: boolean;
1112
}
1213

1314
const DEFAULT: State = {
@@ -16,15 +17,16 @@ const DEFAULT: State = {
1617
seenRustSurvey2020: true,
1718
seenRust2021IsDefault: true,
1819
seenRustSurvey2021: true,
19-
seenMonacoEditorAvailable: false,
20+
seenMonacoEditorAvailable: true,
21+
seenRustSurvey2022: false,
2022
};
2123

2224
export default function notifications(state = DEFAULT, action: Action): State {
2325
switch (action.type) {
2426
case ActionType.NotificationSeen: {
2527
switch (action.notification) {
26-
case Notification.MonacoEditorAvailable: {
27-
return { ...state, seenMonacoEditorAvailable: true };
28+
case Notification.RustSurvey2022: {
29+
return { ...state, seenRustSurvey2022: true };
2830
}
2931
}
3032
}

ui/frontend/selectors/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,15 @@ const notificationsSelector = (state: State) => state.notifications;
271271

272272
const NOW = new Date();
273273

274-
const MONACO_EDITOR_AVAILABLE_END = new Date('2022-02-15T00:00:00Z');
275-
const MONACO_EDITOR_AVAILABLE_OPEN = NOW <= MONACO_EDITOR_AVAILABLE_END;
276-
export const showMonacoEditorAvailableSelector = createSelector(
274+
const RUST_SURVEY_2022_END = new Date('2022-12-19T00:00:00Z');
275+
const RUST_SURVEY_2022_OPEN = NOW <= RUST_SURVEY_2022_END;
276+
export const showRustSurvey2022Selector = createSelector(
277277
notificationsSelector,
278-
notifications => MONACO_EDITOR_AVAILABLE_OPEN && !notifications.seenMonacoEditorAvailable,
278+
notifications => RUST_SURVEY_2022_OPEN && !notifications.seenRustSurvey2022,
279279
);
280280

281281
export const anyNotificationsToShowSelector = createSelector(
282-
showMonacoEditorAvailableSelector,
282+
showRustSurvey2022Selector,
283283
(...allNotifications) => allNotifications.some(n => n),
284284
);
285285

ui/frontend/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export enum Focus {
120120
}
121121

122122
export enum Notification {
123-
MonacoEditorAvailable = 'monaco-editor-available',
123+
RustSurvey2022 = 'rust-survey-2022',
124124
}
125125

126126
export type AceResizeKey = [Focus | undefined, number];

0 commit comments

Comments
 (0)