aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes.tsx
blob: 436f25ea4593b23d9913e0ce225b52f8cebf4ea7 (plain) (blame)
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
191
192
193
194
195
196
197
198
199
200
201
import { Component, ReactElement } from 'react';
import { inject, observer } from 'mobx-react';
import {
  Navigate,
  Route,
  Routes,
  unstable_HistoryRouter as HistoryRouter,
} from 'react-router-dom';
import { HashHistory } from 'history';
import AppLayoutContainer from './containers/layout/AppLayoutContainer';
import SettingsWindow from './containers/settings/SettingsWindow';
import ReleaseNotesWindow from './containers/settings/ReleaseNotesWindow';
import RecipesScreen from './containers/settings/RecipesScreen';
import ServicesScreen from './containers/settings/ServicesScreen';
import EditServiceScreen from './containers/settings/EditServiceScreen';
import AccountScreen from './containers/settings/AccountScreen';
import TeamScreen from './containers/settings/TeamScreen';
import EditUserScreen from './containers/settings/EditUserScreen';
import EditSettingsScreen from './containers/settings/EditSettingsScreen';
import InviteSettingsScreen from './containers/settings/InviteScreen';
import SupportFerdiumScreen from './containers/settings/SupportScreen';
import ReleaseNotesScreen from './containers/settings/ReleaseNotesScreen';
import WelcomeScreen from './containers/auth/WelcomeScreen';
import LoginScreen from './containers/auth/LoginScreen';
import AuthReleaseNotesScreen from './containers/auth/AuthReleaseNotesScreen';
import PasswordScreen from './containers/auth/PasswordScreen';
import ChangeServerScreen from './containers/auth/ChangeServerScreen';
import SignupScreen from './containers/auth/SignupScreen';
import SetupAssistantScreen from './containers/auth/SetupAssistantScreen';
import InviteScreen from './containers/auth/InviteScreen';
import AuthLayoutContainer from './containers/auth/AuthLayoutContainer';
import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen';
import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen';
import { WORKSPACES_ROUTES } from './features/workspaces/constants';
import { StoresProps } from './@types/ferdium-components.types';
import { Actions } from './actions/lib/actions';
import { RealStores } from './stores';
import DownloadManagerScreen from './containers/download-manager/DownloadManagerScreen';
import DownloadManagerWindow from './containers/download-manager/DownloadManagerWindow';

interface IProps {
  history: HashHistory;
  actions?: Actions;
  stores?: RealStores;
}

@inject('stores', 'actions')
@observer
class FerdiumRoutes extends Component<IProps> {
  render(): ReactElement {
    const { history, stores, actions } = this.props;
    const routeProps: StoresProps = { stores: stores!, actions: actions! };
    const errorProps = { error: routeProps.stores.globalError.error || {} };

    return (
      // @ts-expect-error Fix me
      <HistoryRouter history={history}>
        <Routes>
          <Route path="/auth" element={<AuthLayoutContainer {...routeProps} />}>
            <Route
              path="/auth"
              element={<Navigate to="/auth/welcome" replace />}
            />
            <Route
              path="/auth/welcome"
              element={<WelcomeScreen {...routeProps} />}
            />
            <Route
              path="/auth/login"
              element={<LoginScreen {...routeProps} {...errorProps} />}
            />
            <Route
              path="/auth/server"
              element={<ChangeServerScreen {...routeProps} />}
            />
            <Route path="/auth/signup">
              <Route
                path="/auth/signup"
                element={<Navigate to="/auth/signup/form" replace />}
              />
              <Route
                path="/auth/signup/form"
                element={<SignupScreen {...routeProps} {...errorProps} />}
              />
              <Route
                path="/auth/signup/setup"
                element={<SetupAssistantScreen {...routeProps} />}
              />
              <Route
                path="/auth/signup/invite"
                element={<InviteScreen {...routeProps} />}
              />
            </Route>
            <Route
              path="/auth/password"
              element={<PasswordScreen {...routeProps} />}
            />
            <Route
              path="/auth/logout"
              element={<LoginScreen {...routeProps} {...errorProps} />}
            />
            <Route
              path="/auth/releasenotes"
              element={
                <AuthReleaseNotesScreen {...routeProps} {...errorProps} />
              }
            />
          </Route>

          <Route path="/" element={<AppLayoutContainer {...routeProps} />}>
            <Route
              path="/releasenotes"
              element={<ReleaseNotesWindow {...this.props} />}
            >
              <Route
                path="/releasenotes"
                element={<ReleaseNotesScreen {...this.props} />}
              />
            </Route>
            <Route
              path="/downloadmanager"
              element={<DownloadManagerWindow {...this.props} />}
            >
              <Route
                path="/downloadmanager"
                element={<DownloadManagerScreen {...this.props} />}
              />
            </Route>
            <Route
              path="/settings"
              element={<SettingsWindow {...this.props} />}
            >
              <Route
                path="/settings/recipes"
                element={<RecipesScreen {...this.props} />}
              />
              <Route
                path="/settings/recipes/:filter"
                element={<RecipesScreen {...this.props} />}
              />
              <Route
                path="/settings/services"
                // @ts-expect-error Fix me
                element={<ServicesScreen {...this.props} />}
              />
              <Route
                path="/settings/services/:action/:id"
                element={<EditServiceScreen {...this.props} />}
              />
              <Route
                path={WORKSPACES_ROUTES.ROOT}
                // @ts-expect-error Fix me
                element={<WorkspacesScreen {...this.props} />}
              />
              <Route
                path={WORKSPACES_ROUTES.EDIT}
                // @ts-expect-error Fix me
                element={<EditWorkspaceScreen {...this.props} />}
              />
              <Route
                path="/settings/user"
                // @ts-expect-error Fix me
                element={<AccountScreen {...this.props} />}
              />
              <Route
                path="/settings/user/edit"
                // @ts-expect-error Fix me
                element={<EditUserScreen {...this.props} />}
              />
              <Route
                path="/settings/team"
                // @ts-expect-error Fix me
                element={<TeamScreen {...this.props} />}
              />
              <Route
                path="/settings/app"
                // @ts-expect-error Fix me
                element={<EditSettingsScreen {...this.props} />}
              />
              <Route
                path="/settings/invite"
                // @ts-expect-error Fix me
                element={<InviteSettingsScreen {...this.props} />}
              />
              <Route
                path="/settings/support"
                element={<SupportFerdiumScreen {...this.props} />}
              />
              <Route
                path="/settings/releasenotes"
                element={<ReleaseNotesScreen {...this.props} />}
              />
            </Route>
          </Route>
        </Routes>
      </HistoryRouter>
    );
  }
}

export default FerdiumRoutes;