diff options
Diffstat (limited to 'src/routes.tsx')
-rw-r--r-- | src/routes.tsx | 159 |
1 files changed, 121 insertions, 38 deletions
diff --git a/src/routes.tsx b/src/routes.tsx index 490d13ee8..1f929531e 100644 --- a/src/routes.tsx +++ b/src/routes.tsx | |||
@@ -1,6 +1,11 @@ | |||
1 | import { Component, ReactElement } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { Router, Route, IndexRedirect } from 'react-router'; | 3 | import { Route } from 'react-router'; |
4 | import { | ||
5 | Navigate, | ||
6 | Routes, | ||
7 | unstable_HistoryRouter as HistoryRouter, | ||
8 | } from 'react-router-dom'; | ||
4 | 9 | ||
5 | import AppLayoutContainer from './containers/layout/AppLayoutContainer'; | 10 | import AppLayoutContainer from './containers/layout/AppLayoutContainer'; |
6 | import SettingsWindow from './containers/settings/SettingsWindow'; | 11 | import SettingsWindow from './containers/settings/SettingsWindow'; |
@@ -25,59 +30,137 @@ import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; | |||
25 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; | 30 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; |
26 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; | 31 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; |
27 | import { WORKSPACES_ROUTES } from './features/workspaces/constants'; | 32 | import { WORKSPACES_ROUTES } from './features/workspaces/constants'; |
33 | import { Actions } from './actions/lib/actions'; | ||
34 | import { RealStores } from './stores'; | ||
28 | 35 | ||
29 | type Props = { | 36 | type Props = { |
37 | stores: RealStores; | ||
38 | actions: Actions; | ||
30 | history: any; | 39 | history: any; |
31 | }; | 40 | }; |
32 | 41 | ||
33 | class Routes extends Component<Props> { | 42 | class FerdiumRoutes extends Component<Props> { |
34 | render(): ReactElement { | 43 | render(): ReactElement { |
35 | const { history } = this.props; | 44 | const { history } = this.props; |
45 | const routeProps = { | ||
46 | stores: this.props.stores, | ||
47 | actions: this.props.actions, | ||
48 | }; | ||
49 | const errorProps = { | ||
50 | error: this.props.stores.globalError.error || {}, | ||
51 | }; | ||
36 | 52 | ||
37 | return ( | 53 | return ( |
38 | <Router history={history}> | 54 | <HistoryRouter history={history}> |
39 | <Route path="/" component={AppLayoutContainer}> | 55 | <Routes> |
40 | <Route path="/settings" component={SettingsWindow}> | 56 | <Route path="/auth" element={<AuthLayoutContainer {...routeProps} />}> |
41 | <IndexRedirect to="/settings/recipes" /> | ||
42 | <Route path="/settings/recipes" component={RecipesScreen} /> | ||
43 | <Route path="/settings/recipes/:filter" component={RecipesScreen} /> | ||
44 | <Route path="/settings/services" component={ServicesScreen} /> | ||
45 | <Route | 57 | <Route |
46 | path="/settings/services/:action/:id" | 58 | path="/auth" |
47 | component={EditServiceScreen} | 59 | element={<Navigate to="/auth/welcome" replace />} |
48 | /> | 60 | /> |
49 | <Route path={WORKSPACES_ROUTES.ROOT} component={WorkspacesScreen} /> | ||
50 | <Route | 61 | <Route |
51 | path={WORKSPACES_ROUTES.EDIT} | 62 | path="/auth/welcome" |
52 | component={EditWorkspaceScreen} | 63 | element={<WelcomeScreen {...routeProps} />} |
64 | /> | ||
65 | <Route | ||
66 | path="/auth/login" | ||
67 | element={<LoginScreen {...routeProps} {...errorProps} />} | ||
68 | /> | ||
69 | <Route | ||
70 | path="/auth/server" | ||
71 | element={<ChangeServerScreen {...routeProps} />} | ||
72 | /> | ||
73 | <Route path="/auth/signup"> | ||
74 | <Route | ||
75 | path="/auth/signup" | ||
76 | element={<Navigate to="/auth/signup/form" replace />} | ||
77 | /> | ||
78 | <Route | ||
79 | path="/auth/signup/form" | ||
80 | element={<SignupScreen {...routeProps} {...errorProps} />} | ||
81 | /> | ||
82 | <Route | ||
83 | path="/auth/signup/import" | ||
84 | element={<ImportScreen {...routeProps} />} | ||
85 | /> | ||
86 | <Route | ||
87 | path="/auth/signup/setup" | ||
88 | element={<SetupAssistentScreen {...routeProps} />} | ||
89 | /> | ||
90 | <Route | ||
91 | path="/auth/signup/invite" | ||
92 | element={<InviteScreen {...routeProps} />} | ||
93 | /> | ||
94 | </Route> | ||
95 | <Route | ||
96 | path="/auth/password" | ||
97 | element={<PasswordScreen {...routeProps} />} | ||
98 | /> | ||
99 | <Route | ||
100 | path="/auth/logout" | ||
101 | element={<LoginScreen {...routeProps} {...errorProps} />} | ||
53 | /> | 102 | /> |
54 | <Route path="/settings/user" component={AccountScreen} /> | ||
55 | <Route path="/settings/user/edit" component={EditUserScreen} /> | ||
56 | <Route path="/settings/team" component={TeamScreen} /> | ||
57 | <Route path="/settings/app" component={EditSettingsScreen} /> | ||
58 | <Route path="/settings/invite" component={InviteSettingsScreen} /> | ||
59 | <Route path="/settings/support" component={SupportFerdiumScreen} /> | ||
60 | </Route> | 103 | </Route> |
61 | </Route> | 104 | |
62 | <Route path="/auth" component={AuthLayoutContainer}> | 105 | <Route path="/" element={<AppLayoutContainer {...routeProps} />}> |
63 | <IndexRedirect to="/auth/welcome" /> | 106 | <Route |
64 | <Route path="/auth/welcome" component={WelcomeScreen} /> | 107 | path="/settings" |
65 | <Route path="/auth/login" component={LoginScreen} /> | 108 | element={<SettingsWindow {...this.props} />} |
66 | <Route path="/auth/server" component={ChangeServerScreen} /> | 109 | > |
67 | <Route path="/auth/signup"> | 110 | <Route |
68 | <IndexRedirect to="/auth/signup/form" /> | 111 | path="/settings/recipes" |
69 | <Route path="/auth/signup/form" component={SignupScreen} /> | 112 | element={<RecipesScreen {...this.props} />} |
70 | <Route path="/auth/signup/import" component={ImportScreen} /> | 113 | /> |
71 | <Route path="/auth/signup/setup" component={SetupAssistentScreen} /> | 114 | <Route |
72 | <Route path="/auth/signup/invite" component={InviteScreen} /> | 115 | path="/settings/recipes/:filter" |
116 | element={<RecipesScreen {...this.props} />} | ||
117 | /> | ||
118 | <Route | ||
119 | path="/settings/services" | ||
120 | element={<ServicesScreen {...this.props} />} | ||
121 | /> | ||
122 | <Route | ||
123 | path="/settings/services/:action/:id" | ||
124 | element={<EditServiceScreen {...this.props} />} | ||
125 | /> | ||
126 | <Route | ||
127 | path={WORKSPACES_ROUTES.ROOT} | ||
128 | element={<WorkspacesScreen {...this.props} />} | ||
129 | /> | ||
130 | <Route | ||
131 | path={WORKSPACES_ROUTES.EDIT} | ||
132 | element={<EditWorkspaceScreen {...this.props} />} | ||
133 | /> | ||
134 | <Route | ||
135 | path="/settings/user" | ||
136 | element={<AccountScreen {...this.props} />} | ||
137 | /> | ||
138 | <Route | ||
139 | path="/settings/user/edit" | ||
140 | element={<EditUserScreen {...this.props} />} | ||
141 | /> | ||
142 | <Route | ||
143 | path="/settings/team" | ||
144 | element={<TeamScreen {...this.props} />} | ||
145 | /> | ||
146 | <Route | ||
147 | path="/settings/app" | ||
148 | element={<EditSettingsScreen {...this.props} />} | ||
149 | /> | ||
150 | <Route | ||
151 | path="/settings/invite" | ||
152 | element={<InviteSettingsScreen {...this.props} />} | ||
153 | /> | ||
154 | <Route | ||
155 | path="/settings/support" | ||
156 | element={<SupportFerdiumScreen {...this.props} />} | ||
157 | /> | ||
158 | </Route> | ||
73 | </Route> | 159 | </Route> |
74 | <Route path="/auth/password" component={PasswordScreen} /> | 160 | </Routes> |
75 | <Route path="/auth/logout" component={LoginScreen} /> | 161 | </HistoryRouter> |
76 | </Route> | ||
77 | <Route path="*" component={AppLayoutContainer} /> | ||
78 | </Router> | ||
79 | ); | 162 | ); |
80 | } | 163 | } |
81 | } | 164 | } |
82 | 165 | ||
83 | export default inject('stores', 'actions')(observer(Routes)); | 166 | export default inject('stores', 'actions')(observer(FerdiumRoutes)); |