Skip to content

Commit b2e5d8b

Browse files
musalegavinbarron
andauthored
feature: Update teams-channel-picker to fluent UI designs (#1805)
* update: Set rtl and images for fluent UI look * update: Make card height wrap around the content * update: Make searched channels expand in dropdown * refactor: Remove deprecated even.keyCode for event.code * fix: Apply auto card height on the fluent-card * fix: Set render direction to ltr by default and auto height card * update: set the dir attribute at the top most part of the element This together with setting the dir attribute on the fluent-tree-view enables the fluentui components to set the dir on their own. Multiple dir attributes are unnecessary and cause the fluentui components to exhibit unexpected behaviour. * update: Change the usage of fluentui components * update: Set card width * update: Set the width to 368px * update: Handle enter keypress on channel * fix: use min-width to allow growth of element when txt is long * fix: flexible width for the dropdown and selected values * fix: hide the dropdown on losing component focus * fix: change the loading component props to align with main component * refactor: remove unused code * fix: format fixes and new lock file * fix: disable input on selecting a channel * fix: toggle the chevrons and close btn correctly * fix: set a fixed width and resize selected channel img * fix: truncate selected team or channel to fit the width * fix: test the fluent component in spinner * fix: custom event detail should be an obj in an array * fix: mark a channel selected by ID as highlighted in the DOM * fix: remove the click event on the team tree-item * fix: remove highlight on clicking a team name - make clicking the team only expand/collapse channel list * fix: stop showing the previously selected channel * remove the DOM properties that show it selected manually to avoid reloading the state of the component * fix: selectionChanged evt to emit correct type * fix: update the layout of selected pills * fix: remove end slot on selected team Render the team parent name with the default slot --------- Co-authored-by: Gavin Barron <[email protected]>
1 parent 66c2e6c commit b2e5d8b

File tree

10 files changed

+473
-607
lines changed

10 files changed

+473
-607
lines changed

packages/mgt-components/src/components/mgt-teams-channel-picker/mgt-teams-channel-picker.graph.ts

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
import { IGraph, prepScopes } from '@microsoft/mgt-element';
8+
import { IGraph, BetaGraph, CacheItem, CacheService, CacheStore } from '@microsoft/mgt-element';
99
import { Team } from '@microsoft/microsoft-graph-types';
10+
import {
11+
getPhotoForResource,
12+
CachePhoto,
13+
getPhotoInvalidationTime,
14+
getIsPhotosCacheEnabled
15+
} from '../../graph/graph.photos';
16+
import { schemas } from '../../graph/cacheStores';
1017

1118
/**
1219
* async promise, returns all Teams associated with the user logged in
@@ -15,11 +22,46 @@ import { Team } from '@microsoft/microsoft-graph-types';
1522
* @memberof Graph
1623
*/
1724
export async function getAllMyTeams(graph: IGraph): Promise<Team[]> {
18-
const scopes = 'team.readbasic.all';
19-
const teams = await graph
20-
.api('/me/joinedTeams')
21-
.select(['displayName', 'id', 'isArchived'])
22-
.middlewareOptions(prepScopes(scopes))
23-
.get();
25+
const teams = await graph.api('/me/joinedTeams').select(['displayName', 'id', 'isArchived']).get();
2426
return teams ? teams.value : null;
2527
}
28+
29+
/** An object collection of cached photos. */
30+
type CachePhotos = {
31+
[key: string]: CachePhoto;
32+
};
33+
34+
export async function getTeamsPhotosforPhotoIds(graph: BetaGraph, teamIds: string[]): Promise<CachePhotos> {
35+
let cache: CacheStore<CachePhoto>;
36+
let photos: CachePhotos = {};
37+
38+
if (getIsPhotosCacheEnabled()) {
39+
cache = CacheService.getCache<CachePhoto>(schemas.photos, schemas.photos.stores.teams);
40+
for (const id of teamIds) {
41+
try {
42+
const photoDetail = await cache.getValue(id);
43+
if (photoDetail && getPhotoInvalidationTime() > Date.now() - photoDetail.timeCached) {
44+
photos[id] = photoDetail;
45+
}
46+
} catch (_) {}
47+
}
48+
if (Object.keys(photos).length) {
49+
return photos;
50+
}
51+
}
52+
53+
let scopes = ['team.readbasic.all'];
54+
photos = {};
55+
56+
for (const id of teamIds) {
57+
try {
58+
const photoDetail = await getPhotoForResource(graph, `/teams/${id}`, scopes);
59+
if (getIsPhotosCacheEnabled() && photoDetail) {
60+
cache.putValue(id, photoDetail);
61+
}
62+
photos[id] = photoDetail;
63+
} catch (_) {}
64+
}
65+
66+
return photos;
67+
}

0 commit comments

Comments
 (0)