Skip to content

Commit 0440cd9

Browse files
committed
Add Rust 2024 default notification
1 parent 09fe391 commit 0440cd9

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

ui/frontend/Notifications.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import { Portal } from 'react-portal';
33

44
import { Close } from './Icon';
55
import { useAppDispatch, useAppSelector } from './hooks';
6-
import { seenRustSurvey2024 } from './reducers/notifications';
6+
import { seenRust2024IsDefault, seenRustSurvey2024 } from './reducers/notifications';
77
import { allowLongRun, wsExecuteKillCurrent } from './reducers/output/execute';
88
import * as selectors from './selectors';
99

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

1212
const SURVEY_URL = 'https://blog.rust-lang.org/2024/12/05/annual-survey-2024-launch.html';
13+
const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/';
1314

1415
const Notifications: React.FC = () => {
1516
return (
1617
<Portal>
1718
<div className={styles.container}>
1819
<RustSurvey2024Notification />
20+
<Rust2024IsDefaultNotification />
1921
<ExcessiveExecutionNotification />
2022
</div>
2123
</Portal>
@@ -38,6 +40,21 @@ const RustSurvey2024Notification: React.FC = () => {
3840
) : null;
3941
};
4042

43+
const Rust2024IsDefaultNotification: React.FC = () => {
44+
const showIt = useAppSelector(selectors.showRust2024IsDefaultSelector);
45+
46+
const dispatch = useAppDispatch();
47+
const seenIt = useCallback(() => dispatch(seenRust2024IsDefault()), [dispatch]);
48+
49+
return showIt ? (
50+
<Notification onClose={seenIt}>
51+
As of Rust 1.85, the default edition of Rust is now Rust 2024. Learn more about editions in
52+
the <a href={EDITION_URL}>Edition Guide</a>. To specify which edition to use, use the advanced
53+
compilation options menu.
54+
</Notification>
55+
) : null;
56+
};
57+
4158
const ExcessiveExecutionNotification: React.FC = () => {
4259
const showExcessiveExecution = useAppSelector(selectors.excessiveExecutionSelector);
4360
const time = useAppSelector(selectors.excessiveExecutionTimeSelector);

ui/frontend/reducers/notifications.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface State {
1313
seenRustSurvey2023: boolean; // expired
1414
seenDarkMode: boolean; // expired
1515
seenRustSurvey2024: boolean;
16+
seenRust2024IsDefault: boolean;
1617
}
1718

1819
const initialState: State = {
@@ -26,6 +27,7 @@ const initialState: State = {
2627
seenRustSurvey2023: true,
2728
seenDarkMode: true,
2829
seenRustSurvey2024: false,
30+
seenRust2024IsDefault: false,
2931
};
3032

3133
const slice = createSlice({
@@ -38,6 +40,10 @@ const slice = createSlice({
3840
state.seenRustSurvey2024 = true;
3941
break;
4042
}
43+
case Notification.Rust2024IsDefault: {
44+
state.seenRust2024IsDefault = true;
45+
break;
46+
}
4147
}
4248
},
4349
},
@@ -47,4 +53,6 @@ const { notificationSeen } = slice.actions;
4753

4854
export const seenRustSurvey2024 = () => notificationSeen(Notification.RustSurvey2024);
4955

56+
export const seenRust2024IsDefault = () => notificationSeen(Notification.Rust2024IsDefault);
57+
5058
export default slice.reducer;

ui/frontend/selectors/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,16 @@ export const showRustSurvey2024Selector = createSelector(
367367
notifications => RUST_SURVEY_2024_OPEN && !notifications.seenRustSurvey2024,
368368
);
369369

370+
const RUST_2024_IS_DEFAULT_END = new Date('2025-04-03T00:00:00Z');
371+
const RUST_2024_IS_DEFAULT_OPEN = NOW <= RUST_2024_IS_DEFAULT_END;
372+
export const showRust2024IsDefaultSelector = createSelector(
373+
notificationsSelector,
374+
notifications => RUST_2024_IS_DEFAULT_OPEN && !notifications.seenRust2024IsDefault,
375+
);
376+
370377
export const anyNotificationsToShowSelector = createSelector(
371378
showRustSurvey2024Selector,
379+
showRust2024IsDefaultSelector,
372380
excessiveExecutionSelector,
373381
(...allNotifications) => allNotifications.some(n => n),
374382
);

ui/frontend/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,5 @@ export enum Focus {
166166

167167
export enum Notification {
168168
RustSurvey2024 = 'rust-survey-2024',
169+
Rust2024IsDefault = 'rust-2024-is-default',
169170
}

0 commit comments

Comments
 (0)