Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions ui/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,7 @@ module.exports = {
'editor/SimpleEditor.tsx',
'hooks.ts',
'observer.ts',
'reducers/browser.ts',
'reducers/client.ts',
'reducers/code.ts',
'reducers/configuration.ts',
'reducers/crates.ts',
'reducers/featureFlags.ts',
'reducers/globalConfiguration.ts',
'reducers/notifications.ts',
'reducers/output/assembly.ts',
'reducers/output/clippy.ts',
'reducers/output/execute.ts',
'reducers/output/format.ts',
'reducers/output/gist.ts',
'reducers/output/hir.ts',
'reducers/output/llvmIr.ts',
'reducers/output/macroExpansion.ts',
'reducers/output/meta.ts',
'reducers/output/mir.ts',
'reducers/output/miri.ts',
'reducers/output/wasm.ts',
'reducers/page.ts',
'reducers/position.ts',
'reducers/selection.ts',
'reducers/versions.ts',
'reducers/**/*.ts',
'reducers/websocket.ts',
'selectors/index.spec.ts',
'types.ts',
Expand Down
26 changes: 1 addition & 25 deletions ui/frontend/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,7 @@ node_modules
!editor/SimpleEditor.tsx
!hooks.ts
!observer.ts
!reducers/browser.ts
!reducers/client.ts
!reducers/code.ts
!reducers/configuration.ts
!reducers/crates.ts
!reducers/featureFlags.ts
!reducers/globalConfiguration.ts
!reducers/notifications.ts
!reducers/output/assembly.ts
!reducers/output/clippy.ts
!reducers/output/execute.ts
!reducers/output/format.ts
!reducers/output/gist.ts
!reducers/output/hir.ts
!reducers/output/llvmIr.ts
!reducers/output/macroExpansion.ts
!reducers/output/meta.ts
!reducers/output/mir.ts
!reducers/output/miri.ts
!reducers/output/wasm.ts
!reducers/page.ts
!reducers/position.ts
!reducers/selection.ts
!reducers/versions.ts
!reducers/websocket.ts
!reducers/**/*.ts
!selectors/index.spec.ts
!types.ts
!websocketActions.ts
Expand Down
18 changes: 9 additions & 9 deletions ui/frontend/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ import { Portal } from 'react-portal';

import { Close } from './Icon';
import { useAppDispatch, useAppSelector } from './hooks';
import { seenRustSurvey2022 } from './reducers/notifications';
import { seenRustSurvey2023 } from './reducers/notifications';
import { allowLongRun, wsExecuteKillCurrent } from './reducers/output/execute';
import * as selectors from './selectors';

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

const SURVEY_URL = 'https://blog.rust-lang.org/2022/12/05/survey-launch.html';
const SURVEY_URL = 'https://blog.rust-lang.org/2023/12/18/survey-launch.html';

const Notifications: React.FC = () => {
return (
<Portal>
<div className={styles.container}>
<RustSurvey2022Notification />
<RustSurvey2023Notification />
<ExcessiveExecutionNotification />
</div>
</Portal>
);
};

const RustSurvey2022Notification: React.FC = () => {
const showRustSurvey2022 = useAppSelector(selectors.showRustSurvey2022Selector);
const RustSurvey2023Notification: React.FC = () => {
const showIt = useAppSelector(selectors.showRustSurvey2023Selector);

const dispatch = useAppDispatch();
const seenRustSurvey2021 = useCallback(() => dispatch(seenRustSurvey2022()), [dispatch]);
const seenIt = useCallback(() => dispatch(seenRustSurvey2023()), [dispatch]);

return showRustSurvey2022 ? (
<Notification onClose={seenRustSurvey2021}>
return showIt ? (
<Notification onClose={seenIt}>
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{' '}
<a href={SURVEY_URL}>2022 State of Rust Survey</a>. Whether or not you use Rust today, we want
<a href={SURVEY_URL}>2023 State of Rust Survey</a>. Whether or not you use Rust today, we want
to know your opinions.
</Notification>
) : null;
Expand Down
12 changes: 7 additions & 5 deletions ui/frontend/reducers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface State {
seenRust2021IsDefault: boolean; // expired
seenRustSurvey2021: boolean; // expired
seenMonacoEditorAvailable: boolean; // expired
seenRustSurvey2022: boolean;
seenRustSurvey2022: boolean; // expired
seenRustSurvey2023: boolean;
}

const initialState: State = {
Expand All @@ -19,7 +20,8 @@ const initialState: State = {
seenRust2021IsDefault: true,
seenRustSurvey2021: true,
seenMonacoEditorAvailable: true,
seenRustSurvey2022: false,
seenRustSurvey2022: true,
seenRustSurvey2023: false,
};

const slice = createSlice({
Expand All @@ -28,8 +30,8 @@ const slice = createSlice({
reducers: {
notificationSeen: (state, action: PayloadAction<Notification>) => {
switch (action.payload) {
case Notification.RustSurvey2022: {
state.seenRustSurvey2022 = true;
case Notification.RustSurvey2023: {
state.seenRustSurvey2023 = true;
}
}
},
Expand All @@ -38,6 +40,6 @@ const slice = createSlice({

const { notificationSeen } = slice.actions;

export const seenRustSurvey2022 = () => notificationSeen(Notification.RustSurvey2022);
export const seenRustSurvey2023 = () => notificationSeen(Notification.RustSurvey2023);

export default slice.reducer;
10 changes: 5 additions & 5 deletions ui/frontend/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,15 @@ const notificationsSelector = (state: State) => state.notifications;

const NOW = new Date();

const RUST_SURVEY_2022_END = new Date('2022-12-19T00:00:00Z');
const RUST_SURVEY_2022_OPEN = NOW <= RUST_SURVEY_2022_END;
export const showRustSurvey2022Selector = createSelector(
const RUST_SURVEY_2023_END = new Date('2024-01-15T00:00:00Z');
const RUST_SURVEY_2023_OPEN = NOW <= RUST_SURVEY_2023_END;
export const showRustSurvey2023Selector = createSelector(
notificationsSelector,
notifications => RUST_SURVEY_2022_OPEN && !notifications.seenRustSurvey2022,
notifications => RUST_SURVEY_2023_OPEN && !notifications.seenRustSurvey2023,
);

export const anyNotificationsToShowSelector = createSelector(
showRustSurvey2022Selector,
showRustSurvey2023Selector,
excessiveExecutionSelector,
(...allNotifications) => allNotifications.some(n => n),
);
Expand Down
2 changes: 1 addition & 1 deletion ui/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ export enum Focus {
}

export enum Notification {
RustSurvey2022 = 'rust-survey-2022',
RustSurvey2023 = 'rust-survey-2023',
}