Repository navigation
Expand file tree
/
Copy pathroutes.js
More file actions
190 lines (164 loc) · 6.22 KB
/
Copy pathroutes.js
File metadata and controls
190 lines (164 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import React from 'react';
import { Route, IndexRedirect, IndexRoute } from 'react-router';
import { connect } from 'react-redux';
import globals from './Globals';
import { App, Main, PageNotFound } from 'components';
import validateLogin from './utils/validateLogin';
import { requireAsyncGlobals } from './components/App/Actions';
import { composeOnEnterHooks } from 'utils/router';
import { loadMigrationStatus } from './components/Main/Actions';
import { dataRouterUtils } from './components/Services/Data';
import { getRemoteSchemaRouter } from './components/Services/RemoteSchema';
import { getActionsRouter } from './components/Services/Actions';
import { eventsRoutes } from './components/Services/Events';
import generatedApiExplorer from './components/Services/ApiExplorer/ApiExplorer';
import generatedVoyagerConnector from './components/Services/VoyagerView/VoyagerView';
import generatedLoginConnector from './components/Login/Login';
import settingsContainer from './components/Services/Settings/Container';
import ApiContainer from './components/Services/ApiExplorer/Container';
import metadataOptionsConnector from './components/Services/Settings/MetadataOptions/MetadataOptions';
import metadataStatusConnector from './components/Services/Settings/MetadataStatus/MetadataStatus';
import allowedQueriesConnector from './components/Services/Settings/AllowedQueries/AllowedQueries';
import inheritedRolesConnector from './components/Services/Settings/InheritedRoles/InheritedRoles';
import logoutConnector from './components/Services/Settings/Logout/Logout';
import aboutConnector from './components/Services/Settings/About/About';
import { showErrorNotification } from './components/Services/Common/Notification';
import { CLI_CONSOLE_MODE } from './constants';
import UIKit from './components/UIKit/';
import { Heading } from './components/UIKit/atoms';
import { SupportContainer } from './components/Services/Support/SupportContainer';
import HelpPage from './components/Services/Support/HelpPage';
import CreateRestView from './components/Services/ApiExplorer/Rest/Create/';
import RestListView from './components/Services/ApiExplorer/Rest/List';
import DetailsView from './components/Services/ApiExplorer/Rest/Details';
import TempHerokuCallback from './components/Services/Data/DataSources/CreateDataSource/Heroku/TempCallback';
const routes = store => {
// load hasuractl migration status
const requireMigrationStatus = (nextState, replaceState, cb) => {
const { dispatch } = store;
if (globals.consoleMode === CLI_CONSOLE_MODE) {
dispatch(loadMigrationStatus()).then(
() => {
cb();
},
r => {
if (r && r.code === 'data_api_error') {
dispatch(showErrorNotification('Error', null, r));
} else {
dispatch(
showErrorNotification(
'Connection error',
'Hasura console is not able to reach your Hasura CLI instance. Please ensure that your ' +
'instance is running and the endpoint is configured correctly.'
)
);
}
cb();
}
);
} else {
cb();
}
return;
};
const _dataRouterUtils = dataRouterUtils(
connect,
store,
composeOnEnterHooks,
() => {
return {};
},
() => {
return { public: [], personal: [] };
}
);
const requireSource = _dataRouterUtils.requireSource;
const dataRouter = _dataRouterUtils.makeDataRouter;
const remoteSchemaRouter = getRemoteSchemaRouter(
connect,
store,
composeOnEnterHooks
);
const actionsRouter = getActionsRouter(connect, store, composeOnEnterHooks);
const uiKitRouter = globals.isProduction ? null : (
<Route
path="/ui-elements"
// TODO: fix me
component={() => (
<div>
<Heading />
<UIKit />
</div>
)}
/>
);
return (
<Route
path="/"
component={App}
onEnter={composeOnEnterHooks([validateLogin(store)])}
>
<Route path="login" component={generatedLoginConnector(connect)} />
{/*Temp route, it'll be in dashboard*/}
<Route path="heroku-callback" component={TempHerokuCallback} />
<Route
path=""
component={Main}
onEnter={composeOnEnterHooks([
requireSource,
requireMigrationStatus,
requireAsyncGlobals(store),
])}
>
<IndexRoute component={ApiContainer} />
<Route path="api" component={ApiContainer}>
<IndexRedirect to="api-explorer" />
<Route
path="api-explorer"
component={generatedApiExplorer(connect)}
/>
<Route path="rest">
<IndexRedirect to="list" />
<Route path="create" component={CreateRestView} />
<Route path="list" component={RestListView} />
<Route path="details/:name" component={DetailsView} />
<Route path="edit/:name" component={CreateRestView} />
</Route>
</Route>
<Route
path="voyager-view"
component={generatedVoyagerConnector(connect)}
/>
<Route path="settings" component={settingsContainer(connect)}>
<IndexRedirect to="metadata-actions" />
<Route
path="metadata-actions"
component={metadataOptionsConnector(connect)}
/>
<Route
path="metadata-status"
component={metadataStatusConnector(connect)}
/>
<Route
path="allow-list"
component={allowedQueriesConnector(connect)}
/>
<Route path="logout" component={logoutConnector(connect)} />
<Route path="about" component={aboutConnector(connect)} />
<Route path="inherited-roles" component={inheritedRolesConnector} />
</Route>
{dataRouter}
{remoteSchemaRouter}
{actionsRouter}
{eventsRoutes}
{uiKitRouter}
<Route path="support" component={SupportContainer}>
<Route path="forums" component={HelpPage} />
</Route>
</Route>
<Route path="404" component={PageNotFound} status="404" />
<Route path="*" component={PageNotFound} status="404" />
</Route>
);
};
export default routes;