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

compat: move obsolete UI plugins to Editor #1840

Merged
merged 3 commits into from
Jul 19, 2018
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"watch": "webpack --config ./webpack-dist.config.js --watch --progress"
},
"dependencies": {
"@kyleshockey/js-yaml": "^1.0.1",
"ajv": "^5.2.2",
"boron": "^0.2.3",
"brace": "^0.10.0",
"classnames": "^2.1.3",
"core-js": "^2.4.1",
"deepmerge": "^1.3.2",
"immutable": "^3.x.x",
"js-yaml": "^3.5.5",
"json-beautify": "^1.0.1",
"json-refs": "^3.0.4",
"lodash": "^4.17.4",
Expand All @@ -63,6 +63,7 @@
"react-file-download": "^0.3.2",
"react-immutable-proptypes": "^2.1.0",
"react-redux": "^4.x.x",
"react-split-pane": "^0.1.82",
"react-transition-group": "^1.1.1",
"redux": "^3.x.x",
"reselect": "^2.5.4",
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/ast/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as AST from "./ast"
import JumpToPath from "./jump-to-path"

export default function() {
return {
fn: { AST },
components: { JumpToPath }
fn: { AST }
}
}
9 changes: 0 additions & 9 deletions src/plugins/ast/jump-to-path.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/plugins/editor/editor-plugins/json-to-yaml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import YAML from "js-yaml"
import YAML from "@kyleshockey/js-yaml"

export default function(editor) {
editor.on("paste", e => {
Expand Down
85 changes: 85 additions & 0 deletions src/plugins/split-pane-mode/components/split-pane-mode.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from "react"
import PropTypes from "prop-types"
import SplitPane from "react-split-pane"

const MODE_KEY = ["split-pane-mode"]
const MODE_LEFT = "left"
const MODE_RIGHT = "right"
const MODE_BOTH = "both" // or anything other than left/right

export default class SplitPaneMode extends React.Component {

static propTypes = {
threshold: PropTypes.number,

children: PropTypes.array,

layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
};

static defaultProps = {
threshold: 100, // in pixels
children: [],
};

initializeComponent = (c) => {
this.splitPane = c
}

onDragFinished = () => {
let { threshold, layoutActions } = this.props
let { position, draggedSize } = this.splitPane.state
this.draggedSize = draggedSize

let nearLeftEdge = position <= threshold
let nearRightEdge = draggedSize <= threshold

layoutActions
.changeMode(MODE_KEY, (
nearLeftEdge
? MODE_RIGHT : nearRightEdge
? MODE_LEFT : MODE_BOTH
))
}

sizeFromMode = (mode, defaultSize) => {
if(mode === MODE_LEFT) {
this.draggedSize = null
return "0px"
} else if (mode === MODE_RIGHT) {
this.draggedSize = null
return "100%"
}
// mode === "both"
return this.draggedSize || defaultSize
}

render() {
let { children, layoutSelectors } = this.props

const mode = layoutSelectors.whatMode(MODE_KEY)
const left = mode === MODE_RIGHT ? <noscript/> : children[0]
const right = mode === MODE_LEFT ? <noscript/> : children[1]
const size = this.sizeFromMode(mode, "50%")

return (
<SplitPane
disabledClass={""}
ref={this.initializeComponent}
split='vertical'
defaultSize={"50%"}
primary="second"
minSize={0}
size={size}
onDragFinished={this.onDragFinished}
allowResize={mode !== MODE_LEFT && mode !== MODE_RIGHT }
resizerStyle={{"flex": "0 0 auto", "position": "relative"}}
>
{ left }
{ right }
</SplitPane>
)
}

}
15 changes: 15 additions & 0 deletions src/plugins/split-pane-mode/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SplitPaneMode from "./components/split-pane-mode"
export default function SplitPaneModePlugin() {
return {
// statePlugins: {
// layout: {
// actions,
// selectors,
// }
// },

components: {
SplitPaneMode
}
}
}
6 changes: 3 additions & 3 deletions src/standalone/topbar/topbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "whatwg-fetch"
import DropdownMenu from "./DropdownMenu"
import Modal from "boron/DropModal"
import reactFileDownload from "react-file-download"
import YAML from "js-yaml"
import YAML from "@kyleshockey/js-yaml"
import beautifyJson from "json-beautify"

import "react-dd-menu/dist/react-dd-menu.css"
Expand Down Expand Up @@ -384,7 +384,7 @@ export default class Topbar extends React.Component {
</DropdownMenu> : null }
</div>
</div>
<Modal className="swagger-ui modal" ref="modal">
<Modal className="modal" ref="modal">
<div className="container">
<h2>Upload file</h2>
<input type="file" ref="fileLoadInput"></input>
Expand All @@ -394,7 +394,7 @@ export default class Topbar extends React.Component {
<button className="btn" onClick={this.importFromFile}>Open file</button>
</div>
</Modal>
<Modal className="swagger-ui modal" ref="generatorModal">
<Modal className="modal" ref="generatorModal">
<div className="modal-message">
<p>
Code generation for OAS3 is currently work in progress. The available languages is smaller than the for OAS/Swagger 2.0 and is constantly being updated.
Expand Down
2 changes: 2 additions & 0 deletions src/standalone/topbar/topbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
}

.modal {
font-family: sans-serif;
color: #3b4151;
padding: 1em;
position: relative;
min-height: 12em;
Expand Down