Skip to content

Commit 3677936

Browse files
musaleMnickiigavinbarron
authored
feat: use fluent UI to theme the tasks component (#2150)
* feat: move styling from base and add fluentUI styling * feat: theme colors changed to fluentUI token colors * chore: refactor and re-organize element layout to remove unnecessary CSS * chore: add new strings * chore: set SVGs and add new ones * fix: return users when the content is from cache * chore: add person add svg * chore: refactor css classes * fix: add a task and display assign with icon * fix: layout of icons when adding a new task * chore: remove commented out code * fix: strike-through the task title when checked * fix: import required values for tasks stories * fix: upgrade arrow and dot options colors * chore: add assign string * chore: change the planner icon * fix: format and style the tasks scss * chore: remove margin on top of start icon for add button * refactor: change to class methods to avoid re-creation on renders * chore: fix DOM layout for Task Options * fix: update mgt-dot-options to fluent UI elements * chore: add padding for menu item * chore: use button for mgt-dot-option dots * chore: fix failing build * fix: add calendar and milestone icons * chore: change title color when you check a task * Add a css custom property file for tasks * Add tokens for the header, checkbox, titles, icons and new button * Add tokens for new btn,header,checkbox,icons and task * Add header text color, font size and weight * Add task gap,bg,border and border radius tokens * Fix types for various props * Add todo comments for tracking backlog * Set header default font-size to 16px * Fix mgt-flyout slot name * Fix the value for the row gap of tasks Signed-off-by: Musale Martin <[email protected]> * Add tokens for styling the tasks area Signed-off-by: Musale Martin <[email protected]> * Add dot options button tokens * Match dot options colors to the task background * Indicate an update is happening by momentarily freezing a task * Customize the text field inputs for a new task * Add tokens for the dropdown and its options * Add tokens for the assign icon and text * Remove duplicated variables * Add props for the add button * Style the add button props * Add story for styling the new task add button * Add props for cancelling adding a new task * Refactor and style the btn to cancel adding a new task * Add story with custom styling of the cancel btn * Add styling for skeleton shimmers * Add skeleton components for loading effect * Add space as a key event to add a task on click * Remove person-card interaction on people Signed-off-by: Martin Musale <[email protected]> * Remove focusing on people-picker when you click a person Signed-off-by: Martin Musale <[email protected]> * Show the assigned people in the anchor slot of flyout Signed-off-by: Martin Musale <[email protected]> * Use avatar skeleton shimmer on the loading task Signed-off-by: Martin Musale <[email protected]> * Move the colors into the theme file Signed-off-by: Martin Musale <[email protected]> * Refactor Task Source interface methods * Refactor Planner task source method calls * Update the graph functions signature to accomodate ne refactors * Fix linting errors * Fix todo methods apis in Task sources * Add skeleton shimmers for the heading * Add skeleton shimmers for the heading * Remove renderLoadingTasks tester * Remove promise wrapper on response Co-authored-by: Gavin Barron <[email protected]> * Remove debounce and unnecessary click event --------- Signed-off-by: Musale Martin <[email protected]> Signed-off-by: Martin Musale <[email protected]> Co-authored-by: Nickii Miaro <[email protected]> Co-authored-by: Gavin Barron <[email protected]>
1 parent 1c9face commit 3677936

File tree

13 files changed

+1260
-656
lines changed

13 files changed

+1260
-656
lines changed

packages/mgt-components/src/components/mgt-tasks/mgt-tasks.graph.planner.ts

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import { IGraph, prepScopes } from '@microsoft/mgt-element';
99
import { PlannerAssignments, PlannerBucket, PlannerPlan, PlannerTask } from '@microsoft/microsoft-graph-types';
1010
import { CollectionResponse } from '@microsoft/mgt-element';
11+
import { ITask } from './task-sources';
1112

1213
/**
1314
* async promise, allows developer to create new Planner task
1415
*
16+
* @param {IGraph} graph
1517
* @param {(PlannerTask)} newTask
1618
* @returns {Promise<any>}
1719
* @memberof Graph
@@ -27,110 +29,91 @@ export const addPlannerTask = async (graph: IGraph, newTask: PlannerTask): Promi
2729
/**
2830
* async promise, allows developer to assign people to task
2931
*
30-
* @param {string} taskId
31-
* @param {*} people
32-
* @param {string} eTag
32+
* @param {IGraph} graph
33+
* @param {ITask} task
34+
* @param {PlannerAssignments} people
3335
* @returns {Promise<any>}
3436
* @memberof Graph
3537
*/
3638
export const assignPeopleToPlannerTask = async (
3739
graph: IGraph,
38-
taskId: string,
39-
people: PlannerAssignments,
40-
eTag: string
40+
task: ITask,
41+
people: PlannerAssignments
4142
): Promise<void> => {
42-
await setPlannerTaskDetails(
43-
graph,
44-
taskId,
45-
{
46-
assignments: people
47-
},
48-
eTag
49-
);
43+
const details: PlannerTask = { assignments: people, appliedCategories: { category4: true } };
44+
await setPlannerTaskDetails(graph, task, details);
5045
};
5146

5247
/**
5348
* async promise, allows developer to remove Planner task associated with taskId
5449
*
55-
* @param {string} taskId
56-
* @param {string} eTag
50+
* @param {IGraph} graph
51+
* @param {ITask} task the task being removed.
5752
* @returns {Promise<any>}
5853
* @memberof Graph
5954
*/
60-
export const removePlannerTask = async (graph: IGraph, taskId: string, eTag: string): Promise<void> => {
55+
export const removePlannerTask = async (graph: IGraph, task: ITask): Promise<void> => {
6156
await graph
62-
.api(`/planner/tasks/${taskId}`)
57+
.api(`/planner/tasks/${task.id}`)
6358
.header('Cache-Control', 'no-store')
64-
.header('If-Match', eTag)
59+
.header('If-Match', task.eTag)
6560
.middlewareOptions(prepScopes('Group.ReadWrite.All'))
6661
.delete();
6762
};
6863

6964
/**
7065
* async promise, allows developer to set a task to complete, associated with taskId
7166
*
72-
* @param {string} taskId
73-
* @param {string} eTag
67+
* @param {IGraph} graph
68+
* @param {ITask} task
7469
* @returns {Promise<any>}
7570
* @memberof Graph
7671
*/
77-
export const setPlannerTaskComplete = async (graph: IGraph, taskId: string, eTag: string): Promise<void> => {
78-
await setPlannerTaskDetails(
79-
graph,
80-
taskId,
81-
{
82-
percentComplete: 100
83-
},
84-
eTag
85-
);
72+
export const setPlannerTaskComplete = async (graph: IGraph, task: ITask): Promise<void> => {
73+
await setPlannerTaskDetails(graph, task, { percentComplete: 100 });
8674
};
8775

8876
/**
8977
* async promise, allows developer to set a task to incomplete, associated with taskId
9078
*
91-
* @param {string} taskId
92-
* @param {string} eTag
79+
* @param {IGraph} graph
80+
* @param {ITask} task
9381
* @returns {Promise<any>}
9482
* @memberof Graph
9583
*/
96-
export const setPlannerTaskIncomplete = async (graph: IGraph, taskId: string, eTag: string): Promise<void> => {
97-
await setPlannerTaskDetails(
98-
graph,
99-
taskId,
100-
{
101-
percentComplete: 0
102-
},
103-
eTag
104-
);
84+
export const setPlannerTaskIncomplete = async (graph: IGraph, task: ITask): Promise<void> => {
85+
await setPlannerTaskDetails(graph, task, { percentComplete: 0 });
10586
};
10687

10788
/**
10889
* async promise, allows developer to set details of planner task associated with a taskId
10990
*
110-
* @param {string} taskId
111-
* @param {(PlannerTask)} details
112-
* @param {string} eTag
91+
* @param {IGraph} graph
92+
* @param {ITask} task
93+
* @param {PlannerTask} details
11394
* @returns {Promise<any>}
11495
* @memberof Graph
11596
*/
116-
export const setPlannerTaskDetails = async (
117-
graph: IGraph,
118-
taskId: string,
119-
details: PlannerTask,
120-
eTag: string
121-
): Promise<any> => {
122-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
123-
return await graph
124-
.api(`/planner/tasks/${taskId}`)
125-
.header('Cache-Control', 'no-store')
126-
.middlewareOptions(prepScopes('Group.ReadWrite.All'))
127-
.header('If-Match', eTag)
128-
.patch(JSON.stringify(details));
97+
export const setPlannerTaskDetails = async (graph: IGraph, task: ITask, details: PlannerTask): Promise<PlannerTask> => {
98+
let response: PlannerTask;
99+
try {
100+
response = (await graph
101+
.api(`/planner/tasks/${task.id}`)
102+
.header('Cache-Control', 'no-store')
103+
.middlewareOptions(prepScopes('Group.ReadWrite.All'))
104+
.header('Prefer', 'return=representation')
105+
.header('If-Match', task.eTag)
106+
.update(details)) as PlannerTask;
107+
} catch (_) {
108+
/* empty */
109+
}
110+
return response;
129111
};
130112

131113
/**
132114
* async promise, returns all planner plans associated with the group id
133115
*
116+
* @param {IGraph} graph
134117
* @param {string} groupId
135118
* @returns {(Promise<PlannerPlan[]>)}
136119
* @memberof Graph
@@ -150,6 +133,7 @@ export const getPlansForGroup = async (graph: IGraph, groupId: string): Promise<
150133
/**
151134
* async promise, returns a single plan from the Graph associated with the planId
152135
*
136+
* @param {IGraph} graph
153137
* @param {string} planId
154138
* @returns {(Promise<PlannerPlan>)}
155139
* @memberof Graph
@@ -164,6 +148,7 @@ export const getSinglePlannerPlan = async (graph: IGraph, planId: string): Promi
164148
/**
165149
* async promise, returns bucket (for tasks) associated with a planId
166150
*
151+
* @param {IGraph} graph
167152
* @param {string} planId
168153
* @returns {(Promise<PlannerBucket[]>)}
169154
* @memberof Graph
@@ -181,6 +166,7 @@ export const getBucketsForPlannerPlan = async (graph: IGraph, planId: string): P
181166
/**
182167
* async promise, returns all planner plans associated with the user logged in
183168
*
169+
* @param {IGraph} graph
184170
* @returns {(Promise<PlannerPlan[]>)}
185171
* @memberof Graph
186172
*/
@@ -197,6 +183,7 @@ export const getAllMyPlannerPlans = async (graph: IGraph): Promise<PlannerPlan[]
197183
/**
198184
* async promise, returns all tasks from planner associated with a bucketId
199185
*
186+
* @param {IGraph} graph
200187
* @param {string} bucketId
201188
* @returns {(Promise<PlannerTask[][]>)}
202189
* @memberof Graph

0 commit comments

Comments
 (0)