|
|
@@ -31,7 +31,6 @@ export default class AppContainer extends Container {
|
|
|
|
|
|
const body = document.querySelector('body');
|
|
|
|
|
|
- this.me = body.dataset.currentUsername || null; // will be initialized with null when data is empty string
|
|
|
this.isAdmin = body.dataset.isAdmin === 'true';
|
|
|
this.csrfToken = body.dataset.csrftoken;
|
|
|
this.isPluginEnabled = body.dataset.pluginEnabled === 'true';
|
|
|
@@ -39,6 +38,11 @@ export default class AppContainer extends Container {
|
|
|
|
|
|
this.config = JSON.parse(document.getElementById('growi-context-hydrate').textContent || '{}');
|
|
|
|
|
|
+ const currentUserElem = document.getElementById('growi-current-user');
|
|
|
+ if (currentUserElem != null) {
|
|
|
+ this.currentUser = JSON.parse(currentUserElem.textContent);
|
|
|
+ }
|
|
|
+
|
|
|
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
|
this.isMobile = /iphone|ipad|android/.test(userAgent);
|
|
|
|
|
|
@@ -107,6 +111,20 @@ export default class AppContainer extends Container {
|
|
|
window.crowiPlugin = window.growiPlugin;
|
|
|
}
|
|
|
|
|
|
+ get currentUserId() {
|
|
|
+ if (this.currentUser == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.currentUser._id;
|
|
|
+ }
|
|
|
+
|
|
|
+ get currentUsername() {
|
|
|
+ if (this.currentUser == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.currentUser.username;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return {Object} window.Crowi (js/legacy/crowi.js)
|
|
|
*/
|