Skip to content

Commit b81bf7f

Browse files
authored
Feat: Make tasks progress component more flexible (#664)
1 parent 4a28125 commit b81bf7f

File tree

6 files changed

+566
-238
lines changed

6 files changed

+566
-238
lines changed

web/client/src/library/components/ide/ActivePlan.tsx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Popover, Transition } from '@headlessui/react'
22
import { useQueryClient } from '@tanstack/react-query'
33
import clsx from 'clsx'
4-
import { lazy, Fragment, type MouseEvent } from 'react'
4+
import { Fragment, type MouseEvent } from 'react'
55
import { apiCancelPlanApply } from '~/api'
66
import { useStoreContext } from '~/context/context'
77
import {
@@ -14,10 +14,7 @@ import {
1414
} from '~/context/plan'
1515
import { EnumSize, EnumVariant } from '~/types/enum'
1616
import { Button } from '../button/Button'
17-
18-
const TasksProgress = lazy(
19-
async () => await import('../tasksProgress/TasksProgress'),
20-
)
17+
import TasksOverview from '../tasksOverview/TasksOverview'
2118

2219
export default function ActivePlan({
2320
plan,
@@ -67,15 +64,33 @@ export default function ActivePlan({
6764
>
6865
<Popover.Panel className="absolute right-1 z-10 mt-8 transform">
6966
<div className="overflow-hidden rounded-lg bg-theme shadow-lg ring-1 ring-black ring-opacity-5">
70-
<TasksProgress
71-
environment={environment}
72-
tasks={plan.tasks}
73-
updated_at={plan.updated_at}
74-
headline="Most Recent Plan"
75-
showBatches={plan.type !== EnumPlanApplyType.Virtual}
76-
showVirtualUpdate={plan.type === EnumPlanApplyType.Virtual}
77-
planState={planState}
78-
/>
67+
<TasksOverview tasks={plan.tasks}>
68+
{({ total, completed, models }) => (
69+
<>
70+
<TasksOverview.Summary
71+
environment={environment.name}
72+
planState={planState}
73+
headline="Most Recent Plan"
74+
completed={completed}
75+
total={total}
76+
updateType={
77+
plan.type === EnumPlanApplyType.Virtual
78+
? 'Virtual'
79+
: 'Backfill'
80+
}
81+
updatedAt={plan.updated_at}
82+
/>
83+
<TasksOverview.Details
84+
models={models}
85+
showBatches={plan.type !== EnumPlanApplyType.Virtual}
86+
showVirtualUpdate={
87+
plan.type === EnumPlanApplyType.Virtual
88+
}
89+
showProgress={true}
90+
/>
91+
</>
92+
)}
93+
</TasksOverview>
7994
<div className="my-4 px-4">
8095
{planState === EnumPlanState.Applying && (
8196
<Button

web/client/src/library/components/plan/Plan.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function Plan({
279279
<Plan.Header error={error} />
280280
<Divider />
281281
<div className="flex flex-col w-full h-full overflow-hidden overflow-y-auto p-4 scrollbar scrollbar--vertical">
282-
<Plan.Wizard setRefTaskProgress={elTaskProgress} />
282+
<Plan.Wizard setRefTasksOverview={elTaskProgress} />
283283
</div>
284284
<Divider />
285285
<Plan.Actions

web/client/src/library/components/plan/PlanWizard.tsx

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ import {
2525
isObjectNotEmpty,
2626
} from '../../../utils'
2727
import Spinner from '../logo/Spinner'
28-
import TasksProgress from '../tasksProgress/TasksProgress'
2928
import { EnumPlanChangeType, usePlan } from './context'
3029
import { getBackfillStepHeadline, isModified } from './help'
3130
import Plan from './Plan'
3231
import PlanChangePreview from './PlanChangePreview'
3332
import { useChannelEvents } from '@api/channels'
3433
import { EnumVariant } from '~/types/enum'
3534
import Banner from '@components/banner/Banner'
35+
import TasksOverview from '../tasksOverview/TasksOverview'
3636

3737
export default function PlanWizard({
38-
setRefTaskProgress,
38+
setRefTasksOverview,
3939
}: {
40-
setRefTaskProgress: RefObject<HTMLDivElement>
40+
setRefTasksOverview: RefObject<HTMLDivElement>
4141
}): JSX.Element {
4242
const [subscribe] = useChannelEvents()
4343

@@ -338,20 +338,39 @@ export default function PlanWizard({
338338
<Suspense
339339
fallback={<Spinner className="w-4 h-4 mr-2" />}
340340
>
341-
<TasksProgress
342-
environment={environment}
341+
<TasksOverview
343342
tasks={tasks}
344-
changes={{
345-
modified,
346-
added,
347-
removed,
348-
}}
349-
updated_at={activeBackfill?.updated_at}
350-
showBatches={hasBackfills}
351-
showVirtualUpdate={hasVirtualUpdate}
352-
planState={planState}
353-
setRefTaskProgress={setRefTaskProgress}
354-
/>
343+
setRefTasksOverview={setRefTasksOverview}
344+
>
345+
{({ total, completed, models }) => (
346+
<>
347+
<TasksOverview.Summary
348+
environment={environment.name}
349+
planState={planState}
350+
headline="Target Environment"
351+
completed={completed}
352+
total={total}
353+
updateType={
354+
hasVirtualUpdate ? 'Virtual' : 'Backfill'
355+
}
356+
updatedAt={activeBackfill?.updated_at}
357+
/>
358+
{models != null && (
359+
<TasksOverview.Details
360+
models={models}
361+
changes={{
362+
modified,
363+
added,
364+
removed,
365+
}}
366+
showBatches={hasBackfills}
367+
showVirtualUpdate={hasVirtualUpdate}
368+
showProgress={true}
369+
/>
370+
)}
371+
</>
372+
)}
373+
</TasksOverview>
355374
</Suspense>
356375
</>
357376
)}

0 commit comments

Comments
 (0)