Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings): remove Roll Your Own in favor of debug switches #6487

Merged
merged 2 commits into from
Oct 7, 2024
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
1 change: 0 additions & 1 deletion editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { when } from '../../../utils/react-conditionals'
import { useColorTheme, UtopiaStyles } from '../../../uuiui'
import { useDispatch } from '../../editor/store/dispatch-context'
import { Substores, useEditorState, useRefEditorState } from '../../editor/store/store-hook'
import { useRollYourOwnFeatures } from '../../navigator/left-pane/roll-your-own-pane'
import CanvasActions from '../canvas-actions'
import type { ControlWithProps } from '../canvas-strategies/canvas-strategy-types'
import { controlForStrategyMemoized } from '../canvas-strategies/canvas-strategy-types'
Expand Down
15 changes: 0 additions & 15 deletions editor/src/components/canvas/design-panel-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import { EditorModes, isCommentMode } from '../editor/editor-modes'
import { useAllowedToEditProject } from '../editor/store/collaborative-editing'
import { useCanComment } from '../../core/commenting/comment-hooks'
import { ElementsOutsideVisibleAreaIndicator } from '../editor/elements-outside-visible-area-indicator'
import { isFeatureEnabled } from '../../utils/feature-switches'
import { RollYourOwnFeaturesPane } from '../navigator/left-pane/roll-your-own-pane'
import { AnimationContext } from './ui-jsx-canvas-renderer/animation-context'

function isCodeEditorEnabled(): boolean {
Expand Down Expand Up @@ -163,10 +161,6 @@ export const RightPane = React.memo<ResizableRightPaneProps>((props) => {
onClickTab(RightMenuTab.Settings)
}, [onClickTab])

const onClickRollYourOwnTab = React.useCallback(() => {
onClickTab(RightMenuTab.RollYourOwn)
}, [onClickTab])

const canComment = useCanComment()

const allowedToEdit = useAllowedToEditProject()
Expand Down Expand Up @@ -235,14 +229,6 @@ export const RightPane = React.memo<ResizableRightPaneProps>((props) => {
selected={selectedTab === RightMenuTab.Settings}
onClick={onClickSettingsTab}
/>
{when(
isFeatureEnabled('Roll Your Own'),
<MenuTab
label={'RYO'}
selected={selectedTab === RightMenuTab.RollYourOwn}
onClick={onClickRollYourOwnTab}
/>,
)}
</FlexRow>
<SimpleFlexRow
className='Inspector-entrypoint'
Expand All @@ -260,7 +246,6 @@ export const RightPane = React.memo<ResizableRightPaneProps>((props) => {
{when(selectedTab === RightMenuTab.Inspector, <InspectorEntryPoint />)}
{when(selectedTab === RightMenuTab.Settings, <SettingsPane />)}
{when(selectedTab === RightMenuTab.Comments, <CommentsPane />)}
{when(selectedTab === RightMenuTab.RollYourOwn, <RollYourOwnFeaturesPane />)}
</SimpleFlexRow>
<CanvasStrategyInspector />
</FlexColumn>
Expand Down
1 change: 0 additions & 1 deletion editor/src/components/editor/store/editor-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export enum RightMenuTab {
Inspector = 'inspector',
Settings = 'settings',
Comments = 'comments',
RollYourOwn = 'roll-your-own',
}

// TODO: this should just contain an NpmDependency and a status
Expand Down
275 changes: 0 additions & 275 deletions editor/src/components/navigator/left-pane/roll-your-own-pane.tsx

This file was deleted.

27 changes: 15 additions & 12 deletions editor/src/components/navigator/left-pane/settings-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import type { FeatureName } from '../../../utils/feature-switches'
import {
toggleFeatureEnabled,
isFeatureEnabled,
AllFeatureNames,
FeaturesHiddenFromMainSettingsPane,
getFeaturesToDisplay,
} from '../../../utils/feature-switches'
import json5 from 'json5'
import { load } from '../../../components/editor/actions/actions'
Expand Down Expand Up @@ -60,18 +59,23 @@ const themeOptions = [
const defaultTheme = themeOptions[0]

export const FeatureSwitchesSection = React.memo(() => {
const featuresToDisplay = React.useMemo(
() => AllFeatureNames.filter((name) => !FeaturesHiddenFromMainSettingsPane.includes(name)),
[],
)
const [changeCount, setChangeCount] = React.useState(0)
// this replaces the 'forceRender' in the original implementation
const onFeatureChange = React.useCallback(() => setChangeCount(changeCount + 1), [changeCount])
// eslint-disable-next-line react-hooks/exhaustive-deps
const featuresToDisplay = React.useMemo(() => getFeaturesToDisplay(), [changeCount])
if (featuresToDisplay.length > 0) {
return (
<Section>
<UIGridRow padded variant='<---1fr--->|------172px-------|'>
<H2>Experimental Toggle Features</H2>
</UIGridRow>
{featuresToDisplay.map((name) => (
<FeatureSwitchRow key={`feature-switch-${name}`} name={name} />
<FeatureSwitchRow
key={`feature-switch-${name}`}
name={name}
onFeatureChange={onFeatureChange}
/>
))}
</Section>
)
Expand All @@ -80,15 +84,14 @@ export const FeatureSwitchesSection = React.memo(() => {
}
})

const FeatureSwitchRow = React.memo((props: { name: FeatureName }) => {
const FeatureSwitchRow = React.memo((props: { name: FeatureName; onFeatureChange: () => void }) => {
const name = props.name
const onFeatureChange = props.onFeatureChange
const id = `toggle-${name}`
const [changeCount, setChangeCount] = React.useState(0)
const forceRender = React.useCallback(() => setChangeCount(changeCount + 1), [changeCount])
const onChange = React.useCallback(() => {
toggleFeatureEnabled(name)
forceRender()
}, [forceRender, name])
onFeatureChange()
}, [name, onFeatureChange])
return (
<FlexRow style={{ paddingLeft: 16, height: UtopiaTheme.layout.rowHeight.normal }}>
<CheckboxInput
Expand Down
Loading
Loading