Skip to content

Commit 2243494

Browse files
committed
Remove isSicpEditor prop from Playground
Replaces isSicpEditor with the literal `false` and simplify the conditionals that involve it.
1 parent 3104d66 commit 2243494

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

src/pages/playground/Playground.tsx

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Classes } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
33
import { Octokit } from '@octokit/rest';
4-
import { Ace, Range } from 'ace-builds';
54
import { FSModule } from 'browserfs/dist/node/core/FS';
65
import classNames from 'classnames';
76
import { Chapter, Variant } from 'js-slang/dist/types';
@@ -109,7 +108,6 @@ import MobileWorkspace, {
109108
} from '../../commons/mobileWorkspace/MobileWorkspace';
110109
import { SideBarTab } from '../../commons/sideBar/SideBar';
111110
import { SideContentTab, SideContentType } from '../../commons/sideContent/SideContentTypes';
112-
import { Links } from '../../commons/utils/Constants';
113111
import { generateSourceIntroduction } from '../../commons/utils/IntroductionHelper';
114112
import { convertParamToBoolean, convertParamToInt } from '../../commons/utils/ParamParseHelper';
115113
import { IParsedQuery, parseQuery } from '../../commons/utils/QueryHelper';
@@ -142,7 +140,6 @@ export type PlaygroundProps = OwnProps &
142140
};
143141

144142
export type OwnProps = {
145-
isSicpEditor?: boolean;
146143
initialEditorValueHash?: string;
147144
prependLength?: number;
148145
handleCloseEditor?: () => void;
@@ -271,7 +268,6 @@ export async function handleHash(
271268
}
272269

273270
const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground', ...props }) => {
274-
const { isSicpEditor } = props;
275271
const { isMobileBreakpoint } = useResponsive();
276272
const propsRef = React.useRef(props);
277273
propsRef.current = props;
@@ -316,8 +312,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
316312
[deviceSecret]
317313
);
318314

319-
const usingRemoteExecution =
320-
useTypedSelector(state => !!state.session.remoteExecutionSession) && !isSicpEditor;
315+
const usingRemoteExecution = useTypedSelector(state => !!state.session.remoteExecutionSession);
321316
// this is still used by remote execution (EV3)
322317
// specifically, for the editor Ctrl+B to work
323318
const externalLibraryName = useTypedSelector(
@@ -335,7 +330,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
335330
);
336331
}, [props.editorSessionId]);
337332

338-
const hash = isSicpEditor ? props.initialEditorValueHash : props.location.hash;
333+
const hash = props.location.hash;
339334

340335
React.useEffect(() => {
341336
if (!hash) {
@@ -667,21 +662,19 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
667662
);
668663

669664
const shareButton = React.useMemo(() => {
670-
const queryString = isSicpEditor
671-
? Links.playground + '#' + props.initialEditorValueHash
672-
: props.queryString;
665+
const queryString = props.queryString;
673666
return (
674667
<ControlBarShareButton
675668
handleGenerateLz={() => dispatch(generateLzString())}
676669
handleShortenURL={s => dispatch(shortenURL(s))}
677670
handleUpdateShortURL={s => dispatch(updateShortURL(s))}
678671
queryString={queryString}
679672
shortURL={props.shortURL}
680-
isSicp={isSicpEditor}
673+
isSicp={false}
681674
key="share"
682675
/>
683676
);
684-
}, [dispatch, isSicpEditor, props.initialEditorValueHash, props.queryString, props.shortURL]);
677+
}, [dispatch, props.queryString, props.shortURL]);
685678

686679
const toggleFolderModeButton = React.useMemo(() => {
687680
return (
@@ -757,17 +750,14 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
757750
}
758751
}
759752

760-
if (!isSicpEditor) {
761-
tabs.push(remoteExecutionTab);
762-
}
753+
tabs.push(remoteExecutionTab);
763754

764755
return tabs;
765756
}, [
766757
playgroundIntroductionTab,
767758
props.playgroundSourceChapter,
768759
props.output,
769760
usingRemoteExecution,
770-
isSicpEditor,
771761
dispatch,
772762
workspaceLocation,
773763
shouldShowDataVisualizer,
@@ -779,18 +769,6 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
779769
// Remove Intro and Remote Execution tabs for mobile
780770
const mobileTabs = [...tabs].filter(({ id }) => !(id && desktopOnlyTabIds.includes(id)));
781771

782-
const onLoadMethod = React.useCallback(
783-
(editor: Ace.Editor) => {
784-
const addFold = () => {
785-
editor.getSession().addFold(' ', new Range(1, 0, props.prependLength!, 0));
786-
editor.renderer.off('afterRender', addFold);
787-
};
788-
789-
editor.renderer.on('afterRender', addFold);
790-
},
791-
[props.prependLength]
792-
);
793-
794772
const onChangeMethod = React.useCallback(
795773
(newCode: string, delta: CodeDelta) => {
796774
const input: Input = {
@@ -911,7 +889,6 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
911889
onChange: onChangeMethod,
912890
onCursorChange: onCursorChangeMethod,
913891
onSelectionChange: onSelectionChangeMethod,
914-
onLoad: isSicpEditor && props.prependLength ? onLoadMethod : undefined,
915892
sourceChapter: props.playgroundSourceChapter,
916893
externalLibraryName,
917894
sourceVariant: props.playgroundSourceVariant,
@@ -941,7 +918,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
941918
selectedTab === SideContentType.envVisualizer,
942919
inputHidden: replDisabled,
943920
replButtons: [replDisabled ? null : evalButton, clearButton],
944-
disableScrolling: isSicpEditor
921+
disableScrolling: false
945922
};
946923

947924
const sideBarProps: { tabs: SideBarTab[] } = React.useMemo(() => {
@@ -978,7 +955,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
978955
autorunButtons,
979956
props.playgroundSourceChapter === Chapter.FULL_JS ? null : shareButton,
980957
chapterSelect,
981-
isSicpEditor ? null : sessionButtons,
958+
sessionButtons,
982959
languageConfig.supports.multiFile ? toggleFolderModeButton : null,
983960
persistenceButtons,
984961
githubButtons,
@@ -1004,7 +981,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
1004981
beforeDynamicTabs: tabs,
1005982
afterDynamicTabs: []
1006983
},
1007-
workspaceLocation: isSicpEditor ? 'sicp' : 'playground',
984+
workspaceLocation: 'playground',
1008985
sideContentHeight: props.sideContentHeight
1009986
},
1010987
sideContentIsResizeable: selectedTab !== SideContentType.substVisualizer
@@ -1020,7 +997,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
1020997
autorunButtons,
1021998
chapterSelect,
1022999
props.playgroundSourceChapter === Chapter.FULL_JS ? null : shareButton,
1023-
isSicpEditor ? null : sessionButtons,
1000+
sessionButtons,
10241001
languageConfig.supports.multiFile ? toggleFolderModeButton : null,
10251002
persistenceButtons,
10261003
githubButtons
@@ -1032,7 +1009,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
10321009
beforeDynamicTabs: mobileTabs,
10331010
afterDynamicTabs: []
10341011
},
1035-
workspaceLocation: isSicpEditor ? 'sicp' : 'playground'
1012+
workspaceLocation: 'playground'
10361013
}
10371014
};
10381015

0 commit comments

Comments
 (0)