diff options
author | 2022-10-27 07:13:47 +0530 | |
---|---|---|
committer | 2022-10-27 01:43:47 +0000 | |
commit | 81c43ecc3d17e0dbf7ad1d949b6d977f2c65bd48 (patch) | |
tree | dfa7c08cb54fb81b7d2e788d350de52c2ebd05d2 /src/components/settings/navigation/SettingsNavigation.jsx | |
parent | 6.2.1-nightly.30 [skip ci] (diff) | |
download | ferdium-app-81c43ecc3d17e0dbf7ad1d949b6d977f2c65bd48.tar.gz ferdium-app-81c43ecc3d17e0dbf7ad1d949b6d977f2c65bd48.tar.zst ferdium-app-81c43ecc3d17e0dbf7ad1d949b6d977f2c65bd48.zip |
fix: 'failed prop' warning in QuickSwitchModal, SettingsNavigation, SettingsWindow and Recipe component tree (#713)
* chore: turn off eslint rule @typescript-eslint/no-useless-constructor to initialize dynamic props & state
Co-authored-by: Muhamed <>
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/components/settings/navigation/SettingsNavigation.jsx')
-rw-r--r-- | src/components/settings/navigation/SettingsNavigation.jsx | 213 |
1 files changed, 0 insertions, 213 deletions
diff --git a/src/components/settings/navigation/SettingsNavigation.jsx b/src/components/settings/navigation/SettingsNavigation.jsx deleted file mode 100644 index e1242a7fe..000000000 --- a/src/components/settings/navigation/SettingsNavigation.jsx +++ /dev/null | |||
@@ -1,213 +0,0 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { defineMessages, injectIntl } from 'react-intl'; | ||
4 | import { inject, observer } from 'mobx-react'; | ||
5 | import { RouterStore } from '@superwf/mobx-react-router'; | ||
6 | |||
7 | import { NavLink } from 'react-router-dom'; | ||
8 | import { | ||
9 | LOCAL_SERVER, | ||
10 | LIVE_FERDIUM_API, | ||
11 | LIVE_FRANZ_API, | ||
12 | } from '../../../config'; | ||
13 | import UIStore from '../../../stores/UIStore'; | ||
14 | import SettingsStore from '../../../stores/SettingsStore'; | ||
15 | import UserStore from '../../../stores/UserStore'; | ||
16 | import globalMessages from '../../../i18n/globalMessages'; | ||
17 | |||
18 | const messages = defineMessages({ | ||
19 | availableServices: { | ||
20 | id: 'settings.navigation.availableServices', | ||
21 | defaultMessage: 'Available services', | ||
22 | }, | ||
23 | yourServices: { | ||
24 | id: 'settings.navigation.yourServices', | ||
25 | defaultMessage: 'Your services', | ||
26 | }, | ||
27 | yourWorkspaces: { | ||
28 | id: 'settings.navigation.yourWorkspaces', | ||
29 | defaultMessage: 'Your workspaces', | ||
30 | }, | ||
31 | account: { | ||
32 | id: 'settings.navigation.account', | ||
33 | defaultMessage: 'Account', | ||
34 | }, | ||
35 | team: { | ||
36 | id: 'settings.navigation.team', | ||
37 | defaultMessage: 'Manage Team', | ||
38 | }, | ||
39 | releaseNotes: { | ||
40 | id: 'settings.navigation.releaseNotes', | ||
41 | defaultMessage: 'Release Notes', | ||
42 | }, | ||
43 | supportFerdium: { | ||
44 | id: 'settings.navigation.supportFerdium', | ||
45 | defaultMessage: 'About Ferdium', | ||
46 | }, | ||
47 | logout: { | ||
48 | id: 'settings.navigation.logout', | ||
49 | defaultMessage: 'Logout', | ||
50 | }, | ||
51 | }); | ||
52 | |||
53 | class SettingsNavigation extends Component { | ||
54 | static propTypes = { | ||
55 | stores: PropTypes.shape({ | ||
56 | ui: PropTypes.instanceOf(UIStore).isRequired, | ||
57 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
58 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
59 | router: PropTypes.instanceOf(RouterStore).isRequired, | ||
60 | }).isRequired, | ||
61 | actions: PropTypes.shape({ | ||
62 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
63 | }).isRequired, | ||
64 | serviceCount: PropTypes.number.isRequired, | ||
65 | workspaceCount: PropTypes.number.isRequired, | ||
66 | }; | ||
67 | |||
68 | handleLogout() { | ||
69 | const isUsingWithoutAccount = | ||
70 | this.props.stores.settings.app.server === LOCAL_SERVER; | ||
71 | |||
72 | // Remove current auth token | ||
73 | localStorage.removeItem('authToken'); | ||
74 | |||
75 | if (isUsingWithoutAccount) { | ||
76 | // Reset server back to Ferdium API | ||
77 | this.props.actions.settings.update({ | ||
78 | type: 'app', | ||
79 | data: { | ||
80 | server: LIVE_FERDIUM_API, | ||
81 | }, | ||
82 | }); | ||
83 | } | ||
84 | this.props.stores.user.isLoggingOut = true; | ||
85 | |||
86 | this.props.stores.router.push('/auth/welcome'); | ||
87 | |||
88 | // Reload Ferdium, otherwise many settings won't sync correctly with the server | ||
89 | // after logging into another account | ||
90 | window.location.reload(); | ||
91 | } | ||
92 | |||
93 | render() { | ||
94 | const { serviceCount, workspaceCount, stores } = this.props; | ||
95 | const { intl } = this.props; | ||
96 | const isUsingWithoutAccount = stores.settings.app.server === LOCAL_SERVER; | ||
97 | const isUsingFranzServer = stores.settings.app.server === LIVE_FRANZ_API; | ||
98 | |||
99 | return ( | ||
100 | <div className="settings-navigation"> | ||
101 | <NavLink | ||
102 | to="/settings/recipes" | ||
103 | className={({ isActive }) => | ||
104 | isActive | ||
105 | ? 'settings-navigation__link is-active' | ||
106 | : 'settings-navigation__link' | ||
107 | } | ||
108 | > | ||
109 | {intl.formatMessage(messages.availableServices)} | ||
110 | </NavLink> | ||
111 | <NavLink | ||
112 | to="/settings/services" | ||
113 | className={({ isActive }) => | ||
114 | isActive | ||
115 | ? 'settings-navigation__link is-active' | ||
116 | : 'settings-navigation__link' | ||
117 | } | ||
118 | > | ||
119 | {intl.formatMessage(messages.yourServices)}{' '} | ||
120 | <span className="badge">{serviceCount}</span> | ||
121 | </NavLink> | ||
122 | <NavLink | ||
123 | to="/settings/workspaces" | ||
124 | className={({ isActive }) => | ||
125 | isActive | ||
126 | ? 'settings-navigation__link is-active' | ||
127 | : 'settings-navigation__link' | ||
128 | } | ||
129 | > | ||
130 | {intl.formatMessage(messages.yourWorkspaces)}{' '} | ||
131 | <span className="badge">{workspaceCount}</span> | ||
132 | </NavLink> | ||
133 | {!isUsingWithoutAccount && ( | ||
134 | <NavLink | ||
135 | to="/settings/user" | ||
136 | className={({ isActive }) => | ||
137 | isActive | ||
138 | ? 'settings-navigation__link is-active' | ||
139 | : 'settings-navigation__link' | ||
140 | } | ||
141 | > | ||
142 | {intl.formatMessage(messages.account)} | ||
143 | </NavLink> | ||
144 | )} | ||
145 | {isUsingFranzServer && ( | ||
146 | <NavLink | ||
147 | to="/settings/team" | ||
148 | className={({ isActive }) => | ||
149 | isActive | ||
150 | ? 'settings-navigation__link is-active' | ||
151 | : 'settings-navigation__link' | ||
152 | } | ||
153 | > | ||
154 | {intl.formatMessage(messages.team)} | ||
155 | </NavLink> | ||
156 | )} | ||
157 | <NavLink | ||
158 | to="/settings/app" | ||
159 | className={({ isActive }) => | ||
160 | isActive | ||
161 | ? 'settings-navigation__link is-active' | ||
162 | : 'settings-navigation__link' | ||
163 | } | ||
164 | > | ||
165 | {intl.formatMessage(globalMessages.settings)} | ||
166 | {stores.settings.app.automaticUpdates && | ||
167 | (stores.ui.showServicesUpdatedInfoBar || | ||
168 | stores.app.updateStatus === | ||
169 | stores.app.updateStatusTypes.AVAILABLE || | ||
170 | stores.app.updateStatus === | ||
171 | stores.app.updateStatusTypes.DOWNLOADED) && ( | ||
172 | <span className="update-available">•</span> | ||
173 | )} | ||
174 | </NavLink> | ||
175 | <NavLink | ||
176 | to="/settings/releasenotes" | ||
177 | className={({ isActive }) => | ||
178 | isActive | ||
179 | ? 'settings-navigation__link is-active' | ||
180 | : 'settings-navigation__link' | ||
181 | } | ||
182 | > | ||
183 | {intl.formatMessage(messages.releaseNotes)} | ||
184 | </NavLink> | ||
185 | <NavLink | ||
186 | to="/settings/support" | ||
187 | className={({ isActive }) => | ||
188 | isActive | ||
189 | ? 'settings-navigation__link is-active' | ||
190 | : 'settings-navigation__link' | ||
191 | } | ||
192 | > | ||
193 | {intl.formatMessage(messages.supportFerdium)} | ||
194 | </NavLink> | ||
195 | <span className="settings-navigation__expander" /> | ||
196 | <button | ||
197 | type="button" | ||
198 | to="/auth/logout" | ||
199 | className="settings-navigation__link" | ||
200 | onClick={this.handleLogout.bind(this)} | ||
201 | > | ||
202 | {!isUsingWithoutAccount | ||
203 | ? intl.formatMessage(messages.logout) | ||
204 | : 'Exit session'} | ||
205 | </button> | ||
206 | </div> | ||
207 | ); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | export default injectIntl( | ||
212 | inject('stores', 'actions')(observer(SettingsNavigation)), | ||
213 | ); | ||