这是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
2 changes: 2 additions & 0 deletions console/src/Endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const Endpoints = {
schemaChange: `${baseUrl}/v1/query`,
query: `${baseUrl}/v1/query`,
rawSQL: `${baseUrl}/v1/query`,
version: `${baseUrl}/v1/version`,
updateCheck: 'https://releases.hasura.io/graphql-engine',
hasuractlMigrate: `${hasuractlUrl}/apis/migrate`,
hasuractlMetadata: `${hasuractlUrl}/apis/metadata`,
hasuractlMigrateSettings: `${hasuractlUrl}/apis/migrate/settings`,
Expand Down
1 change: 0 additions & 1 deletion console/src/components/ApiExplorer/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ const graphqlSubscriber = (graphQLParams, url, headers) => {
};
return fetcher(graphQLParams);
} catch (e) {
console.log(e);
return e.json();
}
};
Expand Down
86 changes: 86 additions & 0 deletions console/src/components/Main/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import globals from 'Globals';
import defaultState from './State';
import Endpoints from '../../Endpoints';
import requestAction from '../../utils/requestAction';
import requestActionPlain from '../../utils/requestActionPlain';
import { globalCookiePolicy } from '../../Endpoints';
import { saveAccessKeyState } from '../AppState';
import {
Expand All @@ -13,6 +14,11 @@ import { changeRequestHeader } from '../ApiExplorer/Actions';

const SET_MIGRATION_STATUS_SUCCESS = 'Main/SET_MIGRATION_STATUS_SUCCESS';
const SET_MIGRATION_STATUS_ERROR = 'Main/SET_MIGRATION_STATUS_ERROR';
const SET_SERVER_VERSION_SUCCESS = 'Main/SET_SERVER_VERSION_SUCCESS';
const SET_SERVER_VERSION_ERROR = 'Main/SET_SERVER_VERSION_ERROR';
const SET_LATEST_SERVER_VERSION_SUCCESS =
'Main/SET_LATEST_SERVER_VERSION_SUCCESS';
const SET_LATEST_SERVER_VERSION_ERROR = 'Main/SET_LATEST_SERVER_VERSION_ERROR';
const UPDATE_MIGRATION_STATUS_SUCCESS = 'Main/UPDATE_MIGRATION_STATUS_SUCCESS';
const UPDATE_MIGRATION_STATUS_ERROR = 'Main/UPDATE_MIGRATION_STATUS_ERROR';
const HASURACTL_URL_ENV = 'Main/HASURACTL_URL_ENV';
Expand Down Expand Up @@ -41,6 +47,63 @@ const loadMigrationStatus = () => dispatch => {
);
};

const loadServerVersion = () => dispatch => {
const url = Endpoints.version;
const options = {
method: 'GET',
credentials: globalCookiePolicy,
headers: { 'Content-Type': 'application/json' },
};
return dispatch(requestActionPlain(url, options)).then(
data => {
let parsedVersion;
try {
parsedVersion = JSON.parse(data);
dispatch({
type: SET_SERVER_VERSION_SUCCESS,
data: parsedVersion.version,
});
} catch (e) {
console.error(e);
}
},
error => {
console.error(error);
dispatch({ type: SET_SERVER_VERSION_ERROR, data: null });
}
);
};

const checkServerUpdates = () => (dispatch, getState) => {
const url =
Endpoints.updateCheck +
'?agent=console&version=' +
getState().main.serverVersion;
const options = {
method: 'GET',
credentials: globalCookiePolicy,
headers: { 'Content-Type': 'application/json' },
};
return dispatch(requestActionPlain(url, options)).then(
data => {
let parsedVersion;
try {
parsedVersion = JSON.parse(data);
dispatch({
type: SET_LATEST_SERVER_VERSION_SUCCESS,
data: parsedVersion.latest,
});
} catch (e) {
console.error(e);
}
},
error => {
console.error(error);
dispatch({ type: SET_LATEST_SERVER_VERSION_ERROR, data: null });
}
);
};

const validateLogin = isInitialLoad => (dispatch, getState) => {
const url = Endpoints.getSchema;
const currentSchema = getState().tables.currentSchema;
Expand Down Expand Up @@ -149,6 +212,27 @@ const mainReducer = (state = defaultState, action) => {
...state,
migrationMode: action.data.migration_mode === 'true',
};
case SET_SERVER_VERSION_SUCCESS:
return {
...state,
serverVersion: action.data,
};
case SET_SERVER_VERSION_ERROR:
return {
...state,
serverVersion: null,
};

case SET_LATEST_SERVER_VERSION_SUCCESS:
return {
...state,
latestServerVersion: action.data,
};
case SET_LATEST_SERVER_VERSION_ERROR:
return {
...state,
latestServerVersion: null,
};
case UPDATE_MIGRATION_STATUS_SUCCESS:
return {
...state,
Expand Down Expand Up @@ -204,4 +288,6 @@ export {
LOGIN_IN_PROGRESS,
LOGIN_ERROR,
validateLogin,
loadServerVersion,
checkServerUpdates,
};
Loading