@jetbrains/ring-ui 5.0.36 → 5.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/input/input.css +2 -0
- package/components/query-assist/query-assist.js +1 -1
- package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -4
- package/dist/_helpers/anchor.js +0 -1
- package/dist/_helpers/card.js +0 -3
- package/dist/_helpers/dialog__body-scroll-preventer.js +0 -11
- package/dist/_helpers/footer.js +2 -13
- package/dist/_helpers/query-assist__suggestions.js +0 -10
- package/dist/_helpers/select__filter.js +0 -11
- package/dist/_helpers/services-link.js +0 -2
- package/dist/_helpers/sidebar.js +0 -12
- package/dist/_helpers/theme.js +0 -3
- package/dist/_helpers/title.js +0 -9
- package/dist/alert/alert.js +2 -32
- package/dist/alert/container.js +0 -5
- package/dist/alert-service/alert-service.js +0 -26
- package/dist/analytics/analytics.js +0 -22
- package/dist/analytics/analytics__custom-plugin.js +0 -38
- package/dist/analytics/analytics__fus-plugin.js +0 -20
- package/dist/analytics/analytics__ga-plugin.js +0 -13
- package/dist/analytics/analytics__plugin-utils.js +0 -8
- package/dist/analytics-ng/analytics-ng.js +3 -9
- package/dist/auth/auth.js +2 -3
- package/dist/auth/auth__core.js +30 -243
- package/dist/auth/background-flow.js +2 -25
- package/dist/auth/down-notification.js +0 -7
- package/dist/auth/iframe-flow.js +2 -26
- package/dist/auth/landing.js +2 -6
- package/dist/auth/request-builder.js +0 -11
- package/dist/auth/response-parser.js +4 -26
- package/dist/auth/storage.js +4 -60
- package/dist/auth/token-validator.js +6 -42
- package/dist/auth/window-flow.js +2 -34
- package/dist/auth-dialog/auth-dialog.js +2 -12
- package/dist/auth-dialog-service/auth-dialog-service.js +2 -4
- package/dist/auth-ng/auth-ng.js +6 -22
- package/dist/auth-ng/auth-ng.mock.js +0 -4
- package/dist/autofocus-ng/autofocus-ng.js +0 -5
- package/dist/avatar/avatar.js +4 -17
- package/dist/avatar/fallback-avatar.js +2 -9
- package/dist/avatar-editor-ng/avatar-editor-ng.js +1 -17
- package/dist/badge/badge.js +0 -3
- package/dist/button/button.js +0 -8
- package/dist/button-group/button-group.js +0 -3
- package/dist/button-group/caption.js +0 -2
- package/dist/button-group-ng/button-group-ng.js +0 -4
- package/dist/button-ng/button-ng.js +3 -21
- package/dist/button-set/button-set.js +0 -3
- package/dist/button-set-ng/button-set-ng.js +0 -2
- package/dist/button-toolbar/button-toolbar.js +0 -3
- package/dist/button-toolbar-ng/button-toolbar-ng.js +0 -2
- package/dist/caret/caret.js +2 -53
- package/dist/checkbox/checkbox.js +0 -12
- package/dist/code/code.js +3 -25
- package/dist/compiler-ng/compiler-ng.js +0 -5
- package/dist/confirm/confirm.js +0 -6
- package/dist/confirm-service/confirm-service.js +10 -8
- package/dist/content-layout/content-layout.js +0 -7
- package/dist/contenteditable/contenteditable.js +6 -13
- package/dist/data-list/data-list.js +4 -28
- package/dist/data-list/item.js +0 -15
- package/dist/data-list/selection.js +0 -27
- package/dist/date-picker/consts.js +0 -7
- package/dist/date-picker/date-input.js +0 -20
- package/dist/date-picker/date-picker.js +2 -36
- package/dist/date-picker/date-popup.js +18 -71
- package/dist/date-picker/day.js +0 -14
- package/dist/date-picker/month-names.js +0 -9
- package/dist/date-picker/month-slider.js +0 -10
- package/dist/date-picker/month.js +2 -4
- package/dist/date-picker/months.js +6 -13
- package/dist/date-picker/years.js +0 -14
- package/dist/dialog/dialog.js +0 -19
- package/dist/dialog-ng/dialog-ng.js +17 -105
- package/dist/docked-panel-ng/docked-panel-ng.js +6 -29
- package/dist/dropdown/dropdown.js +2 -33
- package/dist/dropdown-menu/dropdown-menu.js +4 -8
- package/dist/editable-heading/editable-heading.js +0 -3
- package/dist/error-bubble/error-bubble.js +2 -4
- package/dist/error-message/error-message.js +0 -3
- package/dist/footer-ng/footer-ng.js +0 -13
- package/dist/form-ng/form-ng.js +1 -21
- package/dist/global/angular-component-factory.js +0 -10
- package/dist/global/compose.js +0 -1
- package/dist/global/composeRefs.js +0 -1
- package/dist/global/controls-height.js +0 -2
- package/dist/global/create-stateful-context.js +0 -5
- package/dist/global/data-tests.js +0 -4
- package/dist/global/dom.js +2 -11
- package/dist/global/focus-sensor-hoc.js +4 -33
- package/dist/global/fuzzy-highlight.js +2 -16
- package/dist/global/get-event-key.js +8 -17
- package/dist/global/get-uid.js +0 -2
- package/dist/global/linear-function.js +0 -2
- package/dist/global/listeners.js +0 -13
- package/dist/global/memoize.js +0 -2
- package/dist/global/normalize-indent.js +2 -5
- package/dist/global/react-dom-renderer.js +0 -8
- package/dist/global/react-render-adapter.js +0 -7
- package/dist/global/rerender-hoc.js +0 -7
- package/dist/global/ring-angular-component.js +0 -5
- package/dist/global/schedule-raf.js +0 -5
- package/dist/global/trivial-template-tag.js +2 -3
- package/dist/global/url.js +0 -27
- package/dist/grid/col.js +0 -4
- package/dist/grid/grid.js +0 -3
- package/dist/grid/row.js +0 -5
- package/dist/group/group.js +0 -3
- package/dist/header/header.js +0 -5
- package/dist/header/logo.js +0 -4
- package/dist/header/profile.js +0 -7
- package/dist/header/services.js +0 -11
- package/dist/header/smart-profile.js +4 -18
- package/dist/header/smart-services.js +0 -17
- package/dist/header/tray-icon.js +2 -3
- package/dist/header/tray.js +0 -3
- package/dist/heading/heading.js +0 -5
- package/dist/http/http.js +20 -65
- package/dist/http/http.mock.js +2 -14
- package/dist/hub-source/hub-source.js +0 -32
- package/dist/hub-source/hub-source__user.js +0 -1
- package/dist/hub-source/hub-source__users-groups.js +0 -12
- package/dist/icon/icon.js +0 -13
- package/dist/icon/icon__constants.js +0 -4
- package/dist/icon/icon__svg.js +0 -10
- package/dist/icon-ng/icon-ng.js +2 -7
- package/dist/input/input.js +0 -30
- package/dist/input-ng/input-ng.js +0 -17
- package/dist/island/adaptive-island-hoc.js +0 -7
- package/dist/island/content.js +0 -25
- package/dist/island/header.js +0 -7
- package/dist/island/island.js +0 -4
- package/dist/island-legacy/content-legacy.js +0 -2
- package/dist/island-legacy/header-legacy.js +0 -2
- package/dist/island-legacy/island-legacy.js +0 -2
- package/dist/island-ng/island-content-ng.js +0 -3
- package/dist/link/clickableLink.js +2 -10
- package/dist/link/link.js +2 -9
- package/dist/link-ng/link-ng.js +0 -2
- package/dist/list/consts.js +0 -4
- package/dist/list/list.js +6 -128
- package/dist/list/list__custom.js +0 -4
- package/dist/list/list__hint.js +0 -3
- package/dist/list/list__item.js +0 -8
- package/dist/list/list__link.js +2 -3
- package/dist/list/list__separator.js +0 -1
- package/dist/list/list__title.js +0 -1
- package/dist/list/list__users-groups-source.js +4 -17
- package/dist/loader/loader.js +0 -10
- package/dist/loader/loader__core.js +6 -70
- package/dist/loader-inline/loader-inline.js +0 -3
- package/dist/loader-ng/loader-ng.js +0 -7
- package/dist/loader-screen/loader-screen.js +0 -3
- package/dist/loader-screen-ng/loader-screen-ng.js +2 -14
- package/dist/login-dialog/login-dialog.js +0 -15
- package/dist/login-dialog/service.js +2 -4
- package/dist/markdown/code.js +0 -2
- package/dist/markdown/heading.js +0 -1
- package/dist/markdown/link.js +0 -1
- package/dist/markdown/markdown.js +0 -2
- package/dist/message/message.js +0 -24
- package/dist/message-bundle-ng/message-bundle-ng.js +2 -45
- package/dist/old-browsers-message/old-browsers-message.js +2 -21
- package/dist/old-browsers-message/white-list.js +2 -6
- package/dist/pager/pager.js +2 -39
- package/dist/panel/panel.js +0 -3
- package/dist/permissions/permissions.js +1 -43
- package/dist/permissions/permissions__cache.js +12 -63
- package/dist/permissions-ng/permissions-ng.js +11 -19
- package/dist/place-under-ng/place-under-ng.js +0 -19
- package/dist/popup/popup.consts.js +0 -11
- package/dist/popup/popup.js +6 -68
- package/dist/popup/position.js +8 -30
- package/dist/popup-menu/popup-menu.js +4 -13
- package/dist/progress-bar/progress-bar.js +0 -14
- package/dist/promised-click-ng/promised-click-ng.js +3 -22
- package/dist/query-assist/query-assist.js +17 -201
- package/dist/radio/radio.js +0 -6
- package/dist/radio/radio__item.js +0 -9
- package/dist/radio-ng/radio-ng.js +0 -4
- package/dist/save-field-ng/save-field-ng.js +1 -37
- package/dist/select/select.js +18 -208
- package/dist/select/select__popup.js +4 -76
- package/dist/select-ng/select-ng.js +18 -74
- package/dist/select-ng/select-ng__lazy.js +2 -17
- package/dist/select-ng/select-ng__options.js +3 -29
- package/dist/shortcuts/core.js +4 -56
- package/dist/shortcuts/shortcuts-hoc.js +0 -4
- package/dist/shortcuts/shortcuts.js +0 -10
- package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -13
- package/dist/shortcuts-ng/shortcuts-ng.js +16 -46
- package/dist/sidebar-ng/sidebar-ng.js +2 -12
- package/dist/storage/storage.js +2 -5
- package/dist/storage/storage__fallback.js +2 -48
- package/dist/storage/storage__local.js +0 -23
- package/dist/style.css +1 -1
- package/dist/tab-trap/tab-trap.js +0 -37
- package/dist/table/cell.js +0 -2
- package/dist/table/disable-hover-hoc.js +0 -9
- package/dist/table/header-cell.js +0 -8
- package/dist/table/header.js +0 -16
- package/dist/table/multitable.js +0 -23
- package/dist/table/row-with-focus-sensor.js +0 -12
- package/dist/table/row.js +0 -18
- package/dist/table/selection-adapter.js +0 -2
- package/dist/table/selection-shortcuts-hoc.js +8 -42
- package/dist/table/selection.js +0 -50
- package/dist/table/smart-table.js +0 -9
- package/dist/table/table.js +6 -37
- package/dist/table-legacy-ng/table-legacy-ng.js +12 -42
- package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +0 -31
- package/dist/table-legacy-ng/table-legacy-ng__selection.js +0 -32
- package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +2 -5
- package/dist/tabs/collapsible-more.js +0 -5
- package/dist/tabs/collapsible-tab.js +0 -4
- package/dist/tabs/collapsible-tabs.js +8 -28
- package/dist/tabs/dumb-tabs.js +0 -8
- package/dist/tabs/smart-tabs.js +0 -6
- package/dist/tabs/tab-link.js +0 -1
- package/dist/tabs/tab.js +0 -2
- package/dist/tabs-ng/tabs-ng.js +13 -29
- package/dist/tag/tag.js +0 -24
- package/dist/tags-input/tags-input.js +0 -76
- package/dist/tags-list/tags-list.js +0 -6
- package/dist/template-ng/template-ng.js +0 -12
- package/dist/text/text.js +0 -3
- package/dist/theme-ng/theme-ng.js +0 -8
- package/dist/title-ng/title-ng.js +6 -17
- package/dist/toggle/toggle.js +0 -4
- package/dist/tooltip/tooltip.js +4 -35
- package/dist/tooltip-ng/tooltip-ng.js +2 -8
- package/dist/user-agreement/service.js +0 -62
- package/dist/user-agreement/user-agreement.js +0 -8
- package/dist/user-card/smart-user-card-tooltip.js +2 -8
- package/dist/user-card/tooltip.js +0 -3
- package/package.json +15 -15
|
@@ -25,49 +25,37 @@ import PermissionCache from './permissions__cache.js';
|
|
|
25
25
|
* <code>serviceId</code> if provided then permissions only for the service are loaded.
|
|
26
26
|
* @constructor
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
28
|
class Permissions {
|
|
30
29
|
/**
|
|
31
30
|
* @const {string}
|
|
32
31
|
*/
|
|
32
|
+
|
|
33
33
|
constructor(auth) {
|
|
34
34
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
-
|
|
36
35
|
_defineProperty(this, "query", void 0);
|
|
37
|
-
|
|
38
36
|
_defineProperty(this, "namesConverter", void 0);
|
|
39
|
-
|
|
40
37
|
_defineProperty(this, "_auth", void 0);
|
|
41
|
-
|
|
42
38
|
_defineProperty(this, "_datasource", void 0);
|
|
43
|
-
|
|
44
39
|
_defineProperty(this, "_promise", void 0);
|
|
45
|
-
|
|
46
40
|
_defineProperty(this, "_subscribed", void 0);
|
|
47
|
-
|
|
48
41
|
_defineProperty(this, "_permissionCache", void 0);
|
|
49
|
-
|
|
50
42
|
_defineProperty(this, "_defaultDatasource", query => this._auth.http.get(Permissions.API_PERMISSION_CACHE_PATH, {
|
|
51
43
|
query: {
|
|
52
44
|
fields: 'permission/key,global,projects(id)',
|
|
53
45
|
query
|
|
54
46
|
}
|
|
55
47
|
}));
|
|
56
|
-
|
|
57
48
|
this.query = Permissions.getPermissionQuery(config.services);
|
|
58
49
|
this.namesConverter = config.prefix ? Permissions.getDefaultNamesConverter(config.prefix) : config.namesConverter;
|
|
59
|
-
|
|
60
50
|
if (!auth) {
|
|
61
51
|
throw new Error('Parameter auth is required');
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
this._auth = auth;
|
|
65
54
|
this._datasource = config.datasource || this._defaultDatasource;
|
|
66
55
|
this._promise = null;
|
|
67
56
|
this._subscribed = false;
|
|
68
57
|
this._permissionCache = new PermissionCache(null, this.namesConverter);
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
/**
|
|
72
60
|
* Returns function, which cuts off prefix from server-side permission name
|
|
73
61
|
*
|
|
@@ -83,35 +71,26 @@ class Permissions {
|
|
|
83
71
|
}
|
|
84
72
|
};
|
|
85
73
|
}
|
|
86
|
-
|
|
87
74
|
static getPermissionQuery(services) {
|
|
88
75
|
if (!services || !services.length) {
|
|
89
76
|
return undefined;
|
|
90
77
|
}
|
|
91
|
-
|
|
92
78
|
return services.map(service => `service:{${service}}`).join(' or ');
|
|
93
79
|
}
|
|
94
|
-
|
|
95
80
|
set(cachedPermissions) {
|
|
96
81
|
this._permissionCache.set(cachedPermissions);
|
|
97
|
-
|
|
98
82
|
this._setCache(Promise.resolve(this._permissionCache));
|
|
99
|
-
|
|
100
83
|
return this._permissionCache;
|
|
101
84
|
}
|
|
102
|
-
|
|
103
85
|
get() {
|
|
104
86
|
return this._permissionCache.get();
|
|
105
87
|
}
|
|
106
|
-
|
|
107
88
|
_setCache(value) {
|
|
108
89
|
this._promise = value;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
_getCache() {
|
|
112
92
|
return this._promise;
|
|
113
93
|
}
|
|
114
|
-
|
|
115
94
|
_resetCache() {
|
|
116
95
|
this._setCache(null);
|
|
117
96
|
}
|
|
@@ -120,42 +99,30 @@ class Permissions {
|
|
|
120
99
|
* @param {object?} options
|
|
121
100
|
* @return {Promise.<Permissions>} promise that is resolved when the permissions are loaded
|
|
122
101
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
102
|
load(options) {
|
|
126
103
|
if (this._subscribed === false) {
|
|
127
104
|
this._auth.addListener('userChange', () => {
|
|
128
105
|
this.reload();
|
|
129
106
|
});
|
|
130
|
-
|
|
131
107
|
this._subscribed = true;
|
|
132
108
|
}
|
|
133
|
-
|
|
134
109
|
const cache = this._getCache();
|
|
135
|
-
|
|
136
110
|
if (!hasCacheControl('NO_CACHE', options) && cache) {
|
|
137
111
|
return cache;
|
|
138
112
|
}
|
|
139
|
-
|
|
140
113
|
if (hasCacheControl('NO_STORE', options)) {
|
|
141
114
|
return this._loadPermissions().then(cachedPermissions => new PermissionCache(cachedPermissions, this.namesConverter));
|
|
142
115
|
}
|
|
143
|
-
|
|
144
116
|
const permissions = this._loadPermissions().then(cachedPermissions => this.set(cachedPermissions));
|
|
145
|
-
|
|
146
117
|
this._setCache(permissions);
|
|
147
|
-
|
|
148
118
|
return permissions;
|
|
149
|
-
|
|
150
119
|
function hasCacheControl(value, _options) {
|
|
151
120
|
if (_options && _options.cacheControl) {
|
|
152
121
|
return _options.cacheControl[value];
|
|
153
122
|
}
|
|
154
|
-
|
|
155
123
|
return false;
|
|
156
124
|
}
|
|
157
125
|
}
|
|
158
|
-
|
|
159
126
|
_loadPermissions() {
|
|
160
127
|
return this._datasource(this.query);
|
|
161
128
|
}
|
|
@@ -163,11 +130,8 @@ class Permissions {
|
|
|
163
130
|
* Reloads permission cache from server
|
|
164
131
|
* @returns {Promise.<Permissions>} promise that is resolved when the permissions are reloaded
|
|
165
132
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
133
|
reload() {
|
|
169
134
|
this._resetCache();
|
|
170
|
-
|
|
171
135
|
return this.load();
|
|
172
136
|
}
|
|
173
137
|
/**
|
|
@@ -180,8 +144,6 @@ class Permissions {
|
|
|
180
144
|
*
|
|
181
145
|
* @return {Promise.<boolean>}
|
|
182
146
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
147
|
check(permissions, projectId) {
|
|
186
148
|
return this.load().then(permissionCache => permissionCache.has(permissions, projectId));
|
|
187
149
|
}
|
|
@@ -202,8 +164,6 @@ class Permissions {
|
|
|
202
164
|
*
|
|
203
165
|
* @return {Promise.<boolean>}
|
|
204
166
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
167
|
bindVariable(object, propertyName, permissions, projectId) {
|
|
208
168
|
object[propertyName] = false;
|
|
209
169
|
return this.check(permissions, projectId).then(permitted => {
|
|
@@ -211,9 +171,7 @@ class Permissions {
|
|
|
211
171
|
return permitted;
|
|
212
172
|
});
|
|
213
173
|
}
|
|
214
|
-
|
|
215
174
|
}
|
|
216
|
-
|
|
217
175
|
_defineProperty(Permissions, "API_PERMISSION_CACHE_PATH", 'permissions/cache');
|
|
218
176
|
|
|
219
177
|
export { Permissions as default };
|
|
@@ -23,48 +23,36 @@ class PermissionCache {
|
|
|
23
23
|
*/
|
|
24
24
|
static _toProjectIdSet(projects) {
|
|
25
25
|
let projectIdSet = null;
|
|
26
|
-
|
|
27
26
|
if (projects) {
|
|
28
27
|
projectIdSet = {};
|
|
29
|
-
|
|
30
28
|
for (let i = 0; i < projects.length; i++) {
|
|
31
29
|
projectIdSet[projects[i].id] = true;
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
return projectIdSet;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
constructor(permissions, namesConverter) {
|
|
39
35
|
_defineProperty(this, "namesConverter", void 0);
|
|
40
|
-
|
|
41
36
|
_defineProperty(this, "_permissions", void 0);
|
|
42
|
-
|
|
43
37
|
_defineProperty(this, "permissionCache", void 0);
|
|
44
|
-
|
|
45
38
|
this.namesConverter = namesConverter || (key => key);
|
|
46
|
-
|
|
47
39
|
this.set(permissions);
|
|
48
40
|
}
|
|
49
|
-
|
|
50
41
|
set(permissions) {
|
|
51
42
|
const permissionCache = (permissions || []).reduce((_permissionCache, permission) => {
|
|
52
43
|
const key = this.namesConverter(permission.permission.key);
|
|
53
|
-
|
|
54
44
|
if (key) {
|
|
55
45
|
_permissionCache[key] = {
|
|
56
46
|
global: permission.global,
|
|
57
47
|
projectIdSet: this.constructor._toProjectIdSet(permission.projects)
|
|
58
48
|
};
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
return _permissionCache;
|
|
62
51
|
}, {});
|
|
63
52
|
this._permissions = permissions;
|
|
64
53
|
this.permissionCache = permissionCache;
|
|
65
54
|
return this;
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
get() {
|
|
69
57
|
return this._permissions;
|
|
70
58
|
}
|
|
@@ -77,15 +65,11 @@ class PermissionCache {
|
|
|
77
65
|
*
|
|
78
66
|
* @return {boolean}
|
|
79
67
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
68
|
has(permissions, projectId) {
|
|
83
69
|
const lexems = this.lex(permissions);
|
|
84
|
-
|
|
85
70
|
if (lexems.length === 0) {
|
|
86
71
|
return true;
|
|
87
72
|
}
|
|
88
|
-
|
|
89
73
|
try {
|
|
90
74
|
return this.or(lexems, projectId);
|
|
91
75
|
} catch (e) {
|
|
@@ -98,14 +82,10 @@ class PermissionCache {
|
|
|
98
82
|
* @param {string} query
|
|
99
83
|
* @return {string[]}
|
|
100
84
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
85
|
lex(query) {
|
|
104
86
|
const lexems = [];
|
|
105
|
-
|
|
106
87
|
if (query) {
|
|
107
88
|
let currentIdentifier = '';
|
|
108
|
-
|
|
109
89
|
for (let i = 0; i < query.length; i++) {
|
|
110
90
|
switch (query.charAt(i)) {
|
|
111
91
|
case ' ':
|
|
@@ -116,11 +96,9 @@ class PermissionCache {
|
|
|
116
96
|
if (currentIdentifier) {
|
|
117
97
|
lexems.push(currentIdentifier);
|
|
118
98
|
currentIdentifier = '';
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
99
|
+
}
|
|
100
|
+
// Skip space
|
|
122
101
|
break;
|
|
123
|
-
|
|
124
102
|
case '(':
|
|
125
103
|
case ')':
|
|
126
104
|
case '&':
|
|
@@ -130,23 +108,19 @@ class PermissionCache {
|
|
|
130
108
|
if (currentIdentifier) {
|
|
131
109
|
lexems.push(currentIdentifier);
|
|
132
110
|
currentIdentifier = '';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
}
|
|
112
|
+
// Append operator
|
|
136
113
|
lexems.push(query.charAt(i));
|
|
137
114
|
break;
|
|
138
|
-
|
|
139
115
|
default:
|
|
140
116
|
currentIdentifier += query.charAt(i);
|
|
141
117
|
break;
|
|
142
118
|
}
|
|
143
119
|
}
|
|
144
|
-
|
|
145
120
|
if (currentIdentifier) {
|
|
146
121
|
lexems.push(currentIdentifier);
|
|
147
122
|
}
|
|
148
123
|
}
|
|
149
|
-
|
|
150
124
|
return lexems;
|
|
151
125
|
}
|
|
152
126
|
/*
|
|
@@ -156,25 +130,19 @@ class PermissionCache {
|
|
|
156
130
|
term -> '(' or ')' | permission
|
|
157
131
|
permission -> [^()&|!\s]+
|
|
158
132
|
*/
|
|
159
|
-
|
|
160
133
|
/**
|
|
161
134
|
* @param {string[]} lexems
|
|
162
135
|
* @param {string=} projectId
|
|
163
136
|
* @return {boolean}
|
|
164
137
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
138
|
or(lexems, projectId) {
|
|
168
139
|
let result = this.and(lexems, projectId);
|
|
169
|
-
|
|
170
140
|
while (lexems.length > 0 && lexems[0] !== ')') {
|
|
171
141
|
if (lexems.shift() !== '|') {
|
|
172
142
|
throw new Error('Operator \'|\' was expected');
|
|
173
143
|
}
|
|
174
|
-
|
|
175
144
|
result = this.and(lexems, projectId) || result;
|
|
176
145
|
}
|
|
177
|
-
|
|
178
146
|
return result;
|
|
179
147
|
}
|
|
180
148
|
/**
|
|
@@ -182,20 +150,15 @@ class PermissionCache {
|
|
|
182
150
|
* @param {string=} projectId
|
|
183
151
|
* @return {boolean}
|
|
184
152
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
153
|
and(lexems, projectId) {
|
|
188
154
|
let result = this.not(lexems, projectId);
|
|
189
|
-
|
|
190
155
|
while (lexems.length > 0 && lexems[0] !== ')' && lexems[0] !== '|') {
|
|
191
156
|
// Expect optional '&'
|
|
192
157
|
if (lexems[0] === '&') {
|
|
193
158
|
lexems.shift();
|
|
194
159
|
}
|
|
195
|
-
|
|
196
160
|
result = this.not(lexems, projectId) && result;
|
|
197
161
|
}
|
|
198
|
-
|
|
199
162
|
return result;
|
|
200
163
|
}
|
|
201
164
|
/**
|
|
@@ -203,16 +166,12 @@ class PermissionCache {
|
|
|
203
166
|
* @param {string=} projectId
|
|
204
167
|
* @return {boolean}
|
|
205
168
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
169
|
not(lexems, projectId) {
|
|
209
170
|
let notCounter = 0;
|
|
210
|
-
|
|
211
171
|
while (lexems.length > 0 && lexems[0] === '!') {
|
|
212
172
|
++notCounter;
|
|
213
173
|
lexems.shift();
|
|
214
174
|
}
|
|
215
|
-
|
|
216
175
|
const result = this.term(lexems, projectId);
|
|
217
176
|
return notCounter % 2 === 0 ? result : !result;
|
|
218
177
|
}
|
|
@@ -221,26 +180,22 @@ class PermissionCache {
|
|
|
221
180
|
* @param {string=} projectId
|
|
222
181
|
* @return {boolean}
|
|
223
182
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
183
|
term(lexems, projectId) {
|
|
227
184
|
if (lexems.length === 0) {
|
|
228
185
|
throw new Error('Operand was expected');
|
|
229
186
|
}
|
|
230
|
-
|
|
231
187
|
const t = lexems.shift();
|
|
232
|
-
let result;
|
|
233
|
-
|
|
188
|
+
let result;
|
|
189
|
+
// Nested parenthesized expression
|
|
234
190
|
if (t === '(') {
|
|
235
|
-
result = this.or(lexems, projectId);
|
|
236
|
-
|
|
191
|
+
result = this.or(lexems, projectId);
|
|
192
|
+
// Expect ')'
|
|
237
193
|
if (lexems.shift() !== ')') {
|
|
238
194
|
throw new Error('Operator \')\' was expected');
|
|
239
195
|
}
|
|
240
196
|
} else {
|
|
241
197
|
result = t != null && this.testPermission(t, projectId);
|
|
242
198
|
}
|
|
243
|
-
|
|
244
199
|
return result;
|
|
245
200
|
}
|
|
246
201
|
/**
|
|
@@ -248,22 +203,18 @@ class PermissionCache {
|
|
|
248
203
|
* @param {string=} projectId
|
|
249
204
|
* @return {boolean}
|
|
250
205
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
206
|
testPermission(permissionName, projectId) {
|
|
254
207
|
const permissionCache = this.permissionCache;
|
|
255
208
|
const convertedName = this.namesConverter(permissionName);
|
|
256
|
-
const cachedPermission = (permissionCache === null || permissionCache === void 0 ? void 0 : permissionCache[permissionName]) || convertedName && (permissionCache === null || permissionCache === void 0 ? void 0 : permissionCache[convertedName]);
|
|
257
|
-
|
|
209
|
+
const cachedPermission = (permissionCache === null || permissionCache === void 0 ? void 0 : permissionCache[permissionName]) || convertedName && (permissionCache === null || permissionCache === void 0 ? void 0 : permissionCache[convertedName]);
|
|
210
|
+
// Hasn't the permission in any project
|
|
258
211
|
if (!cachedPermission) {
|
|
259
212
|
return false;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
213
|
+
}
|
|
214
|
+
// The permission is global or is given in the global project
|
|
263
215
|
if (cachedPermission.global) {
|
|
264
216
|
return true;
|
|
265
217
|
}
|
|
266
|
-
|
|
267
218
|
if (projectId) {
|
|
268
219
|
// if projectId is specified check that the permission is given in the project
|
|
269
220
|
return cachedPermission.projectIdSet != null && projectId in cachedPermission.projectIdSet;
|
|
@@ -271,9 +222,7 @@ class PermissionCache {
|
|
|
271
222
|
return true;
|
|
272
223
|
}
|
|
273
224
|
}
|
|
274
|
-
|
|
275
225
|
}
|
|
276
|
-
|
|
277
226
|
_defineProperty(PermissionCache, "GLOBAL_PROJECT_ID", 'global');
|
|
278
227
|
|
|
279
228
|
export { PermissionCache as default };
|
|
@@ -72,8 +72,8 @@ function registerPermission(element) {
|
|
|
72
72
|
const somePermissionsCtrl = element.controller('rgSomePermissions');
|
|
73
73
|
return somePermissionsCtrl && somePermissionsCtrl.registerPermission() || angular.noop;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
75
|
const angularModule = angular.module('Ring.permissions', ['Ring.auth']);
|
|
76
|
+
|
|
77
77
|
/**
|
|
78
78
|
* @ngdoc object
|
|
79
79
|
* @name userPermissions
|
|
@@ -87,23 +87,20 @@ const angularModule = angular.module('Ring.permissions', ['Ring.auth']);
|
|
|
87
87
|
* @property {?string} serviceId
|
|
88
88
|
* @property {?string} prefix
|
|
89
89
|
*/
|
|
90
|
-
|
|
91
90
|
angularModule.provider('userPermissions', function provider() {
|
|
92
91
|
/**
|
|
93
92
|
* @type {permissionsNgConfig}
|
|
94
93
|
*/
|
|
95
94
|
let _config = {};
|
|
95
|
+
|
|
96
96
|
/**
|
|
97
97
|
* @param {permissionsNgConfig} config
|
|
98
98
|
*/
|
|
99
|
-
|
|
100
99
|
this.config = config => {
|
|
101
100
|
_config = config;
|
|
102
101
|
};
|
|
103
|
-
|
|
104
102
|
this.$get = ["auth", "$q", "$http", (auth, $q, $http) => {
|
|
105
103
|
const apiUri = auth.auth.getAPIPath() + Permissions.API_PERMISSION_CACHE_PATH;
|
|
106
|
-
|
|
107
104
|
async function datasource(query) {
|
|
108
105
|
const {
|
|
109
106
|
data
|
|
@@ -115,17 +112,17 @@ angularModule.provider('userPermissions', function provider() {
|
|
|
115
112
|
});
|
|
116
113
|
return data;
|
|
117
114
|
}
|
|
118
|
-
|
|
119
115
|
_config.datasource = _config.datasource || datasource;
|
|
120
|
-
const permissions = new Permissions(auth.auth, _config);
|
|
116
|
+
const permissions = new Permissions(auth.auth, _config);
|
|
121
117
|
|
|
118
|
+
// Override load to execute in $digest
|
|
122
119
|
permissions.load = function load() {
|
|
123
120
|
return $q.when(Permissions.prototype.load.call(this));
|
|
124
121
|
};
|
|
125
|
-
|
|
126
122
|
return permissions;
|
|
127
123
|
}];
|
|
128
124
|
});
|
|
125
|
+
|
|
129
126
|
/**
|
|
130
127
|
* @ngdoc directive
|
|
131
128
|
* @name permission
|
|
@@ -139,28 +136,27 @@ angularModule.provider('userPermissions', function provider() {
|
|
|
139
136
|
* @element ANY
|
|
140
137
|
* @requires userPermissions
|
|
141
138
|
*/
|
|
142
|
-
|
|
143
139
|
angularModule.directive('rgPermission', ["userPermissions", "$interpolate", function rgPermissionDirective(userPermissions, $interpolate) {
|
|
144
140
|
return {
|
|
145
141
|
controller: ["$scope", "$element", "$attrs", function controller($scope, $element, $attrs) {
|
|
146
|
-
const element = $element[0];
|
|
142
|
+
const element = $element[0];
|
|
147
143
|
|
|
144
|
+
//noinspection JSPotentiallyInvalidUsageOfThis
|
|
148
145
|
this.permitted = false;
|
|
149
146
|
element.classList.add('ring-permission-hide');
|
|
150
147
|
const permission = $interpolate($attrs.rgPermission)($scope);
|
|
151
148
|
const projectId = $attrs.hasOwnProperty('inGlobal') ? PermissionCache.GLOBAL_PROJECT_ID : $scope.$eval($attrs.inProject);
|
|
152
149
|
userPermissions.check(permission, projectId).then(permitted => {
|
|
153
150
|
this.permitted = permitted;
|
|
154
|
-
|
|
155
151
|
if (permitted) {
|
|
156
152
|
element.classList.remove('ring-permission-hide');
|
|
157
153
|
}
|
|
158
|
-
|
|
159
154
|
return permitted;
|
|
160
155
|
}).then(registerPermission($element));
|
|
161
156
|
}]
|
|
162
157
|
};
|
|
163
158
|
}]);
|
|
159
|
+
|
|
164
160
|
/**
|
|
165
161
|
* @ngdoc directive
|
|
166
162
|
* @name permissionIf
|
|
@@ -189,7 +185,6 @@ angularModule.directive('rgPermission', ["userPermissions", "$interpolate", func
|
|
|
189
185
|
* @requires $animate
|
|
190
186
|
* @requires userPermissions
|
|
191
187
|
*/
|
|
192
|
-
|
|
193
188
|
angularModule.directive('rgPermissionIf', ["$animate", "userPermissions", "$interpolate", function rgPermissionIfDirective($animate, userPermissions, $interpolate) {
|
|
194
189
|
return {
|
|
195
190
|
transclude: 'element',
|
|
@@ -222,7 +217,6 @@ angularModule.directive('rgPermissionIf', ["$animate", "userPermissions", "$inte
|
|
|
222
217
|
childScope.$destroy();
|
|
223
218
|
childScope = null;
|
|
224
219
|
}
|
|
225
|
-
|
|
226
220
|
if (block) {
|
|
227
221
|
/* global getBlockElements: false */
|
|
228
222
|
$animate.leave(getBlockElements(block));
|
|
@@ -233,6 +227,7 @@ angularModule.directive('rgPermissionIf', ["$animate", "userPermissions", "$inte
|
|
|
233
227
|
}
|
|
234
228
|
};
|
|
235
229
|
}]);
|
|
230
|
+
|
|
236
231
|
/**
|
|
237
232
|
* @ngdoc directive
|
|
238
233
|
* @name rgSomePermissions
|
|
@@ -245,7 +240,6 @@ angularModule.directive('rgPermissionIf', ["$animate", "userPermissions", "$inte
|
|
|
245
240
|
* @restrict A
|
|
246
241
|
* @element ANY
|
|
247
242
|
*/
|
|
248
|
-
|
|
249
243
|
angularModule.directive('rgSomePermissions', function rgSomePermissionsDirective() {
|
|
250
244
|
return {
|
|
251
245
|
scope: {
|
|
@@ -254,7 +248,6 @@ angularModule.directive('rgSomePermissions', function rgSomePermissionsDirective
|
|
|
254
248
|
controller: ["$scope", function controller($scope) {
|
|
255
249
|
const permissions = [];
|
|
256
250
|
$scope.rgSomePermissions = false;
|
|
257
|
-
|
|
258
251
|
function checkPermissions() {
|
|
259
252
|
for (let i = permissions.length - 1; i >= 0; i--) {
|
|
260
253
|
if (permissions[i].permitted) {
|
|
@@ -262,11 +255,10 @@ angularModule.directive('rgSomePermissions', function rgSomePermissionsDirective
|
|
|
262
255
|
return;
|
|
263
256
|
}
|
|
264
257
|
}
|
|
265
|
-
|
|
266
258
|
$scope.rgSomePermissions = false;
|
|
267
|
-
}
|
|
268
|
-
|
|
259
|
+
}
|
|
269
260
|
|
|
261
|
+
//noinspection JSPotentiallyInvalidUsageOfThis
|
|
270
262
|
this.registerPermission = () => {
|
|
271
263
|
const permission = {
|
|
272
264
|
permitted: false
|
|
@@ -13,12 +13,10 @@ angularModule.directive('rgPlaceUnder', // eslint-disable-next-line angular/di-u
|
|
|
13
13
|
link: function link(scope, iElement, iAttrs) {
|
|
14
14
|
const element = iElement[0];
|
|
15
15
|
const synchronizer = rgPlaceUnderHelper.createPositionSynchronizer(element, iAttrs, scope);
|
|
16
|
-
|
|
17
16
|
function startSyncing(placeUnderSelector) {
|
|
18
17
|
if (placeUnderSelector) {
|
|
19
18
|
scope.$evalAsync(() => {
|
|
20
19
|
const syncWith = getClosestElementWithCommonParent(element, placeUnderSelector);
|
|
21
|
-
|
|
22
20
|
if (syncWith) {
|
|
23
21
|
synchronizer.syncPositionWith(syncWith);
|
|
24
22
|
} else {
|
|
@@ -27,7 +25,6 @@ angularModule.directive('rgPlaceUnder', // eslint-disable-next-line angular/di-u
|
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
iAttrs.$observe('rgPlaceUnder', startSyncing);
|
|
32
29
|
}
|
|
33
30
|
};
|
|
@@ -35,7 +32,6 @@ angularModule.directive('rgPlaceUnder', // eslint-disable-next-line angular/di-u
|
|
|
35
32
|
angularModule.factory('getClosestElementWithCommonParent', function getClosestElementWithCommonParentFactory() {
|
|
36
33
|
return function getClosestElementWithCommonParent(currentElement, selector) {
|
|
37
34
|
const parent = currentElement.parentNode;
|
|
38
|
-
|
|
39
35
|
if (parent) {
|
|
40
36
|
return parent.querySelector(selector) || getClosestElementWithCommonParent(parent, selector);
|
|
41
37
|
} else {
|
|
@@ -56,11 +52,9 @@ angularModule.factory('rgPlaceUnderHelper', ["$window", $window => {
|
|
|
56
52
|
const syncHeight = iAttrs.syncHeight;
|
|
57
53
|
let syncBottom = [];
|
|
58
54
|
let removeScrollListener = [];
|
|
59
|
-
|
|
60
55
|
if (iAttrs.syncBottom) {
|
|
61
56
|
syncBottom = iAttrs.syncBottom.split(',');
|
|
62
57
|
}
|
|
63
|
-
|
|
64
58
|
function waitForNonZeroHeight(elementToCheck) {
|
|
65
59
|
return new Promise(resolve => {
|
|
66
60
|
function checkElementHeight() {
|
|
@@ -70,11 +64,9 @@ angularModule.factory('rgPlaceUnderHelper', ["$window", $window => {
|
|
|
70
64
|
resolve();
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
|
-
|
|
74
67
|
checkElementHeight();
|
|
75
68
|
});
|
|
76
69
|
}
|
|
77
|
-
|
|
78
70
|
function onScroll(syncElement) {
|
|
79
71
|
const documentScrollTop = getDocumentScrollTop();
|
|
80
72
|
const documentOffsetHeight = $window.document.documentElement && $window.document.documentElement.offsetHeight || $window.document.body.offsetHeight;
|
|
@@ -83,47 +75,37 @@ angularModule.factory('rgPlaceUnderHelper', ["$window", $window => {
|
|
|
83
75
|
const bottom = syncedElementOffsetTop + syncedElementHeight;
|
|
84
76
|
const margin = Math.max(bottom - documentScrollTop, syncedElementHeight);
|
|
85
77
|
element.style.marginTop = `${margin + topOffset}px`;
|
|
86
|
-
|
|
87
78
|
if (syncHeight) {
|
|
88
79
|
/**
|
|
89
80
|
* Decrease height by margin value to make scroll work properly
|
|
90
81
|
*/
|
|
91
82
|
let bottomOffset = 0;
|
|
92
|
-
|
|
93
83
|
if (syncBottom.length) {
|
|
94
84
|
for (let i = 0; i < syncBottom.length; i++) {
|
|
95
85
|
const syncBottomParams = syncBottom[i].split(';');
|
|
96
86
|
const elem = $window.document.querySelector(syncBottomParams[0]);
|
|
97
87
|
const extraMargin = syncBottomParams[1] ? parseInt(syncBottomParams[1], 10) : 0;
|
|
98
|
-
|
|
99
88
|
if (elem) {
|
|
100
89
|
const boundingRect = elem.getBoundingClientRect();
|
|
101
|
-
|
|
102
90
|
if (boundingRect.top === 0) {
|
|
103
91
|
continue;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
const marginTop = parseInt($window.getComputedStyle(elem).getPropertyValue('margin-top'), 10);
|
|
107
94
|
bottomOffset = documentOffsetHeight - boundingRect.top + marginTop + extraMargin;
|
|
108
|
-
|
|
109
95
|
if (bottomOffset < 0) {
|
|
110
96
|
bottomOffset = 0;
|
|
111
97
|
}
|
|
112
|
-
|
|
113
98
|
break;
|
|
114
99
|
}
|
|
115
100
|
}
|
|
116
101
|
}
|
|
117
|
-
|
|
118
102
|
element.style.height = `calc(100% - ${parseInt(element.style.marginTop, 10) + bottomOffset}px)`;
|
|
119
103
|
}
|
|
120
104
|
}
|
|
121
|
-
|
|
122
105
|
function removeScrollListeners() {
|
|
123
106
|
removeScrollListener.map(cb => cb());
|
|
124
107
|
removeScrollListener = [];
|
|
125
108
|
}
|
|
126
|
-
|
|
127
109
|
function syncPositionWith(syncElement) {
|
|
128
110
|
removeScrollListeners();
|
|
129
111
|
const afterScrollFinishRecheck = debounce(() => this.onScroll(syncElement), AFTER_SCROLL_RECHECK_INTERVAL);
|
|
@@ -142,7 +124,6 @@ angularModule.factory('rgPlaceUnderHelper', ["$window", $window => {
|
|
|
142
124
|
resizeDetector.listenTo(elementToHeightListening, sidebarScrollListener);
|
|
143
125
|
removeScrollListener.push(() => resizeDetector.removeAllListeners(elementToHeightListening));
|
|
144
126
|
}
|
|
145
|
-
|
|
146
127
|
scope.$on('$destroy', removeScrollListeners);
|
|
147
128
|
return {
|
|
148
129
|
waitForNonZeroHeight,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var Directions;
|
|
2
|
-
|
|
3
2
|
(function (Directions) {
|
|
4
3
|
Directions["BOTTOM_RIGHT"] = "BOTTOM_RIGHT";
|
|
5
4
|
Directions["BOTTOM_LEFT"] = "BOTTOM_LEFT";
|
|
@@ -18,34 +17,24 @@ var Directions;
|
|
|
18
17
|
* When positioning a popup, directions will be tried in the listed order.
|
|
19
18
|
* @type {Array.<string>}
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
20
|
const DEFAULT_DIRECTIONS = [Directions.BOTTOM_RIGHT, Directions.BOTTOM_LEFT, Directions.TOP_LEFT, Directions.TOP_RIGHT, Directions.RIGHT_TOP, Directions.RIGHT_BOTTOM, Directions.LEFT_TOP, Directions.LEFT_BOTTOM];
|
|
24
21
|
/**
|
|
25
22
|
* @enum {number}
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
24
|
var Dimension;
|
|
29
|
-
|
|
30
25
|
(function (Dimension) {
|
|
31
26
|
Dimension[Dimension["MARGIN"] = 16] = "MARGIN";
|
|
32
27
|
Dimension[Dimension["BORDER_WIDTH"] = 1] = "BORDER_WIDTH";
|
|
33
28
|
})(Dimension || (Dimension = {}));
|
|
34
|
-
|
|
35
29
|
var MinWidth;
|
|
36
|
-
|
|
37
30
|
(function (MinWidth) {
|
|
38
31
|
MinWidth[MinWidth["TARGET"] = -1] = "TARGET";
|
|
39
32
|
})(MinWidth || (MinWidth = {}));
|
|
40
|
-
|
|
41
33
|
var MaxHeight;
|
|
42
|
-
|
|
43
34
|
(function (MaxHeight) {
|
|
44
35
|
MaxHeight[MaxHeight["SCREEN"] = -1] = "SCREEN";
|
|
45
36
|
})(MaxHeight || (MaxHeight = {}));
|
|
46
|
-
|
|
47
37
|
var Display;
|
|
48
|
-
|
|
49
38
|
(function (Display) {
|
|
50
39
|
Display[Display["HIDDEN"] = 0] = "HIDDEN";
|
|
51
40
|
Display[Display["SHOWING"] = 1] = "SHOWING";
|