Skip to content

Commit

Permalink
Merge pull request #6646 from saulshanabrook/remove-table-view
Browse files Browse the repository at this point in the history
Remove settings table view
  • Loading branch information
jasongrout committed Jun 19, 2019
2 parents 46301ae + f75896d commit 659858d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 255 deletions.
31 changes: 9 additions & 22 deletions packages/settingeditor/src/plugineditor.ts
Expand Up @@ -25,8 +25,6 @@ import { RawEditor } from './raweditor';

import { SettingEditor } from './settingeditor';

import { TableEditor } from './tableeditor';

/**
* The class name added to all plugin editors.
*/
Expand All @@ -46,6 +44,11 @@ export class PluginEditor extends Widget {
this.addClass(PLUGIN_EDITOR_CLASS);

const { commands, editorFactory, registry, rendermime } = options;

// TODO: Remove this layout. We were using this before when we
// when we had a way to switch between the raw and table editor
// Now, the raw editor is the only child and probably could merged into
// this class directly in the future.
const layout = (this.layout = new StackedLayout());
const { onSaveError } = Private;

Expand All @@ -56,28 +59,21 @@ export class PluginEditor extends Widget {
registry,
rendermime
});
this.table = this._tableEditor = new TableEditor({ onSaveError });
this._rawEditor.handleMoved.connect(this._onStateChanged, this);

layout.addWidget(this._rawEditor);
layout.addWidget(this._tableEditor);
}

/**
* The plugin editor's raw editor.
*/
readonly raw: RawEditor;

/**
* The plugin editor's table editor.
*/
readonly table: TableEditor;

/**
* Tests whether the settings have been modified and need saving.
*/
get isDirty(): boolean {
return this._rawEditor.isDirty || this._tableEditor.isDirty;
return this._rawEditor.isDirty;
}

/**
Expand All @@ -92,28 +88,25 @@ export class PluginEditor extends Widget {
}

const raw = this._rawEditor;
const table = this._tableEditor;

this._settings = raw.settings = table.settings = settings;
this._settings = raw.settings = settings;
this.update();
}

/**
* The plugin editor layout state.
*/
get state(): SettingEditor.IPluginLayout {
const editor = this._editor;
const plugin = this._settings ? this._settings.id : '';
const { sizes } = this._rawEditor;

return { editor, plugin, sizes };
return { plugin, sizes };
}
set state(state: SettingEditor.IPluginLayout) {
if (JSONExt.deepEqual(this.state, state)) {
return;
}

this._editor = state.editor;
this._rawEditor.sizes = state.sizes;
this.update();
}
Expand Down Expand Up @@ -154,7 +147,6 @@ export class PluginEditor extends Widget {

super.dispose();
this._rawEditor.dispose();
this._tableEditor.dispose();
}

/**
Expand All @@ -168,9 +160,7 @@ export class PluginEditor extends Widget {
* Handle `'update-request'` messages.
*/
protected onUpdateRequest(msg: Message): void {
const editor = this._editor;
const raw = this._rawEditor;
const table = this._tableEditor;
const settings = this._settings;

if (!settings) {
Expand All @@ -179,8 +169,7 @@ export class PluginEditor extends Widget {
}

this.show();
(editor === 'raw' ? table : raw).hide();
(editor === 'raw' ? raw : table).show();
raw.show();
}

/**
Expand All @@ -190,9 +179,7 @@ export class PluginEditor extends Widget {
(this.stateChanged as Signal<any, void>).emit(undefined);
}

private _editor: 'raw' | 'table' = 'raw';
private _rawEditor: RawEditor;
private _tableEditor: TableEditor;
private _settings: ISettingRegistry.ISettings | null = null;
private _stateChanged = new Signal<this, void>(this);
}
Expand Down
44 changes: 2 additions & 42 deletions packages/settingeditor/src/pluginlist.tsx
Expand Up @@ -44,21 +44,6 @@ export class PluginList extends Widget {
return this._changed;
}

/**
* The editor type currently selected.
*/
get editor(): 'raw' | 'table' {
return this._editor;
}
set editor(editor: 'raw' | 'table') {
if (this._editor === editor) {
return;
}

this._editor = editor;
this.update();
}

/**
* The selection value of the plugin list.
*/
Expand Down Expand Up @@ -120,10 +105,9 @@ export class PluginList extends Widget {
*/
protected onUpdateRequest(msg: Message): void {
const { node, registry } = this;
const type = this._editor;
const selection = this._selection;

Private.populateList(registry, type, selection, node);
Private.populateList(registry, selection, node);
node.querySelector('ul').scrollTop = this._scrollTop;
}

Expand All @@ -142,15 +126,6 @@ export class PluginList extends Widget {
return;
}

const editor = target.getAttribute('data-editor');

if (editor) {
this._editor = editor as 'raw' | 'table';
this._changed.emit(undefined);
this.update();
return;
}

if (!id) {
while (!id && target !== this.node) {
target = target.parentElement as HTMLElement;
Expand All @@ -176,7 +151,6 @@ export class PluginList extends Widget {

private _changed = new Signal<this, void>(this);
private _confirm: () => Promise<void>;
private _editor: 'raw' | 'table' = 'raw';
private _scrollTop = 0;
private _selection = '';
}
Expand Down Expand Up @@ -264,7 +238,6 @@ namespace Private {
*/
export function populateList(
registry: ISettingRegistry,
type: 'raw' | 'table',
selection: string,
node: HTMLElement
): void {
Expand Down Expand Up @@ -297,20 +270,7 @@ namespace Private {
});

ReactDOM.unmountComponentAtNode(node);
ReactDOM.render(
<React.Fragment>
<div className="jp-PluginList-switcher">
<button data-editor="raw" disabled={type === 'raw'}>
Raw View
</button>
<button data-editor="table" disabled={type === 'table'}>
Table View
</button>
</div>
<ul>{items}</ul>
</React.Fragment>,
node
);
ReactDOM.render(<ul>{items}</ul>, node);
}

/**
Expand Down
9 changes: 0 additions & 9 deletions packages/settingeditor/src/settingeditor.tsx
Expand Up @@ -248,7 +248,6 @@ export class SettingEditor extends Widget {
private _onStateChanged(): void {
this._state.sizes = this._panel.relativeSizes();
this._state.container = this._editor.state;
this._state.container.editor = this._list.editor;
this._state.container.plugin = this._list.selection;
this._saveState()
.then(() => {
Expand Down Expand Up @@ -329,7 +328,6 @@ export class SettingEditor extends Widget {
panel.addWidget(editor);
}
editor.settings = settings;
list.editor = container.editor;
list.selection = container.plugin;
this._setLayout();
})
Expand Down Expand Up @@ -438,9 +436,6 @@ export namespace SettingEditor {
* The current plugin being displayed.
*/
plugin: string;

editor: 'raw' | 'table';

sizes: number[];
}
}
Expand Down Expand Up @@ -496,10 +491,6 @@ namespace Private {
: {};

saved.container = {
editor:
container.editor === 'raw' || container.editor === 'table'
? container.editor
: DEFAULT_LAYOUT.container.editor,
plugin:
typeof container.plugin === 'string'
? container.plugin
Expand Down
151 changes: 0 additions & 151 deletions packages/settingeditor/src/tableeditor.tsx

This file was deleted.

0 comments on commit 659858d

Please sign in to comment.