Skip to content

Commit a59352a

Browse files
author
Brenda Coronel
committed
Task List Demo modifications
1 parent 7c1bf82 commit a59352a

File tree

4 files changed

+40
-37
lines changed

4 files changed

+40
-37
lines changed

packages/playground/src/demo/display/task-grid/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getLogger } from "@azure/bonito-core";
22
import { LoadMoreFn } from "@azure/bonito-ui/lib/hooks";
3-
import { BatchTaskOutput } from "@batch/ui-service/lib/batch-models";
43

54
export interface DemoTask {
65
name: string;

packages/playground/src/demo/display/task-list/task-list-demo.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@ import { Slider } from "@fluentui/react/lib/Slider";
66
import { Stack } from "@fluentui/react/lib/Stack";
77
import React from "react";
88
import { DemoPane } from "../../../layout/demo-pane";
9-
import { PagedAsyncIterableIterator } from "@azure/core-paging";
10-
import { BatchTaskOutput } from "@batch/ui-service/src/batch-models";
9+
import { TextField } from "@azure/bonito-ui/src/components/form";
10+
import { TextFieldOnChange } from "../../../functions";
11+
//import { PagedAsyncIterableIterator } from "@azure/core-paging";
1112

1213
export const TaskListDemo: React.FC = () => {
13-
const [taskNumberSlider, setTaskNumberSlider] = React.useState(0);
14-
const [items, setItems] = React.useState<
15-
PagedAsyncIterableIterator<BatchTaskOutput>
16-
>([]);
17-
const taskNumberSliderOnChange = (value: number) => {
18-
setTaskNumberSlider(value);
19-
};
20-
const [accountEndpoint, setAccountEndpoint] = React.useState<string>(
14+
const [taskNumberField, setTaskNumberField] = React.useState(0);
15+
const [items, setItems] = React.useState<any>([]);
16+
17+
const [accountEndpoint] = React.useState<string>(
2118
"mercury.eastus.batch.azure.com"
2219
);
23-
const [jobId, setJobId] = React.useState<string>("faketestjob1");
20+
const [jobId] = React.useState<string>("faketestjob1");
2421

2522
React.useEffect(() => {
2623
let isMounted = true;
@@ -56,12 +53,12 @@ export const TaskListDemo: React.FC = () => {
5653
styles={{ root: { marginBottom: "1em" } }}
5754
>
5855
<Stack.Item grow={1}>
59-
<Slider
60-
label="Additional Tasks Slider"
61-
min={0}
62-
max={50}
63-
value={taskNumberSlider}
64-
onChange={taskNumberSliderOnChange}
56+
<TextField
57+
value={taskNumberField}
58+
onChange={(_, newValue) => {
59+
const number = parseInt(`${newValue}`);
60+
setTaskNumberField(number);
61+
}}
6562
/>
6663
</Stack.Item>
6764
</Stack>

packages/react/src/task/task-list.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
import { BatchTaskOutput } from "@batch/ui-service/lib/batch-models";
88
import { CiCircleChevDown } from "react-icons/ci";
99
import { IconButton } from "@fluentui/react/lib/Button";
10-
import { PagedAsyncIterableIterator } from "@azure/core-paging";
10+
//import { PagedAsyncIterableIterator } from "@azure/core-paging";
1111

1212
interface TaskListProps {
13-
pagedTasks: PagedAsyncIterableIterator<BatchTaskOutput>;
13+
pagedTasks: any;
1414
}
1515

1616
interface taskRow extends BatchTaskOutput {
@@ -25,19 +25,21 @@ export const TaskList = (props: TaskListProps) => {
2525
const [isCompact] = React.useState<boolean>(false);
2626

2727
React.useEffect(() => {
28-
const taskArray = [];
28+
const parseTasks = async () => {
29+
const taskArray = [];
2930

30-
for await (const task of pagedTasks) {
31-
taskArray.push({
32-
url: task.url,
33-
id: task.id,
34-
state: task.state,
35-
creationTime: task.creationTime,
36-
executionInfo: task.executionInfo,
37-
});
38-
}
39-
40-
setItems(taskArray);
31+
for await (const task of pagedTasks) {
32+
taskArray.push({
33+
url: task.url,
34+
id: task.id,
35+
state: task.state,
36+
creationTime: task.creationTime,
37+
executionInfo: task.executionInfo,
38+
});
39+
}
40+
setItems(taskArray);
41+
};
42+
parseTasks();
4143
}, [pagedTasks]);
4244

4345
return (

packages/service/src/task/__tests__/fake-task-service.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ describe("FakeTaskService", () => {
1919
});
2020

2121
test("Generate tasks", async () => {
22-
const task = await service.generateTasks(accountEndpoint, jobId);
23-
expect(task[0].id).toEqual("task1");
24-
expect(task[1].id).toEqual("task2");
25-
expect(task[2].id).toEqual("task3");
22+
const tasks = await service.listTasks(accountEndpoint, jobId, 3);
23+
const allTasks = [];
24+
for await (const task of tasks) {
25+
allTasks.push(task);
26+
}
27+
28+
expect(allTasks[0].id).toEqual("task1");
29+
expect(allTasks[1].id).toEqual("task2");
30+
expect(allTasks[2].id).toEqual("task3");
2631
});
2732

2833
test("List batch tasks", async () => {
@@ -49,7 +54,7 @@ describe("FakeTaskService", () => {
4954
});
5055

5156
test("List hardcoded batch tasks", async () => {
52-
const tasks = await service.listHardcodedTasks(accountEndpoint, jobId);
57+
const tasks = await service.listTasks(accountEndpoint, jobId);
5358

5459
const allTasks = [];
5560

0 commit comments

Comments
 (0)