Skip to content

Commit bbccd23

Browse files
author
Ives van Hoorne
committed
Fix UI splitting
1 parent d220daa commit bbccd23

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

packages/app/src/app/components/CodeEditor/Configuration/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import EntryIcons from 'app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons';
44
import type { Module } from 'common/types';
5+
import getUI from 'common/templates/configuration/ui';
56
import getType from 'app/utils/get-type';
67
import Tooltip from 'common/components/Tooltip';
78

@@ -56,7 +57,7 @@ export default class Configuration extends React.PureComponent<Props>
5657
const { config, width, height } = this.props;
5758
const currentModule = this.currentModule;
5859

59-
const { ConfigWizard } = config.ui;
60+
const { ConfigWizard } = getUI(config.type);
6061

6162
return (
6263
<Container style={{ width, height }}>

packages/app/src/app/components/CodeEditor/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Loadable from 'react-loadable';
55
import Loading from 'app/components/Loading';
66
import Title from 'app/components/Title';
77
import SubTitle from 'app/components/SubTitle';
8+
import getUI from 'common/templates/configuration/ui';
89
import Centered from 'common/components/flex/Centered';
910
import Margin from 'common/components/spacing/Margin';
1011
import isImage from 'common/utils/is-image';
@@ -85,7 +86,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
8586
module.id
8687
);
8788
const config = template.configurationFiles[modulePath];
88-
if (config && config.ui && this.state.showConfigUI) {
89+
if (config && getUI(config.type) && this.state.showConfigUI) {
8990
return (
9091
<Configuration
9192
{...props}
@@ -140,7 +141,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
140141
}}
141142
>
142143
{config &&
143-
(config.ui ? (
144+
(getUI(config.type) ? (
144145
<Icons>
145146
<Tooltip title="Switch to UI Configuration">
146147
<Icon onClick={this.toggleConfigUI}>

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/ConfigurationFiles/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import getDefinition from 'common/templates';
3+
import getUI from 'common/templates/configuration/ui';
34
import { Module, Configuration } from 'common/types';
45
import { resolveModule } from 'common/sandbox/modules';
56

@@ -60,7 +61,7 @@ const FileConfig = ({
6061
<BookIcon />
6162
</a>
6263
</Tooltip>
63-
{config.ui && (
64+
{getUI(config.type) && (
6465
<Tooltip title="Editable with UI">
6566
<UIIcon style={{ marginLeft: '.5rem' }} />
6667
</Tooltip>

packages/common/templates/configuration/prettierRC/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
import DEFAULT_PRETTIER_CONFIG from 'common/prettify-default-config';
33

44
import type { ConfigurationFile } from '../types';
5-
import ui from './ui';
65

76
const config: ConfigurationFile = {
87
title: '.prettierrc',
98
type: 'prettier',
109
description: 'Defines how all files will be prettified by Prettier.',
1110
moreInfoUrl: 'https://prettier.io/docs/en/configuration.html',
12-
ui,
1311
generateFileFromState: state =>
1412
JSON.stringify(
1513
{

packages/common/templates/configuration/sandbox/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// @flow
22
import type { ConfigurationFile } from '../types';
3-
import ui from './ui';
43

54
const config: ConfigurationFile = {
65
title: 'sandbox.config.json',
76
type: 'sandbox',
87
description: 'Configuration specific to the current sandbox.',
98
moreInfoUrl:
109
'https://codesandbox.io/docs/configuration#sandbox-configuration',
11-
ui,
1210
getDefaultCode: () =>
1311
JSON.stringify(
1412
{
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @flow
2-
import type { ComponentType } from 'react';
32
import type { Sandbox } from 'common/types';
43

54
export type ConfigurationFile = {
@@ -15,13 +14,6 @@ export type ConfigurationFile = {
1514
generateFileFromState?: (state: any) => string,
1615
generateFileFromSandbox?: (sandbox: Sandbox) => string,
1716

18-
ui?: {
19-
ConfigWizard: ComponentType<{
20-
file: string,
21-
updateFile: (code: string) => void,
22-
}>,
23-
},
24-
2517
schema?: string,
2618
partialSupportDisclaimer?: string,
2719
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @flow
2+
import configs from './';
3+
4+
import prettierUI from './prettierRC/ui';
5+
import sandboxUI from './sandbox/ui';
6+
7+
export default function getUI(configType: string) {
8+
switch (configType) {
9+
case configs.prettier.type: {
10+
return prettierUI;
11+
}
12+
case configs.sandbox.type: {
13+
return sandboxUI;
14+
}
15+
default: {
16+
return null;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)