Skip to content

Commit

Permalink
Add jan-2019
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 14, 2019
1 parent ef9c0b7 commit e333221
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/repl/PluginConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const replDefaults: ReplState = {
shippedProposals: false,
targets: "",
version: "",
decoratorsVersion: "nov-2018",
decoratorsVersion: "jan-2019",
decoratorsBeforeExport: false,
pipelineProposal: "minimal",
};
Expand Down
33 changes: 24 additions & 9 deletions js/repl/ReplOptions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import { css, cx } from "emotion";
import React, { Component } from "react";
import React, { Component, type Node as ReactChildren } from "react";
import { envPresetDefaults, pluginConfigs } from "./PluginConfig";
import AccordionTab from "./AccordionTab";
import PresetLoadingAnimation from "./PresetLoadingAnimation";
Expand Down Expand Up @@ -127,6 +127,18 @@ const PresetOption = ({
);
};

type SelectOptionProps = {
value: string,
actual: string,
children: ReactChildren,
};

const SelectOption = ({ value, actual, children }: SelectOptionProps) => (
<option value={value} selected={value === actual}>
{children}
</option>
);

export default function ReplOptions(props: Props) {
return (
<div className={`${styles.wrapper} ${props.className}`}>
Expand Down Expand Up @@ -220,7 +232,7 @@ class ExpandedContainer extends Component<Props, State> {
const isStage1Enabled =
presetState["stage-0"].isEnabled || presetState["stage-1"].isEnabled;

const isDecoratorsNov2018 = presetsOptions.decoratorsVersion === "nov-2018";
const { decoratorsVersion } = presetsOptions;

return (
<div className={styles.expandedContainer}>
Expand Down Expand Up @@ -338,12 +350,15 @@ class ExpandedContainer extends Component<Props, State> {
t => t.value
)}
>
<option value="nov-2018" selected={isDecoratorsNov2018}>
<SelectOption value="jan-2019" actual={decoratorsVersion}>
January 2019
</SelectOption>
<SelectOption value="nov-2018" actual={decoratorsVersion}>
November 2018
</option>
<option value="legacy" selected={!isDecoratorsNov2018}>
</SelectOption>
<SelectOption value="legacy" actual={decoratorsVersion}>
Legacy
</option>
</SelectOption>
</select>
</PresetOption>
<PresetOption
Expand All @@ -354,17 +369,17 @@ class ExpandedContainer extends Component<Props, State> {
"Only works with November 2018 decorators." +
" It defaults to 'true' with legacy decorators."
}
enabled={isDecoratorsNov2018}
enabled={decoratorsVersion === "nov-2018"}
>
<span className={styles.presetsOptionsLabel}>
Decorators before
<code>export</code>
</span>
<input
enabled={isDecoratorsNov2018}
enabled={decoratorsVersion === "nov-2018"}
checked={presetsOptions.decoratorsBeforeExport}
ref={el => {
if (el) el.indeterminate = !isDecoratorsNov2018;
if (el) el.indeterminate = decoratorsVersion !== "nov-2018";
}}
className={styles.envPresetCheckbox}
type="checkbox"
Expand Down
4 changes: 2 additions & 2 deletions js/repl/replUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export const persistedStateToPresetsOptions = (
persistedState: ReplState
): PresetsOptions => {
return {
decoratorsVersion: persistedState.decoratorsVersion || "nov-2018",
decoratorsVersion: persistedState.decoratorsVersion || "jan-2019",
decoratorsBeforeExport:
persistedState.decoratorsVersion === "nov-2018" &&
persistedState.decoratorsVersion === "jan-2019" &&
!!persistedState.decoratorsBeforeExport,
pipelineProposal: persistedState.pipelineProposal || "minimal",
};
Expand Down
4 changes: 2 additions & 2 deletions js/repl/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type BabelPresets = Array<string | Array<string | Object>>;
export type BabelPlugins = Array<string>;

export type PresetsOptions = {
decoratorsVersion: "legacy" | "nov-2018",
decoratorsVersion: "legacy" | "nov-2018" | "jan-2019",
decoratorsBeforeExport: boolean,
pipelineProposal: "smart" | "minimal",
};
Expand Down Expand Up @@ -123,7 +123,7 @@ export type ReplState = {
showSidebar: boolean,
targets: string,
version: any,
decoratorsVersion: "legacy" | "nov-2018",
decoratorsVersion: "legacy" | "nov-2018" | "jan-2019",
decoratorsBeforeExport: boolean,
pipelineProposal: "minimal" | "smart",
};
Expand Down

0 comments on commit e333221

Please sign in to comment.