1 | import UserEditor from './UserEditor.js'
|
2 | import LogoutSettingsButton from './LogoutSettingsButton.js'
|
3 | import ChangePasswordSettingsButton from './ChangePasswordSettingsButton.js'
|
4 | import ChangePasswordButton from './ChangePasswordButton.js'
|
5 | import Studio from 'jsreport-studio'
|
6 | import NewUserModal from './NewUserModal.js'
|
7 |
|
8 |
|
9 | Studio.initializeListeners.unshift(async () => {
|
10 | const response = await Studio.api.get('/api/settings')
|
11 |
|
12 | if (!response.tenant) {
|
13 |
|
14 | return
|
15 | }
|
16 |
|
17 | Studio.authentication = { user: response.tenant }
|
18 |
|
19 | if (Studio.authentication.user.isAdmin) {
|
20 | Studio.addEntitySet({
|
21 | name: 'users',
|
22 | faIcon: 'fa-user',
|
23 | visibleName: 'user',
|
24 | nameAttribute: 'username',
|
25 | onNew: () => Studio.openModal(NewUserModal)
|
26 | })
|
27 | Studio.addEditorComponent('users', UserEditor)
|
28 | Studio.addToolbarComponent(ChangePasswordButton)
|
29 | }
|
30 |
|
31 | Studio.addToolbarComponent(ChangePasswordSettingsButton, 'settings')
|
32 | Studio.addToolbarComponent(() => <div className='toolbar-button'><span><i
|
33 | className='fa fa-user' /> {Studio.authentication.user.username}</span></div>, 'settingsBottom')
|
34 | Studio.addToolbarComponent(LogoutSettingsButton, 'settingsBottom')
|
35 | })
|
36 |
|
\ | No newline at end of file |