diff options
author | Ricardo Cino <ricardo@cino.io> | 2022-07-07 09:31:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 09:31:50 +0200 |
commit | 71c52373f81cace664047edd19d9d289f45a4dff (patch) | |
tree | 69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/components/settings/navigation/SettingsNavigation.js | |
parent | 6.0.0-nightly.91 [skip ci] (diff) | |
download | ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.gz ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.zst ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.zip |
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/components/settings/navigation/SettingsNavigation.js')
-rw-r--r-- | src/components/settings/navigation/SettingsNavigation.js | 169 |
1 files changed, 0 insertions, 169 deletions
diff --git a/src/components/settings/navigation/SettingsNavigation.js b/src/components/settings/navigation/SettingsNavigation.js deleted file mode 100644 index ad1cef1e4..000000000 --- a/src/components/settings/navigation/SettingsNavigation.js +++ /dev/null | |||
@@ -1,169 +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 'mobx-react-router'; | ||
6 | |||
7 | import { LOCAL_SERVER, LIVE_FERDIUM_API, LIVE_FRANZ_API } from '../../../config'; | ||
8 | import Link from '../../ui/Link'; | ||
9 | import UIStore from '../../../stores/UIStore'; | ||
10 | import SettingsStore from '../../../stores/SettingsStore'; | ||
11 | import UserStore from '../../../stores/UserStore'; | ||
12 | import globalMessages from '../../../i18n/globalMessages'; | ||
13 | |||
14 | const messages = defineMessages({ | ||
15 | availableServices: { | ||
16 | id: 'settings.navigation.availableServices', | ||
17 | defaultMessage: 'Available services', | ||
18 | }, | ||
19 | yourServices: { | ||
20 | id: 'settings.navigation.yourServices', | ||
21 | defaultMessage: 'Your services', | ||
22 | }, | ||
23 | yourWorkspaces: { | ||
24 | id: 'settings.navigation.yourWorkspaces', | ||
25 | defaultMessage: 'Your workspaces', | ||
26 | }, | ||
27 | account: { | ||
28 | id: 'settings.navigation.account', | ||
29 | defaultMessage: 'Account', | ||
30 | }, | ||
31 | team: { | ||
32 | id: 'settings.navigation.team', | ||
33 | defaultMessage: 'Manage Team', | ||
34 | }, | ||
35 | supportFerdium: { | ||
36 | id: 'settings.navigation.supportFerdium', | ||
37 | defaultMessage: 'About Ferdium', | ||
38 | }, | ||
39 | logout: { | ||
40 | id: 'settings.navigation.logout', | ||
41 | defaultMessage: 'Logout', | ||
42 | }, | ||
43 | }); | ||
44 | |||
45 | class SettingsNavigation extends Component { | ||
46 | static propTypes = { | ||
47 | stores: PropTypes.shape({ | ||
48 | ui: PropTypes.instanceOf(UIStore).isRequired, | ||
49 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
50 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
51 | router: PropTypes.instanceOf(RouterStore).isRequired, | ||
52 | }).isRequired, | ||
53 | actions: PropTypes.shape({ | ||
54 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
55 | }).isRequired, | ||
56 | serviceCount: PropTypes.number.isRequired, | ||
57 | workspaceCount: PropTypes.number.isRequired, | ||
58 | }; | ||
59 | |||
60 | handleLogout() { | ||
61 | const isUsingWithoutAccount = | ||
62 | this.props.stores.settings.app.server === LOCAL_SERVER; | ||
63 | |||
64 | // Remove current auth token | ||
65 | localStorage.removeItem('authToken'); | ||
66 | |||
67 | if (isUsingWithoutAccount) { | ||
68 | // Reset server back to Ferdium API | ||
69 | this.props.actions.settings.update({ | ||
70 | type: 'app', | ||
71 | data: { | ||
72 | server: LIVE_FERDIUM_API, | ||
73 | }, | ||
74 | }); | ||
75 | } | ||
76 | this.props.stores.user.isLoggingOut = true; | ||
77 | |||
78 | this.props.stores.router.push('/auth/welcome'); | ||
79 | |||
80 | // Reload Ferdium, otherwise many settings won't sync correctly with the server | ||
81 | // after logging into another account | ||
82 | window.location.reload(); | ||
83 | } | ||
84 | |||
85 | render() { | ||
86 | const { serviceCount, workspaceCount, stores } = this.props; | ||
87 | const { intl } = this.props; | ||
88 | const isUsingWithoutAccount = stores.settings.app.server === LOCAL_SERVER; | ||
89 | const isUsingFranzServer = stores.settings.app.server === LIVE_FRANZ_API; | ||
90 | |||
91 | return ( | ||
92 | <div className="settings-navigation"> | ||
93 | <Link | ||
94 | to="/settings/recipes" | ||
95 | className="settings-navigation__link" | ||
96 | activeClassName="is-active" | ||
97 | > | ||
98 | {intl.formatMessage(messages.availableServices)} | ||
99 | </Link> | ||
100 | <Link | ||
101 | to="/settings/services" | ||
102 | className="settings-navigation__link" | ||
103 | activeClassName="is-active" | ||
104 | > | ||
105 | {intl.formatMessage(messages.yourServices)}{' '} | ||
106 | <span className="badge">{serviceCount}</span> | ||
107 | </Link> | ||
108 | <Link | ||
109 | to="/settings/workspaces" | ||
110 | className="settings-navigation__link" | ||
111 | activeClassName="is-active" | ||
112 | > | ||
113 | {intl.formatMessage(messages.yourWorkspaces)}{' '} | ||
114 | <span className="badge">{workspaceCount}</span> | ||
115 | </Link> | ||
116 | {!isUsingWithoutAccount && ( | ||
117 | <Link | ||
118 | to="/settings/user" | ||
119 | className="settings-navigation__link" | ||
120 | activeClassName="is-active" | ||
121 | > | ||
122 | {intl.formatMessage(messages.account)} | ||
123 | </Link> | ||
124 | )} | ||
125 | {isUsingFranzServer && ( | ||
126 | <Link | ||
127 | to="/settings/team" | ||
128 | className="settings-navigation__link" | ||
129 | activeClassName="is-active" | ||
130 | > | ||
131 | {intl.formatMessage(messages.team)} | ||
132 | </Link> | ||
133 | )} | ||
134 | <Link | ||
135 | to="/settings/app" | ||
136 | className="settings-navigation__link" | ||
137 | activeClassName="is-active" | ||
138 | > | ||
139 | {intl.formatMessage(globalMessages.settings)} | ||
140 | {stores.settings.app.automaticUpdates && (stores.ui.showServicesUpdatedInfoBar || | ||
141 | (stores.app.updateStatus === stores.app.updateStatusTypes.AVAILABLE || | ||
142 | stores.app.updateStatus === stores.app.updateStatusTypes.DOWNLOADED)) && ( | ||
143 | <span className="update-available">•</span> | ||
144 | )} | ||
145 | </Link> | ||
146 | <Link | ||
147 | to="/settings/support" | ||
148 | className="settings-navigation__link" | ||
149 | activeClassName="is-active" | ||
150 | > | ||
151 | {intl.formatMessage(messages.supportFerdium)} | ||
152 | </Link> | ||
153 | <span className="settings-navigation__expander" /> | ||
154 | <button | ||
155 | type="button" | ||
156 | to='/auth/logout' | ||
157 | className="settings-navigation__link" | ||
158 | onClick={this.handleLogout.bind(this)} | ||
159 | > | ||
160 | {!isUsingWithoutAccount | ||
161 | ? intl.formatMessage(messages.logout) | ||
162 | : 'Exit session'} | ||
163 | </button> | ||
164 | </div> | ||
165 | ); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | export default injectIntl(inject('stores', 'actions')(observer(SettingsNavigation))); | ||