这是indexloc提供的服务,不要输入任何密码
Skip to content
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
6,916 changes: 3,458 additions & 3,458 deletions console/package-lock.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions console/src/components/ApiExplorer/Actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import defaultState from './state';
import fetch from 'isomorphic-fetch';

const CHANGE_TAB = 'ApiExplorer/CHANGE_TAB';
const CHANGE_API_SELECTION = 'ApiExplorer/CHANGE_API_SELECTION';
Expand Down Expand Up @@ -155,6 +156,18 @@ const changeRequestParams = newParams => {
};
};

const graphQLFetcherFinal = (graphQLParams, url, headers) => {
const graphqlUrl = url;
const currentHeaders = headers;
const headersFinal = getHeadersAsJSON(currentHeaders);

return fetch(graphqlUrl, {
method: 'POST',
headers: headersFinal,
body: JSON.stringify(graphQLParams),
}).then(response => response.json());
};

const changeRequestHeader = (index, key, newValue, isDisabled) => {
return {
type: REQUEST_HEADER_CHANGED,
Expand Down Expand Up @@ -539,4 +552,5 @@ export {
clearHistory,
updateFileObject,
editGeneratedJson,
graphQLFetcherFinal,
};
31 changes: 12 additions & 19 deletions console/src/components/ApiExplorer/GraphiQLWrapper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { Component } from 'react';
import GraphiQL from 'graphiql';
import PropTypes from 'prop-types';
import fetch from 'isomorphic-fetch';
import { getHeadersAsJSON } from './utils';
import ErrorBoundary from './ErrorBoundary';
import { graphQLFetcherFinal } from './Actions';

import './GraphiQL.css';

Expand All @@ -18,28 +17,22 @@ class GraphiQLWrapper extends Component {
};
}

shouldComponentUpdate() {
// shouldn't re-render if headers change. play button will trigger the query
return false;
}

render() {
const styles = require('../Common/Common.scss');
const headers = getHeadersAsJSON(this.props.data.headers);

const graphqlUrl = this.props.data.url;
const filterAccessKeyHeader = this.props.data.headers.filter(
elem => elem.key === 'X-Hasura-Access-Key'
)[0];

if (
this.props.data.dataHeaders['X-Hasura-Access-Key'] &&
!filterAccessKeyHeader
) {
headers['X-Hasura-Access-Key'] = this.props.data.dataHeaders[
'X-Hasura-Access-Key'
];
}
const graphQLFetcher = graphQLParams => {
return fetch(graphqlUrl, {
method: 'POST',
headers: headers,
body: JSON.stringify(graphQLParams),
}).then(response => response.json());
return graphQLFetcherFinal(
graphQLParams,
graphqlUrl,
this.props.data.headers
);
};

// let content = "fetching schema";
Expand Down
3 changes: 2 additions & 1 deletion console/src/components/Main/Actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { push } from 'react-router-redux';
import globals from 'Globals';
import defaultState from './State';
import Endpoints from '../../Endpoints';
import requestAction from '../../utils/requestAction';
Expand Down Expand Up @@ -64,7 +65,7 @@ const validateLogin = isInitialLoad => (dispatch, getState) => {
}
return dispatch(requestAction(url, options)).then(
() => {
dispatch(push('/'));
dispatch(push(globals.urlPrefix));
},
error => {
dispatch({ type: LOGIN_IN_PROGRESS, data: false });
Expand Down
8 changes: 4 additions & 4 deletions console/src/components/Services/Data/DataRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const dataRouter = (connect, store, composeOnEnterHooks) => {
}
// redirect to login page if error in access key
if (store.getState().tables.accessKeyError) {
replaceState('/login');
replaceState(globals.urlPrefix + '/login');
cb();
} else {
// validate login
Expand All @@ -187,7 +187,7 @@ const dataRouter = (connect, store, composeOnEnterHooks) => {
},
() => {
// alert('Could not load schema.');
replaceState('/');
replaceState(globals.urlPrefix);
cb();
}
);
Expand All @@ -207,14 +207,14 @@ const dataRouter = (connect, store, composeOnEnterHooks) => {
const migrationRedirects = (nextState, replaceState, cb) => {
const state = store.getState();
if (!state.main.migrationMode) {
replaceState('/data/schema');
replaceState(globals.urlPrefix + '/data/schema');
cb();
}
cb();
};
const consoleModeRedirects = (nextState, replaceState, cb) => {
if (globals.consoleMode === 'hasuradb') {
replaceState('/data/schema');
replaceState(globals.urlPrefix + '/data/schema');
cb();
}
cb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
}

.changeSchema {
height: 25px;
margin-left: 10px;
width: auto;
}
Expand Down
2 changes: 1 addition & 1 deletion console/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const routes = store => {
},
() => {
alert(
'Not able to reach the cluster. Check if hasura console server is running or if cluster exists and try again'
'Not able to reach the graphql server. Check if hasura console server is running or if graphql server is running and try again'
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion console/src/utils/requestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const requestAction = (
});
dispatch({ type: LOGIN_IN_PROGRESS, data: false });
dispatch({ type: LOGIN_ERROR, data: false });
dispatch(push('/login'));
dispatch(push(globals.urlPrefix + '/login'));
}
reject(msg);
});
Expand Down