Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Implement baseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
dok committed Sep 25, 2018
1 parent 6af0346 commit 6df73c7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions example/src/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Demo extends React.Component {
oasFiles={{
'api-setting': Object.assign(extensions.defaults, this.state.oas),
}}
baseUrl={'/'}
Logs={Logs}
flags={{
correctnewlines: false,
Expand Down
10 changes: 8 additions & 2 deletions packages/api-explorer/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31180,6 +31180,7 @@ function (_React$Component) {
flags: _this2.props.flags,
user: Cookie.getJSON('user_data'),
Logs: _this2.props.Logs,
baseUrl: _this2.props.baseUrl,
appearance: _this2.props.appearance,
language: _this2.state.language,
oauth: _this2.props.oauth,
Expand All @@ -31204,6 +31205,7 @@ ApiExplorer.propTypes = {
correctnewlines: PropTypes.bool
}).isRequired,
oauth: PropTypes.bool,
baseUrl: PropTypes.string.isRequired,
Logs: PropTypes.func,
suggestedEdits: PropTypes.bool.isRequired,
tryItMetrics: PropTypes.func,
Expand All @@ -31227,7 +31229,8 @@ ApiExplorer.defaultProps = {
correctnewlines: false
},
tryItMetrics: function tryItMetrics() {},
Logs: undefined
Logs: undefined,
baseUrl: '/'
};

module.exports = function (props) {
Expand Down Expand Up @@ -37758,6 +37761,7 @@ function (_React$Component) {
apiKey: this.props.apiKey,
oas: this.oas,
user: this.props.user,
baseUrl: this.props.baseUrl,
operation: this.getOperation(),
formData: this.state.formData,
onChange: this.onChange,
Expand Down Expand Up @@ -37878,6 +37882,7 @@ Doc.propTypes = {
referenceLayout: PropTypes.string
}).isRequired,
language: PropTypes.string.isRequired,
baseUrl: PropTypes.string,
oauth: PropTypes.bool.isRequired,
suggestedEdits: PropTypes.bool.isRequired,
apiKey: PropTypes.string,
Expand All @@ -37893,7 +37898,8 @@ Doc.defaultProps = {
},
apiKey: undefined,
Logs: undefined,
user: undefined
user: undefined,
baseUrl: '/'
};

/***/ }),
Expand Down
3 changes: 3 additions & 0 deletions packages/api-explorer/src/Doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class Doc extends React.Component {
apiKey={this.props.apiKey}
oas={this.oas}
user={this.props.user}
baseUrl={this.props.baseUrl}
operation={this.getOperation()}
formData={this.state.formData}
onChange={this.onChange}
Expand Down Expand Up @@ -381,6 +382,7 @@ Doc.propTypes = {
referenceLayout: PropTypes.string,
}).isRequired,
language: PropTypes.string.isRequired,
baseUrl: PropTypes.string,
oauth: PropTypes.bool.isRequired,
suggestedEdits: PropTypes.bool.isRequired,
apiKey: PropTypes.string,
Expand All @@ -398,4 +400,5 @@ Doc.defaultProps = {
apiKey: undefined,
Logs: undefined,
user: undefined,
baseUrl: '/',
};
3 changes: 3 additions & 0 deletions packages/api-explorer/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ApiExplorer extends React.Component {
flags={this.props.flags}
user={Cookie.getJSON('user_data')}
Logs={this.props.Logs}
baseUrl={this.props.baseUrl}
appearance={this.props.appearance}
language={this.state.language}
oauth={this.props.oauth}
Expand Down Expand Up @@ -133,6 +134,7 @@ ApiExplorer.propTypes = {
correctnewlines: PropTypes.bool,
}).isRequired,
oauth: PropTypes.bool,
baseUrl: PropTypes.string.isRequired,
Logs: PropTypes.func,
suggestedEdits: PropTypes.bool.isRequired,
tryItMetrics: PropTypes.func,
Expand All @@ -156,6 +158,7 @@ ApiExplorer.defaultProps = {
},
tryItMetrics: () => {},
Logs: undefined,
baseUrl: '/',
};

module.exports = props => (
Expand Down
1 change: 0 additions & 1 deletion packages/api-logs/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('Logs', () => {
test('should be in a loading state', () => {
const comp = shallow(<LogTest {...props} />);
comp.setState({ loading: true });
console.log('whoa dude: ', comp.html());

expect(comp.find('.loading-container').length).toBe(1);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/api-logs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Logs extends React.Component {
}

getData() {
const { oas, operation } = this.props;
const { oas, operation, baseUrl } = this.props;
const { group } = this.state;
this.setState({ loading: true });

Expand All @@ -91,8 +91,7 @@ class Logs extends React.Component {
find.group = group;
}

// TODO: make this url non-root so that it can work with parent
const reqUrl = `/api/logs?${querystring.stringify(find)}`;
const reqUrl = `${baseUrl}api/logs?${querystring.stringify(find)}`;

return fetch(reqUrl).then(res => {
return this.handleData(res);
Expand Down Expand Up @@ -199,6 +198,7 @@ class Logs extends React.Component {
Logs.propTypes = {
oas: PropTypes.shape({}).isRequired,
operation: PropTypes.shape({}).isRequired,
baseUrl: PropTypes.string.isRequired,
user: PropTypes.shape({
keys: PropTypes.array,
id: PropTypes.string,
Expand Down

0 comments on commit 6df73c7

Please sign in to comment.