@ichicraft/widgets-widget-base 1.7.4 → 1.7.8
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/README.md +15 -0
- package/lib/types/index.d.ts +31 -1
- package/lib/utils/UserHelper.d.ts +1 -0
- package/lib/utils/UserHelper.js +20 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -8,6 +8,21 @@ All notable changes to this project will be documented here.
|
|
|
8
8
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
9
9
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
10
10
|
|
|
11
|
+
## 1.7.8 - 2022-01-18
|
|
12
|
+
### Changed
|
|
13
|
+
* Added `initiateWidgetDeletion()` function to the `WidgetContext` interface.
|
|
14
|
+
|
|
15
|
+
## 1.7.7 - 2022-01-14
|
|
16
|
+
### Changed
|
|
17
|
+
* Added `tenantId` property to the `WidgetContext` interface.
|
|
18
|
+
|
|
19
|
+
## 1.7.6 - 2021-11-04
|
|
20
|
+
### Changed
|
|
21
|
+
* Added `theme` property to the `WidgetContext` interface to give access to currently applied theme.
|
|
22
|
+
|
|
23
|
+
## 1.7.5 - 2021-10-26
|
|
24
|
+
### Changed
|
|
25
|
+
* Added `userSecurityGroups` and `userSharePointGroups` properties to the `WidgetContext` interface to inform widgets of SharePoint and security group memberships of the current user.
|
|
11
26
|
|
|
12
27
|
## 1.7.4 - 2021-10-20
|
|
13
28
|
### Changed
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MSGraphClientFactory, AadTokenProviderFactory, AadHttpClientFactory } from '@microsoft/sp-http';
|
|
2
|
+
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
|
2
3
|
import * as microsoftTeams from '@microsoft/teams-js';
|
|
3
4
|
/**
|
|
4
5
|
* Widget context providing widget metadata and functionality offered by the widget board
|
|
@@ -31,6 +32,11 @@ export interface WidgetContext {
|
|
|
31
32
|
* menu of the widget.
|
|
32
33
|
*/
|
|
33
34
|
openConfiguration?: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Call this function to open the widget delete confirmation dialog for a user. This offers widget developers
|
|
37
|
+
* the ability to trigger the "widget deletion process". This allows different methods to delete the widget.
|
|
38
|
+
*/
|
|
39
|
+
initiateWidgetDeletion?: () => void;
|
|
34
40
|
/**
|
|
35
41
|
* Functionality offered by the widget board to open a url in an iframe dialog.
|
|
36
42
|
*/
|
|
@@ -116,6 +122,10 @@ export interface WidgetContext {
|
|
|
116
122
|
* Tells whether the widget board is running in a mobile webview context
|
|
117
123
|
*/
|
|
118
124
|
isMobileWebView: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Tenant ID of current SharePoint tenant
|
|
127
|
+
*/
|
|
128
|
+
tenantId: string;
|
|
119
129
|
/**
|
|
120
130
|
* Site url of the site where the widget board is running
|
|
121
131
|
*/
|
|
@@ -131,10 +141,22 @@ export interface WidgetContext {
|
|
|
131
141
|
* Example: `"example@contoso.com"`
|
|
132
142
|
*/
|
|
133
143
|
userEmail: string;
|
|
144
|
+
/**
|
|
145
|
+
* SharePoint ID of the user in the current site
|
|
146
|
+
*/
|
|
147
|
+
spUserId: number;
|
|
134
148
|
/**
|
|
135
149
|
* Login name of current user in claim style: i:0#.f|myprovider|myuser
|
|
136
150
|
*/
|
|
137
151
|
claimBasedLoginName: string;
|
|
152
|
+
/**
|
|
153
|
+
* Azure AD Security groups that user is member of
|
|
154
|
+
*/
|
|
155
|
+
userSecurityGroups: string[];
|
|
156
|
+
/**
|
|
157
|
+
* SharePoint groups in this site collection that user is member of
|
|
158
|
+
*/
|
|
159
|
+
userSharePointGroups: number[];
|
|
138
160
|
/**
|
|
139
161
|
* Language code of currently used UI rendering language in SharePoint
|
|
140
162
|
*/
|
|
@@ -162,9 +184,13 @@ export interface WidgetContext {
|
|
|
162
184
|
*/
|
|
163
185
|
friendlyName: string;
|
|
164
186
|
/**
|
|
165
|
-
* Whether this is the default
|
|
187
|
+
* Whether this is the default UI language of the Widget Board
|
|
166
188
|
*/
|
|
167
189
|
isDefault?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Whether this is the current UI language of the Widget Board
|
|
192
|
+
*/
|
|
193
|
+
isCurrent?: boolean;
|
|
168
194
|
}[];
|
|
169
195
|
/**
|
|
170
196
|
* MS Graph Client Factory class as provided by the WebPartContext object.
|
|
@@ -178,6 +204,10 @@ export interface WidgetContext {
|
|
|
178
204
|
* AAD Token Provider Factory class as provided by the WebPartContext object.
|
|
179
205
|
*/
|
|
180
206
|
aadTokenProviderFactory: AadTokenProviderFactory;
|
|
207
|
+
/**
|
|
208
|
+
* Currently in use theme (by SharePoint/Teams)
|
|
209
|
+
*/
|
|
210
|
+
theme: IReadonlyTheme;
|
|
181
211
|
/**
|
|
182
212
|
* Returns whether or not the currently signed in user is part of an AAD security group.
|
|
183
213
|
* Provide the guid of the group.
|
|
@@ -5,4 +5,5 @@ import { ICPersona, WidgetContext } from '../types';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class UserHelper {
|
|
7
7
|
static isCurrentUserInScope(personas: ICPersona[], context: WidgetContext): Promise<boolean>;
|
|
8
|
+
static gatherAllNormalizedUserPersonaIds(userName: string, claimBasedLoginName: string, spGroups: number[], secGroups: string[]): string[];
|
|
8
9
|
}
|
package/lib/utils/UserHelper.js
CHANGED
|
@@ -120,6 +120,26 @@ var UserHelper = /** @class */ (function () {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
|
+
UserHelper.gatherAllNormalizedUserPersonaIds = function (userName, claimBasedLoginName, spGroups, secGroups) {
|
|
124
|
+
var personas = [];
|
|
125
|
+
// 1. The user name in two known shapes
|
|
126
|
+
personas.push("USER|" + userName.toLowerCase());
|
|
127
|
+
personas.push("USER|" + claimBasedLoginName.toLowerCase());
|
|
128
|
+
// 2. The SP Groups, just as they are: numeric strings
|
|
129
|
+
spGroups.forEach(function (spg) {
|
|
130
|
+
personas.push("SPGROUP|" + spg);
|
|
131
|
+
});
|
|
132
|
+
// 3. The Security Groups, as Guids
|
|
133
|
+
secGroups.forEach(function (secg) {
|
|
134
|
+
personas.push("ADGROUP|" + secg.toLowerCase());
|
|
135
|
+
});
|
|
136
|
+
// 4. Optionally the all users except external users group:
|
|
137
|
+
if (claimBasedLoginName.indexOf('#ext#') === -1) {
|
|
138
|
+
// This is an internal user
|
|
139
|
+
personas.push('ADGROUP|spo-grid-all-users');
|
|
140
|
+
}
|
|
141
|
+
return personas;
|
|
142
|
+
};
|
|
123
143
|
return UserHelper;
|
|
124
144
|
}());
|
|
125
145
|
exports.UserHelper = UserHelper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichicraft/widgets-widget-base",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"description": "Part of the Widget Development Kit for building widgets for Ichicraft Boards",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"lib/**/*"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@microsoft/sp-
|
|
23
|
-
"@microsoft/
|
|
22
|
+
"@microsoft/sp-component-base": "^1.11.0",
|
|
23
|
+
"@microsoft/sp-http": "1.11.0",
|
|
24
|
+
"@microsoft/teams-js": "1.9.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"typescript": "^3.6.4"
|