Skip to content

Commit 4f97659

Browse files
committed
Automatically select nightly channel when selecting Rust 2021
1 parent d0796bf commit 4f97659

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

ui/frontend/AdvancedOptionsMenu.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { useSelector, useDispatch } from 'react-redux';
44
import * as actions from './actions';
55
import { Either as EitherConfig, Select as SelectConfig } from './ConfigElement';
66
import MenuGroup from './MenuGroup';
7+
import MenuAside from './MenuAside';
78
import { State } from './reducers';
89
import * as selectors from './selectors';
910
import { Backtrace, Edition } from './types';
1011

1112
const AdvancedOptionsMenu: React.SFC = () => {
1213
const isEditionDefault = useSelector(selectors.isEditionDefault);
1314
const edition = useSelector((state: State) => state.configuration.edition);
15+
const isRust2021Available = useSelector(selectors.isRust2021Available);
1416
const isBacktraceSet = useSelector(selectors.getBacktraceSet);
1517
const backtrace = useSelector((state: State) => state.configuration.backtrace);
1618

@@ -19,13 +21,16 @@ const AdvancedOptionsMenu: React.SFC = () => {
1921
const changeEdition = useCallback((e) => dispatch(actions.changeEdition(e)), [dispatch]);
2022
const changeBacktrace = useCallback((b) => dispatch(actions.changeBacktrace(b)), [dispatch]);
2123

24+
const Aside = !isRust2021Available && <Rust2021Aside />;
25+
2226
return (
2327
<MenuGroup title="Advanced options">
2428
<SelectConfig
2529
name="Edition"
2630
value={edition}
2731
isNotDefault={!isEditionDefault}
2832
onChange={changeEdition}
33+
aside={Aside}
2934
>
3035
<option value={Edition.Rust2015}>2015</option>
3136
<option value={Edition.Rust2018}>2018</option>
@@ -44,4 +49,11 @@ const AdvancedOptionsMenu: React.SFC = () => {
4449
);
4550
};
4651

52+
const Rust2021Aside: React.SFC = () => (
53+
<MenuAside>
54+
Note: Rust 2021 currently requires using the Nightly channel, selecting this
55+
option will switch to Nightly.
56+
</MenuAside>
57+
);
58+
4759
export default AdvancedOptionsMenu;

ui/frontend/ConfigElement.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ export const Select: React.SFC<SelectProps> = ({ value, onChange, children, ...r
5252
interface ConfigElementProps {
5353
name: string;
5454
isNotDefault?: boolean;
55+
aside?: JSX.Element,
5556
}
5657

57-
const ConfigElement: React.SFC<ConfigElementProps> = ({ name, isNotDefault, children }) => (
58+
const ConfigElement: React.SFC<ConfigElementProps> = ({ name, isNotDefault, aside, children }) => (
5859
<MenuItem>
5960
<div className={styles.container}>
6061
<span className={isNotDefault ? styles.notDefault : styles.name}>{name}</span>
6162
<div className={styles.value}>
6263
{children}
6364
</div>
6465
</div>
66+
{aside}
6567
</MenuItem>
6668
);

ui/frontend/actions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,16 @@ export const changeChannel = (channel: Channel) =>
165165
export const changeMode = (mode: Mode) =>
166166
createAction(ActionType.ChangeMode, { mode });
167167

168-
export const changeEdition = (edition: Edition) =>
168+
const changeEditionRaw = (edition: Edition) =>
169169
createAction(ActionType.ChangeEdition, { edition });
170170

171+
export const changeEdition = (edition: Edition): ThunkAction => dispatch => {
172+
if (edition == Edition.Rust2021) {
173+
dispatch(changeChannel(Channel.Nightly));
174+
}
175+
dispatch(changeEditionRaw(edition));
176+
}
177+
171178
export const changeBacktrace = (backtrace: Backtrace) =>
172179
createAction(ActionType.ChangeBacktrace, { backtrace });
173180

@@ -805,7 +812,7 @@ export type Action =
805812
| ReturnType<typeof changeBacktrace>
806813
| ReturnType<typeof changeChannel>
807814
| ReturnType<typeof changeDemangleAssembly>
808-
| ReturnType<typeof changeEdition>
815+
| ReturnType<typeof changeEditionRaw>
809816
| ReturnType<typeof changeEditor>
810817
| ReturnType<typeof changeFocus>
811818
| ReturnType<typeof changeKeybinding>

ui/frontend/selectors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export const isNightlyChannel = (state: State) => (
108108
);
109109
export const isWasmAvailable = isNightlyChannel;
110110
export const isHirAvailable = isNightlyChannel;
111+
export const isRust2021Available = isNightlyChannel;
111112

112113
export const getModeLabel = (state: State) => {
113114
const { configuration: { mode } } = state;

0 commit comments

Comments
 (0)