jitz-sharepoint-utilities 1.11.3 → 2.0.1

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.
Files changed (94) hide show
  1. package/@types/allTypes.d.ts +1 -0
  2. package/controls/JitzGrid.tsx +639 -0
  3. package/controls/JitzImage.tsx +38 -0
  4. package/controls/JitzPeoplePicker.tsx +419 -0
  5. package/controls/JitzPersonInfo.tsx +114 -0
  6. package/controls/JitzPersona.tsx +53 -0
  7. package/data/context/CommonRepository.ts +287 -0
  8. package/data/context/JitzContext.ts +33 -0
  9. package/data/context/JitzSPContext.ts +16 -0
  10. package/data/context/JitzSPHttpClient.ts +133 -0
  11. package/data/context/List.ts +429 -0
  12. package/data/context/Repository.ts +395 -0
  13. package/data/interfaces/ICommonRepository.ts +7 -0
  14. package/data/interfaces/IJitzContext.ts +11 -0
  15. package/data/interfaces/IJitzSPContext.ts +7 -0
  16. package/data/interfaces/IJitzSPHttpClient.ts +6 -0
  17. package/data/interfaces/IList.ts +41 -0
  18. package/data/interfaces/IModels.ts +33 -0
  19. package/data/interfaces/IRepository.ts +31 -0
  20. package/lib/common/IModels.d.ts +9 -1
  21. package/lib/common/IObjects.d.ts +72 -0
  22. package/lib/common/IObjects.js +30 -0
  23. package/lib/controls/JitzGrid.d.ts +75 -0
  24. package/lib/controls/JitzGrid.js +606 -0
  25. package/lib/controls/JitzImage.d.ts +14 -0
  26. package/lib/controls/JitzImage.js +37 -0
  27. package/lib/controls/JitzPeoplePicker.d.ts +49 -0
  28. package/lib/controls/JitzPeoplePicker.js +311 -0
  29. package/lib/controls/JitzPersonInfo.d.ts +32 -0
  30. package/lib/controls/JitzPersonInfo.js +98 -0
  31. package/lib/controls/JitzPersona.d.ts +23 -0
  32. package/lib/controls/JitzPersona.js +48 -0
  33. package/lib/data/Activities.d.ts +6 -0
  34. package/lib/data/Activities.js +36 -0
  35. package/lib/data/Attachments.d.ts +6 -0
  36. package/lib/data/Attachments.js +30 -0
  37. package/lib/data/Configurations.d.ts +6 -0
  38. package/lib/data/Configurations.js +30 -0
  39. package/lib/data/CustomStylesheet.d.ts +6 -0
  40. package/lib/data/CustomStylesheet.js +30 -0
  41. package/lib/data/EmailTemplates.d.ts +6 -0
  42. package/lib/data/EmailTemplates.js +31 -0
  43. package/lib/data/FAQs.d.ts +6 -0
  44. package/lib/data/FAQs.js +30 -0
  45. package/lib/data/HomePageTexts.d.ts +6 -0
  46. package/lib/data/HomePageTexts.js +30 -0
  47. package/lib/data/TicketCategories.d.ts +6 -0
  48. package/lib/data/TicketCategories.js +26 -0
  49. package/lib/data/TicketComments.d.ts +6 -0
  50. package/lib/data/TicketComments.js +32 -0
  51. package/lib/data/TicketPriorities.d.ts +6 -0
  52. package/lib/data/TicketPriorities.js +31 -0
  53. package/lib/data/TicketStatuses.d.ts +6 -0
  54. package/lib/data/TicketStatuses.js +31 -0
  55. package/lib/data/TicketSubcategories.d.ts +6 -0
  56. package/lib/data/TicketSubcategories.js +26 -0
  57. package/lib/data/Tickets.d.ts +6 -0
  58. package/lib/data/Tickets.js +45 -0
  59. package/lib/data/context/CommonRepository.d.ts +17 -0
  60. package/lib/data/context/CommonRepository.js +288 -0
  61. package/lib/data/context/JitzContext.d.ts +13 -0
  62. package/lib/data/context/JitzContext.js +80 -0
  63. package/lib/data/context/JitzSPContext.d.ts +8 -0
  64. package/lib/data/context/JitzSPContext.js +58 -0
  65. package/lib/data/context/JitzSPHttpClient.d.ts +14 -0
  66. package/lib/data/context/JitzSPHttpClient.js +173 -0
  67. package/lib/data/context/List.d.ts +36 -0
  68. package/lib/data/context/List.js +450 -0
  69. package/lib/data/context/Repository.d.ts +19 -0
  70. package/lib/data/context/Repository.js +421 -0
  71. package/lib/data/interfaces/ICommonRepository.d.ts +6 -0
  72. package/lib/data/interfaces/ICommonRepository.js +2 -0
  73. package/lib/data/interfaces/IJitzContext.d.ts +10 -0
  74. package/lib/data/interfaces/IJitzContext.js +2 -0
  75. package/lib/data/interfaces/IJitzSPContext.d.ts +6 -0
  76. package/lib/data/interfaces/IJitzSPContext.js +2 -0
  77. package/lib/data/interfaces/IJitzSPHttpClient.d.ts +6 -0
  78. package/lib/data/interfaces/IJitzSPHttpClient.js +2 -0
  79. package/lib/data/interfaces/IList.d.ts +25 -0
  80. package/lib/data/interfaces/IList.js +2 -0
  81. package/lib/data/interfaces/IModels.d.ts +32 -0
  82. package/lib/data/interfaces/IModels.js +2 -0
  83. package/lib/data/interfaces/IRepository.d.ts +14 -0
  84. package/lib/data/interfaces/IRepository.js +2 -0
  85. package/lib/jitzSPHttpClient.js +5 -3
  86. package/lib/repositories/CommonRepository.js +17 -16
  87. package/lib/repositories/Repository.js +22 -21
  88. package/lib/services/GraphService.d.ts +10 -0
  89. package/lib/services/GraphService.js +105 -0
  90. package/lib/services/UserService.d.ts +1 -1
  91. package/lib/services/UserService.js +9 -9
  92. package/lib/services/UtilityService.d.ts +18 -12
  93. package/lib/services/UtilityService.js +157 -58
  94. package/package.json +7 -5
