Skip to content

Commit 645ba89

Browse files
lqdshepmaster
authored andcommitted
add rust 2021 default notification
1 parent e9e7feb commit 645ba89

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

ui/frontend/Notifications.tsx

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

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

12-
const SURVEY_URL = 'https://blog.rust-lang.org/2020/09/10/survey-launch.html';
12+
const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/';
1313

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

24-
const Rust2020SurveyNotification: React.SFC = () => {
25-
const showRust2020Survey = useSelector(selectors.showRustSurvey2020Selector);
24+
const Rust2021IsDefaultNotification: React.SFC = () => {
25+
const showRust2021IsDefault = useSelector(selectors.showRust2021IsDefaultSelector);
2626

2727
const dispatch = useDispatch();
28-
const seenRustSurvey2020 = useCallback(() => dispatch(actions.seenRustSurvey2020()), [dispatch]);
29-
30-
return showRust2020Survey && (
31-
<Notification onClose={seenRustSurvey2020}>
32-
We want to know your opinions! Your responses to
33-
the <a href={SURVEY_URL}>2020 State of Rust Survey</a> will
34-
help the project understand its strengths and weaknesses
35-
and establish development priorities for the future!
28+
const seenRust2021IsDefault = useCallback(() => dispatch(actions.seenRust2021IsDefault()), [dispatch]);
29+
30+
return showRust2021IsDefault && (
31+
<Notification onClose={seenRust2021IsDefault}>
32+
As of Rust 1.56, the default edition of Rust is now Rust
33+
2021. Learn more about editions in the <a href={EDITION_URL}>Edition Guide</a>.
34+
To specify which edition to use, use the advanced compilation options menu.
3635
</Notification>
3736
);
3837
};

ui/frontend/actions.ts

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

711-
export const seenRustSurvey2020 = () => notificationSeen(Notification.RustSurvey2020);
711+
export const seenRust2021IsDefault = () => notificationSeen(Notification.Rust2021IsDefault);
712712

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

ui/frontend/reducers/notifications.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ import { Notification } from '../types';
44
interface State {
55
seenRustSurvey2018: boolean; // expired
66
seenRust2018IsDefault: boolean; // expired
7-
seenRustSurvey2020: boolean;
7+
seenRustSurvey2020: boolean; // expired
8+
seenRust2021IsDefault: boolean;
89
}
910

1011
const DEFAULT: State = {
1112
seenRustSurvey2018: true,
1213
seenRust2018IsDefault: true,
13-
seenRustSurvey2020: false,
14+
seenRustSurvey2020: true,
15+
seenRust2021IsDefault: false,
1416
};
1517

1618
export default function notifications(state = DEFAULT, action: Action): State {
1719
switch (action.type) {
1820
case ActionType.NotificationSeen: {
1921
switch (action.notification) {
20-
case Notification.RustSurvey2020: {
21-
return { ...state, seenRustSurvey2020: true };
22+
case Notification.Rust2021IsDefault: {
23+
return { ...state, seenRust2021IsDefault: true };
2224
}
2325
}
2426
}

ui/frontend/selectors/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,15 @@ export const codeUrlSelector = createSelector(
249249
const notificationsSelector = (state: State) => state.notifications;
250250

251251
const NOW = new Date();
252-
const RUST_SURVEY_2020_END = new Date('2020-09-24T23:59:59Z');
253-
const RUST_SURVEY_2020_OPEN = NOW <= RUST_SURVEY_2020_END;
254-
export const showRustSurvey2020Selector = createSelector(
252+
const RUST_2021_DEFAULT_END = new Date('2022-01-01T00:00:00Z');
253+
const RUST_2021_DEFAULT_OPEN = NOW <= RUST_2021_DEFAULT_END;
254+
export const showRust2021IsDefaultSelector = createSelector(
255255
notificationsSelector,
256-
notifications => RUST_SURVEY_2020_OPEN && !notifications.seenRustSurvey2020,
256+
notifications => RUST_2021_DEFAULT_OPEN && !notifications.seenRust2021IsDefault,
257257
);
258258

259259
export const anyNotificationsToShowSelector = createSelector(
260-
showRustSurvey2020Selector,
260+
showRust2021IsDefaultSelector,
261261
allNotifications => allNotifications,
262262
);
263263

ui/frontend/types.ts

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

121121
export enum Notification {
122-
RustSurvey2020 = 'rust-survey-2020',
122+
Rust2021IsDefault = 'rust-2021-is-default',
123123
}
124124

125125
export type AceResizeKey = [Focus, number];

0 commit comments

Comments
 (0)