Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/client/src/library/components/editor/EditorPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default function EditorPreview({
includes(
[
EnumErrorKey.Fetchdf,
EnumErrorKey.General,
EnumErrorKey.EvaluateModel,
EnumErrorKey.RenderQuery,
EnumErrorKey.ColumnLineage,
Expand Down
5 changes: 2 additions & 3 deletions web/client/src/library/components/plan/Plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ function Plan(): JSX.Element {
function reset(): void {
setPlanAction(new ModelPlanAction({ value: EnumPlanAction.Run }))

resetPlanTrackers()
clearPlanApply()

cleanUp()

setTimeout(() => resetPlanTrackers(), 500)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we delay reset to make state change animation smoother

}

function cancel(): void {
Expand All @@ -78,7 +78,6 @@ function Plan(): JSX.Element {
function apply(): void {
setPlanAction(new ModelPlanAction({ value: EnumPlanAction.Applying }))

resetPlanTrackers()
clearPlanApply()

dispatch([{ type: EnumPlanActions.ResetTestsReport }])
Expand Down
202 changes: 120 additions & 82 deletions web/client/src/library/components/plan/PlanApplyStageTracker.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Disclosure, Transition } from '@headlessui/react'
import {
MinusCircleIcon,
PlusCircleIcon,
ExclamationCircleIcon,
} from '@heroicons/react/24/solid'
import { MinusCircleIcon, PlusCircleIcon } from '@heroicons/react/24/solid'
import { ExclamationCircleIcon } from '@heroicons/react/24/outline'
import { CheckIcon } from '@heroicons/react/20/solid'
import clsx from 'clsx'
import { useEffect, useMemo, useRef, useState } from 'react'
Expand All @@ -16,6 +13,8 @@ import {
isNil,
toDateFormat,
isFalse,
includes,
isFalseOrNil,
} from '../../../utils'
import { EnumPlanChangeType, usePlan } from './context'
import { getPlanOverviewDetails } from './help'
Expand Down Expand Up @@ -45,11 +44,8 @@ export default function PlanApplyStageTracker(): JSX.Element {
const planCancel = useStorePlan(s => s.planCancel)
const planAction = useStorePlan(s => s.planAction)

const { plan_options } = getPlanOverviewDetails(
planApply,
planOverview,
planCancel,
)
const { plan_options, hasChanges, hasBackfills, isFailed } =
getPlanOverviewDetails(planApply, planOverview, planCancel)

const hasTestsDetails = isNotNil(tests) && Boolean(tests.total)
const showTestsMessage =
Expand All @@ -60,6 +56,11 @@ export default function PlanApplyStageTracker(): JSX.Element {
isFalse(planAction.isProcessing) &&
isFalse(planAction.isDone) &&
isFalse(planCancel.isFinished)
const showFailedMessage =
isFailed &&
[hasFailedTests, hasTestsDetails, hasChanges, hasBackfills].every(
isFalseOrNil,
)

return (
<Transition
Expand All @@ -71,53 +72,78 @@ export default function PlanApplyStageTracker(): JSX.Element {
leave="transition ease duration-300 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
className="my-2"
className={clsx('my-2 rounded-xl', isFailed && 'bg-danger-5')}
>
{isTrue(plan_options?.skip_tests) ? (
{showFailedMessage ? (
<Banner
className="flex items-center mb-1"
className="flex items-center"
size={EnumSize.sm}
hasBackground={false}
variant={EnumVariant.Danger}
>
<CheckIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">Tests Skipped</Banner.Label>
<ExclamationCircleIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">Plan Failed</Banner.Label>
</Banner>
) : hasTestsDetails ? (
<StageTestsFailed
isOpen={true}
report={tests}
/>
) : showTestsMessage ? (
<StageTestsCompleted report={tests} />
) : (
<Banner
className="flex items-center mb-1"
size={EnumSize.sm}
hasBackground={false}
>
<CheckIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">No Tests</Banner.Label>
</Banner>
)}
{isFalse(hasFailedTests) && (
<>
<StageChanges isOpen={showChangesAndBackfills} />
<StageBackfills isOpen={showChangesAndBackfills} />
<StageVirtualUpdate />
{planApply.shouldShowEvaluation && (
<StageEvaluate
start={planApply.evaluationStart}
end={
planApply.isFinished
? planApply.evaluationEnd ?? planCancel.meta?.end
: undefined
}
{isFailed && (
<Banner
className="flex items-center mb-1"
size={EnumSize.sm}
variant={EnumVariant.Danger}
>
<ExclamationCircleIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">Plan Failed</Banner.Label>
</Banner>
)}
{isTrue(plan_options?.skip_tests) ? (
<Banner
className="flex items-center mb-1"
size={EnumSize.sm}
hasBackground={false}
>
<StageCreation />
<StageRestate />
<StageBackfill />
<StagePromote />
</StageEvaluate>
<CheckIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">
Tests Skipped
</Banner.Label>
</Banner>
) : hasTestsDetails ? (
<StageTestsFailed
isOpen={true}
report={tests}
/>
) : showTestsMessage ? (
<StageTestsCompleted report={tests} />
) : (
<Banner
className="flex items-center mb-1"
size={EnumSize.sm}
hasBackground={false}
>
<CheckIcon className="w-4 mr-2" />
<Banner.Label className="mr-2 text-sm">No Tests</Banner.Label>
</Banner>
)}
{isFalse(hasFailedTests) && (
<>
<StageChanges isOpen={showChangesAndBackfills} />
<StageBackfills isOpen={showChangesAndBackfills} />
<StageVirtualUpdate />
{planApply.shouldShowEvaluation && (
<StageEvaluate
start={planApply.evaluationStart}
end={
planApply.isFinished
? planApply.evaluationEnd ?? planCancel.meta?.end
: undefined
}
>
<StageCreation />
<StageRestate />
<StageBackfill />
<StagePromote />
</StageEvaluate>
)}
</>
)}
</>
)}
Expand All @@ -136,7 +162,9 @@ function StageChanges({ isOpen = false }: { isOpen?: boolean }): JSX.Element {
planCancel,
)
const tempMeta = stageChanges?.meta ?? meta
const showChanges = tempMeta?.status === Status.init || isTrue(hasChanges)
const showChanges =
includes([Status.init, Status.fail], stageChanges?.meta?.status) ||
isTrue(hasChanges)

return showChanges ? (
<Stage
Expand Down Expand Up @@ -288,20 +316,18 @@ function StageEvaluate({
}, 500)
}, [])

return (
return isNil(start) ? (
<></>
) : (
<div
ref={elStageEvaluate}
className="pt-4 pb-2 text-xs"
>
{isNotNil(start) && (
<>
<span className="text-neutral-500 block px-4 mb-1">
Evaluation started at{' '}
{toDateFormat(new Date(start), 'yyyy-mm-dd hh-mm-ss')}
</span>
<Divider />
</>
)}
<span className="text-neutral-500 block px-4 mb-1">
Evaluation started at{' '}
{toDateFormat(new Date(start), 'yyyy-mm-dd hh-mm-ss')}
</span>
<Divider />
<div className="py-2">{children}</div>
{isNotNil(end) && (
<>
Expand All @@ -319,9 +345,9 @@ function StageEvaluate({
function StageCreation({ isOpen }: { isOpen?: boolean }): JSX.Element {
const planApply = useStorePlan(s => s.planApply)

if (isNil(planApply.stageCreation)) return <></>

return (
return isNil(planApply.stageCreation) ? (
<></>
) : (
<Stage
meta={planApply.stageCreation?.meta}
states={[
Expand Down Expand Up @@ -418,9 +444,9 @@ function StageBackfill(): JSX.Element {
[backfills, planApply.tasks],
)

if (isNil(stageBackfill) || isNil(environment)) return <></>
const showStageBackfill = isNotNil(stageBackfill) && isNotNil(environment)

return (
return showStageBackfill ? (
<Stage
meta={stageBackfill.meta}
states={['Backfilled', 'Backfilling Failed', 'Backfilling Intervals...']}
Expand Down Expand Up @@ -458,6 +484,8 @@ function StageBackfill(): JSX.Element {
)}
</TasksOverview>
</Stage>
) : (
<></>
)
}

Expand Down Expand Up @@ -515,12 +543,19 @@ function StageVirtualUpdate(): JSX.Element {

const planApply = useStorePlan(s => s.planApply)
const planOverview = useStorePlan(s => s.planOverview)
const planCancel = useStorePlan(s => s.planCancel)

const { isFailed } = getPlanOverviewDetails(
planApply,
planOverview,
planCancel,
)

const isVirtualUpdate =
planApply.overview?.isVirtualUpdate ?? planOverview.isVirtualUpdate
const isUpdated = isTrue(planApply.isFinished)

return isVirtualUpdate ? (
return isVirtualUpdate && isFalse(isFailed) ? (
<Stage
meta={{
status: Status.success,
Expand Down Expand Up @@ -647,7 +682,8 @@ function Stage({
const planOverview = useStorePlan(s => s.planOverview)
const planApply = useStorePlan(s => s.planApply)

const hasChildren = isNotNil(panel) || isNotNil(children)
const hasChildren =
(meta?.status !== Status.fail && isNotNil(panel)) || isNotNil(children)

const [open, setOpen] = useState(isOpen)

Expand All @@ -665,19 +701,21 @@ function Stage({
setOpen(isOpen && hasChildren)
}, [isOpen, hasChildren])

const variant =
meta?.status === Status.success
? EnumVariant.Success
: meta?.status === Status.fail
? EnumVariant.Danger
: EnumVariant.Info
const isStatusFail = meta?.status === Status.fail
const isStatusSuccess = meta?.status === Status.success
const isStatusInit = meta?.status === Status.init

const variant = isStatusSuccess
? EnumVariant.Success
: isStatusFail
? EnumVariant.Danger
: EnumVariant.Info
const [titleSuccess, titleFail, titleDefault] = states
const text =
meta?.status === Status.success
? titleSuccess
: meta?.status === Status.fail
? titleFail
: titleDefault
const text = isStatusSuccess
? titleSuccess
: isStatusFail
? titleFail
: titleDefault

return (
<Transition
Expand Down Expand Up @@ -710,7 +748,7 @@ function Stage({
>
{isNil(trigger) ? (
<>
{meta?.status === Status.init && (
{isStatusInit && (
<Loading
text={text}
hasSpinner
Expand All @@ -719,9 +757,9 @@ function Stage({
className="w-full"
/>
)}
{meta?.status !== Status.init && (
{isFalse(isStatusInit) && (
<div className="flex items-center h-full">
{showDetails ? (
{showDetails && hasChildren ? (
<>
{open ? (
<MinusCircleIcon className="w-4 mr-2" />
Expand Down
5 changes: 4 additions & 1 deletion web/client/src/library/components/plan/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ type PlanOverviewDetails = Pick<
| 'stageValidation'
| 'stageChanges'
| 'stageBackfills'
>
> & {
isFailed: boolean
}

export function getPlanOverviewDetails(
planApply: ModelPlanApplyTracker,
Expand Down Expand Up @@ -56,5 +58,6 @@ export function getPlanOverviewDetails(
stageValidation: plan.stageValidation,
stageBackfills: plan.stageBackfills,
stageChanges: plan.stageChanges,
isFailed: overview.isFailed || planCancel.isFailed || planApply.isFailed,
}
}
Loading