@@ -0,0 +1,419 @@
1
+ import * as React from "react";
2
+ import * as lodash from "lodash";
3
+ import IJitzSPContext from "../data/interfaces/IJitzSPContext";
4
+ import UtilityService from "../services/UtilityService";
5
+ import {
6
+ CompactPeoplePicker,
7
+ IBasePickerSuggestionsProps,
8
+ IContextualMenuItem,
9
+ IPersonaProps,
10
+ NormalPeoplePicker,
11
+ } from "@fluentui/react";
12
+ import {
13
+ IClientPeoplePickerSearchUser,
14
+ IEnsurableSharePointUser,
15
+ IEnsureUser,
16
+ IJitzPeoplePickerState,
17
+ SharePointUserPersona,
18
+ } from "../common/IObjects";
19
+
20
+ const suggestionProps: IBasePickerSuggestionsProps = {
21
+ suggestionsHeaderText: "Suggested People",
22
+ noResultsFoundText: "No results found",
23
+ loadingText: "Loading",
24
+ };
25
+
26
+ export interface IJitzPeoplePickerProps {
27
+ description: string;
28
+ context: IJitzSPContext;
29
+ hostSiteUrl?: string;
30
+ typePicker: string;
31
+ disabled: boolean;
32
+ principalTypeUser: boolean;
33
+ principalTypeSharePointGroup: boolean;
34
+ principalTypeSecurityGroup: boolean;
35
+ principalTypeDistributionList: boolean;
36
+ numberOfItems: number;
37
+ onChange?: (items: SharePointUserPersona[]) => void;
38
+ prePopulatedItems: string[];
39
+ errorMessage?: string;
40
+ errorCss?: string;
41
+ multiSelect: boolean;
42
+ }
43
+
44
+ export class JitzPeoplePicker extends React.Component<
45
+ IJitzPeoplePickerProps,
46
+ IJitzPeoplePickerState
47
+ > {
48
+ private _peopleList: any;
49
+ private contextualMenuItems: IContextualMenuItem[] = [
50
+ {
51
+ key: "newItem",
52
+ icon: "circlePlus",
53
+ name: "New",
54
+ },
55
+ {
56
+ key: "upload",
57
+ icon: "upload",
58
+ name: "Upload",
59
+ },
60
+ {
61
+ key: "divider_1",
62
+ name: "-",
63
+ },
64
+ {
65
+ key: "rename",
66
+ name: "Rename",
67
+ },
68
+ {
69
+ key: "properties",
70
+ name: "Properties",
71
+ },
72
+ {
73
+ key: "disabled",
74
+ name: "Disabled item",
75
+ disabled: true,
76
+ },
77
+ ];
78
+ constructor(props: IJitzPeoplePickerProps) {
79
+ super(props);
80
+ this._peopleList = [];
81
+
82
+ this.state = {
83
+ currentPicker: 1,
84
+ disabled: false,
85
+ delayResults: false,
86
+ selectedItems: [],
87
+ };
88
+ }
89
+
90
+ public getSelectedItems() {}
91
+
92
+ public componentDidMount(): void {
93
+ this.setState({ disabled: this.props.disabled });
94
+ this.prePopulate(this.props.prePopulatedItems);
95
+ }
96
+
97
+ public componentDidUpdate(
98
+ prevProps: IJitzPeoplePickerProps,
99
+ prevState: IJitzPeoplePickerState,
100
+ prevContext: any
101
+ ): void {
102
+ //this.prePopulate();
103
+ }
104
+
105
+ public componentWillReceiveProps(nextProps: IJitzPeoplePickerProps) {
106
+ this.setState({ disabled: nextProps.disabled });
107
+ this.prePopulate(nextProps.prePopulatedItems);
108
+ }
109
+
110
+ public render(): React.ReactElement<IJitzPeoplePickerProps> {
111
+ if (this.props.typePicker == "Normal") {
112
+ return (
113
+ <NormalPeoplePicker
114
+ onChange={this._onChange.bind(this)}
115
+ disabled={this.state.disabled}
116
+ onResolveSuggestions={this._onFilterChanged}
117
+ getTextFromItem={(persona: IPersonaProps) =>
118
+ persona.primaryText || ""
119
+ }
120
+ pickerSuggestionsProps={suggestionProps}
121
+ selectedItems={this.state.selectedItems}
122
+ className={
123
+ "ms-PeoplePicker " +
124
+ (this.props.errorMessage != null &&
125
+ this.props.errorMessage != undefined &&
126
+ this.props.errorMessage.length > 0
127
+ ? this.props.errorCss
128
+ : "")
129
+ }
130
+ key={"normal"}
131
+ />
132
+ );
133
+ } else {
134
+ return (
135
+ <CompactPeoplePicker
136
+ onChange={this._onChange.bind(this)}
137
+ onResolveSuggestions={this._onFilterChanged}
138
+ disabled={this.state.disabled}
139
+ getTextFromItem={(persona: IPersonaProps) =>
140
+ persona.primaryText || ""
141
+ }
142
+ pickerSuggestionsProps={suggestionProps}
143
+ selectedItems={this.state.selectedItems}
144
+ className={
145
+ "ms-PeoplePicker" +
146
+ (this.props.errorMessage != null &&
147
+ this.props.errorMessage != undefined &&
148
+ this.props.errorMessage.length > 0
149
+ ? this.props.errorCss
150
+ : "")
151
+ }
152
+ key={"normal"}
153
+ />
154
+ );
155
+ }
156
+ }
157
+
158
+ private _onChange(items?: any[]) {
159
+ this.setState({
160
+ selectedItems:
161
+ (this.props.multiSelect
162
+ ? items
163
+ : items != undefined
164
+ ? items.length > 0
165
+ ? [items[0]]
166
+ : items
167
+ : []) || [],
168
+ });
169
+
170
+ if (items != undefined) {
171
+ items.map((p, v) => {
172
+ // console.log(p);
173
+ const ensureUserUrl = `${this.props.context.siteUrl}/_api/web/ensureUser`;
174
+
175
+ this.props.context.client
176
+ .post(ensureUserUrl, { logonName: p.User.Key })
177
+ .then((response: any) => {
178
+ var res = response.data.d;
179
+ return res;
180
+ })
181
+ .then((res: any) => {});
182
+ });
183
+ }
184
+
185
+ if (this.props.onChange) {
186
+ this.props.onChange(items || []);
187
+ }
188
+ }
189
+
190
+ private prePopulate = (nextPrePopulatedItems: string[]) => {
191
+ const ensureUserUrl = `${this.props.context.siteUrl}/_api/web/ensureUser`;
192
+ if (
193
+ nextPrePopulatedItems != undefined &&
194
+ nextPrePopulatedItems != null &&
195
+ nextPrePopulatedItems[0] != null
196
+ ) {
197
+ nextPrePopulatedItems.map((item) => {
198
+ // console.log(item);
199
+ this.props.context.client
200
+ .post(ensureUserUrl, { logonName: item })
201
+ .then((response: any) => {
202
+ var res = response.data.d;
203
+ return res;
204
+ })
205
+ .then((res: any) => {
206
+ var pers = new SharePointUserPersona(
207
+ res as IEnsurableSharePointUser
208
+ );
209
+ pers.imageUrl = UtilityService.getProfilePictureUrl(
210
+ this.props.hostSiteUrl || this.props.context.siteUrl,
211
+ pers.User.Email || ""
212
+ );
213
+ // (this.props.hostSiteUrl || this.props.context.siteUrl) +
214
+ // `/_layouts/15/userphoto.aspx?size=S&accountname=${pers.User.Email}`;
215
+ var prepopulatedItems = this.state.selectedItems;
216
+ if (
217
+ prepopulatedItems.filter(
218
+ (x: any) => x.User.LoginName == pers.User.LoginName
219
+ ).length == 0
220
+ ) {
221
+ prepopulatedItems.push(pers);
222
+ this.setState({
223
+ selectedItems: this.props.multiSelect
224
+ ? prepopulatedItems
225
+ : prepopulatedItems.length > 0
226
+ ? [prepopulatedItems[0]]
227
+ : prepopulatedItems,
228
+ });
229
+ }
230
+ if (this.props.onChange) {
231
+ this.props.onChange(prepopulatedItems);
232
+ }
233
+ });
234
+ });
235
+ }
236
+ };
237
+
238
+ private _onFilterChanged = (
239
+ filterText: string,
240
+ currentPersonas?: IPersonaProps[]
241
+ ): any => {
242
+ if (filterText) {
243
+ if (filterText.length > 2) {
244
+ return this._searchPeople(filterText, this._peopleList);
245
+ }
246
+ } else {
247
+ return [];
248
+ }
249
+ };
250
+
251
+ /**
252
+ * @function
253
+ * Returns fake people results for the Mock mode
254
+ */
255
+ private searchPeopleFromMock(): IPersonaProps[] {
256
+ return (this._peopleList = []);
257
+ }
258
+
259
+ /**
260
+ * @function
261
+ * Returns people results after a REST API call
262
+ */
263
+ private _searchPeople(
264
+ terms: string,
265
+ results: IPersonaProps[]
266
+ ): IPersonaProps[] | Promise<IPersonaProps[]> {
267
+ const userRequestUrl: string = `${this.props.context.siteUrl}/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser`;
268
+ let principalType: number = 0;
269
+ if (this.props.principalTypeUser === true) {
270
+ principalType += 1;
271
+ }
272
+ if (this.props.principalTypeSharePointGroup === true) {
273
+ principalType += 8;
274
+ }
275
+ if (this.props.principalTypeSecurityGroup === true) {
276
+ principalType += 4;
277
+ }
278
+ if (this.props.principalTypeDistributionList === true) {
279
+ principalType += 2;
280
+ }
281
+ const userQueryParams = {
282
+ queryParams: {
283
+ AllowEmailAddresses: true,
284
+ AllowMultipleEntities: false,
285
+ AllUrlZones: false,
286
+ MaximumEntitySuggestions: this.props.numberOfItems,
287
+ PrincipalSource: 15,
288
+ // PrincipalType controls the type of entities that are returned in the results.
289
+ // Choices are All - 15, Distribution List - 2 , Security Groups - 4, SharePoint Groups - 8, User - 1.
290
+ // These values can be combined (example: 13 is security + SP groups + users)
291
+ PrincipalType: principalType,
292
+ QueryString: terms,
293
+ },
294
+ };
295
+
296
+ return new Promise<SharePointUserPersona[]>((resolve: any, reject: any) =>
297
+ this.props.context.client
298
+ .post(userRequestUrl, userQueryParams)
299
+ .then((response: any) => {
300
+ return response.data.d;
301
+ })
302
+ .then((response: { ClientPeoplePickerSearchUser: string }) => {
303
+ let userQueryResults: IClientPeoplePickerSearchUser[] = JSON.parse(
304
+ response.ClientPeoplePickerSearchUser
305
+ );
306
+ let persons = userQueryResults.map(
307
+ (p) => new SharePointUserPersona(p as IEnsurableSharePointUser)
308
+ );
309
+ persons.map((p, index) => {
310
+ persons[index].imageUrl = UtilityService.getProfilePictureUrl(
311
+ this.props.hostSiteUrl || this.props.context.siteUrl,
312
+ persons[index].User.Email ||
313
+ persons[index].User.Key.substr(
314
+ persons[index].User.Key.lastIndexOf("|") + 1
315
+ )
316
+ );
317
+ // (this.props.hostSiteUrl || this.props.context.siteUrl) +
318
+ // `/_layouts/15/userphoto.aspx?size=S&accountname=${
319
+ // persons[index].User.Email ||
320
+ // persons[index].User.Key.substr(
321
+ // persons[index].User.Key.lastIndexOf("|") + 1
322
+ // )
323
+ // }`;
324
+ });
325
+ return persons;
326
+ })
327
+ .then(
328
+ (persons: any) => {
329
+ //const batch = this.props.spHttpClient.beginBatch();
330
+ const ensureUserUrl = `${this.props.context.siteUrl}/_api/web/ensureUser`;
331
+ const batchPromises: Promise<IEnsureUser>[] = persons.map(
332
+ (p: SharePointUserPersona) => {
333
+ p.primaryText = p.User.DisplayText;
334
+ p.secondaryText = p.User.EntityData.Title;
335
+ var userQuery = { logonName: p.User.Key };
336
+ return (
337
+ this.props.context.client
338
+ .post(ensureUserUrl, userQuery)
339
+ // return this.props.spHttpClient.post(ensureUserUrl,
340
+ // SPHttpClient.configurations.v1,
341
+ // {body:JSON.stringify({logonName: p.User.Key})})
342
+ .then((response: any) => {
343
+ return response.data.d;
344
+ })
345
+ .then((json: IEnsureUser) => json)
346
+ );
347
+ }
348
+ );
349
+
350
+ // var users = this.props.spHttpClient.execute().then(() => );
351
+ var users = Promise.all(batchPromises).then((values: any) => {
352
+ values.forEach((v: any) => {
353
+ let userPersona = lodash.find(
354
+ persons,
355
+ (o: any) => o.User.Key == v.LoginName
356
+ );
357
+ if (userPersona && userPersona.User) {
358
+ let user = userPersona.User;
359
+ lodash.assign(user, v);
360
+ userPersona.User = user;
361
+ }
362
+ });
363
+
364
+ resolve(persons);
365
+ });
366
+ },
367
+ (error: any): void => {
368
+ reject((this._peopleList = []));
369
+ }
370
+ )
371
+ );
372
+ }
373
+
374
+ private _filterPersonasByText(filterText: string): IPersonaProps[] {
375
+ return this._peopleList.filter((item: any) =>
376
+ this._doesTextStartWith(item.primaryText, filterText)
377
+ );
378
+ }
379
+
380
+ private _removeDuplicates(
381
+ personas: IPersonaProps[],
382
+ possibleDupes: IPersonaProps[]
383
+ ) {
384
+ return personas.filter(
385
+ (persona) => !this._listContainsPersona(persona, possibleDupes)
386
+ );
387
+ }
388
+ private _listContainsPersona(
389
+ persona: IPersonaProps,
390
+ personas: IPersonaProps[]
391
+ ) {
392
+ if (!personas || !personas.length || personas.length === 0) {
393
+ return false;
394
+ }
395
+ return (
396
+ personas.filter((item) => item.primaryText === persona.primaryText)
397
+ .length > 0
398
+ );
399
+ }
400
+ private _filterPromise(
401
+ personasToReturn: IPersonaProps[]
402
+ ): IPersonaProps[] | Promise<IPersonaProps[]> {
403
+ if (this.state.delayResults) {
404
+ return this._convertResultsToPromise(personasToReturn);
405
+ } else {
406
+ return personasToReturn;
407
+ }
408
+ }
409
+ private _convertResultsToPromise(
410
+ results: IPersonaProps[]
411
+ ): Promise<IPersonaProps[]> {
412
+ return new Promise<IPersonaProps[]>((resolve: any, reject: any) =>
413
+ setTimeout(() => resolve(results), 2000)
414
+ );
415
+ }
416
+ private _doesTextStartWith(text: string, filterText: string): boolean {
417
+ return text.toLowerCase().indexOf(filterText.toLowerCase()) === 0;
418
+ }
419
+ }
@@ -0,0 +1,114 @@
1
+ import * as React from "react";
2
+ import IJitzSPContext from "../data/interfaces/IJitzSPContext";
3
+ import { Persona, PersonaPresence, PersonaSize } from "@fluentui/react";
4
+ import UserInfo from "../services/UserService";
5
+ import { IPersonOrGroup } from "../common/IModels";
6
+ import UtilityService from "../services/UtilityService";
7
+
8
+ export interface IPersonInfoProps {
9
+ userId: number;
10
+ email?: string;
11
+ title?: string;
12
+ department?: string;
13
+ location?: string;
14
+ context?: IJitzSPContext;
15
+ siteUrl?: string;
16
+ imageUrl?: string;
17
+ size?: PersonaSize;
18
+ className?: string;
19
+ hidePersonaDetails?: boolean;
20
+ }
21
+
22
+ export interface IPersonInfoState {
23
+ user: {
24
+ email?: string;
25
+ title?: string;
26
+ department?: string;
27
+ location?: string;
28
+ };
29
+ }
30
+
31
+ export class JitzPersonInfo extends React.Component<
32
+ IPersonInfoProps,
33
+ IPersonInfoState
34
+ > {
35
+ private _userInfo!: UserInfo;
36
+
37
+ constructor(props: IPersonInfoProps, state: IPersonInfoState) {
38
+ super(props);
39
+ this.state = {
40
+ user: {},
41
+ };
42
+ }
43
+
44
+ public componentDidMount() {
45
+ if (
46
+ this.props.userId > 0 &&
47
+ this.props.email == undefined &&
48
+ this.props.title == undefined
49
+ ) {
50
+ this.loadUser(this.props.userId);
51
+ }
52
+ }
53
+
54
+ public componentWillReceiveProps(nextProps: IPersonInfoProps) {
55
+ if (
56
+ nextProps.userId > 0 &&
57
+ nextProps.email == undefined &&
58
+ nextProps.title == undefined
59
+ ) {
60
+ this.loadUser(nextProps.userId);
61
+ }
62
+ }
63
+
64
+ private loadUser = (id: number) => {
65
+ if (this.props.context != undefined) {
66
+ this._userInfo = new UserInfo(this.props.context);
67
+ this._userInfo.getUserById(id).then((userInfo: IPersonOrGroup) => {
68
+ this.setState({
69
+ user: {
70
+ email: userInfo.Email,
71
+ title: userInfo.Title,
72
+ // department: userInfo.Department,
73
+ },
74
+ });
75
+ });
76
+ }
77
+ };
78
+
79
+ public render(): React.ReactElement<IPersonInfoProps> {
80
+ // const userDetails = this.state.user;
81
+ const userDetails = {
82
+ imageUrl: UtilityService.getProfilePictureUrl(
83
+ this.props.siteUrl || this.props.context!.siteUrl,
84
+ this.props.email || this.state.user.email || ""
85
+ ),
86
+ // this.props.imageUrl ||
87
+ // (this.props.siteUrl || this.props.context!.siteUrl) +
88
+ // `/_layouts/15/userphoto.aspx?size=${
89
+ // this.props.size == PersonaSize.size48 ||
90
+ // this.props.size == PersonaSize.size56 ||
91
+ // this.props.size == PersonaSize.size72 ||
92
+ // this.props.size == PersonaSize.size100 ||
93
+ // this.props.size == PersonaSize.size120
94
+ // ? "L"
95
+ // : "M"
96
+ // }&accountname=${this.props.email || this.state.user.email}`,
97
+ imageInitials: "",
98
+ primaryText: this.props.title || this.state.user.title,
99
+ secondaryText: this.props.department || this.state.user.department,
100
+ tertiaryText: "",
101
+ optionalText: "",
102
+ };
103
+ return (
104
+ <Persona
105
+ title={this.props.hidePersonaDetails ? userDetails.primaryText : ""}
106
+ {...userDetails}
107
+ className={this.props.className}
108
+ size={this.props.size || PersonaSize.size24}
109
+ // presence={PersonaPresence.online} //TODO: Actual presence
110
+ hidePersonaDetails={this.props.hidePersonaDetails || false}
111
+ />
112
+ );
113
+ }
114
+ }
@@ -0,0 +1,53 @@
1
+ import * as React from "react";
2
+ import IJitzSPContext from "../data/interfaces/IJitzSPContext";
3
+ import { Persona, PersonaPresence, PersonaSize } from "@fluentui/react";
4
+ import UserInfo from "../services/UserService";
5
+ import { IPersonOrGroup } from "../common/IModels";
6
+ import UtilityServiceLocal from "../services/UtilityService";
7
+
8
+ export interface IJitzPersonaProps {
9
+ className?: string;
10
+ imageUrl?: string;
11
+ personaSize?: PersonaSize;
12
+ presence?: PersonaPresence;
13
+ showPersonalDetails?: boolean;
14
+ imageInitials?: string;
15
+ text?: string;
16
+ secondaryText?: string;
17
+ tertiaryText?: string;
18
+ optionalText?: string;
19
+ }
20
+
21
+ export interface IJitzPersonaState {}
22
+
23
+ export class JitzPersona extends React.Component<
24
+ IJitzPersonaProps,
25
+ IJitzPersonaState
26
+ > {
27
+ private _userInfo!: UserInfo;
28
+
29
+ constructor(props: IJitzPersonaProps, state: IJitzPersonaState) {
30
+ super(props);
31
+ this.state = {
32
+ user: {},
33
+ };
34
+ }
35
+
36
+ public componentDidMount() {}
37
+
38
+ public componentWillReceiveProps(nextProps: IJitzPersonaProps) {}
39
+
40
+ public render(): React.ReactElement<IJitzPersonaProps> {
41
+ return (
42
+ <Persona
43
+ className={this.props.className || ""}
44
+ {...this.props}
45
+ text={this.props.text}
46
+ hidePersonaDetails={!this.props.showPersonalDetails}
47
+ size={this.props.personaSize || PersonaSize.size56}
48
+ presence={this.props.presence || PersonaPresence.none}
49
+ imageAlt={``}
50
+ />
51
+ );
52
+ }
53
+ }