diff --git a/src/core/components/layouts/base.jsx b/src/core/components/layouts/base.jsx index 6cd909bb..1f5a0788 100644 --- a/src/core/components/layouts/base.jsx +++ b/src/core/components/layouts/base.jsx @@ -94,8 +94,9 @@ export default class BaseLayout extends React.Component { ) : null } { servers && servers.size ? ( -
+
+ Server + { !tryItOutEnabled ? null : + + } + {!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ?
{ + const { path, method } = this.props + // FIXME: we should be keeping up with this in props/state upstream of us + // instead of cheating™ with `forceUpdate` + this.forceUpdate() + return this.props.setSelectedServer(server, `${path}:${method}`) + } + + setServerVariableValue = (obj) => { + const { path, method } = this.props + // FIXME: we should be keeping up with this in props/state upstream of us + // instead of cheating™ with `forceUpdate` + this.forceUpdate() + return this.props.setServerVariableValue({ + ...obj, + namespace: `${path}:${method}` + }) + } + + getSelectedServer = () => { + const { path, method } = this.props + return this.props.getSelectedServer(`${path}:${method}`) + } + + getServerVariable = (server, key) => { + const { path, method } = this.props + return this.props.getServerVariable({ + namespace: `${path}:${method}`, + server + }, key) + } + + getEffectiveServerValue = (server) => { + const { path, method } = this.props + return this.props.getEffectiveServerValue({ + server, + namespace: `${path}:${method}` + }) + } + + render() { + const { + // for self + operationServers, + pathServers, + + // util + getComponent + } = this.props + + if(!operationServers && !pathServers) { + return null + } + + const Servers = getComponent("Servers") + + const serversToDisplay = operationServers || pathServers + const displaying = operationServers ? "operation" : "path" + + return
+
+
+

Servers

+
+
+
+

+ These {displaying}-level options override the global server options. +

+ +
+
+ } +} diff --git a/src/core/plugins/oas3/components/servers.jsx b/src/core/plugins/oas3/components/servers.jsx index 75b528f5..d6ed4a63 100644 --- a/src/core/plugins/oas3/components/servers.jsx +++ b/src/core/plugins/oas3/components/servers.jsx @@ -15,7 +15,11 @@ export default class Servers extends React.Component { } componentDidMount() { - let { servers } = this.props + let { servers, currentServer } = this.props + + if(currentServer) { + return + } //fire 'change' event to set default 'value' of select this.setServer(servers.first().get("url")) @@ -93,9 +97,8 @@ export default class Servers extends React.Component { let shouldShowVariableUI = currentServerVariableDefs.size !== 0 return ( -
+