Skip to content

Commit

Permalink
Align changed story count in notification and sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
thafryer committed Feb 24, 2024
1 parent 77c3dfb commit 04928d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/SidebarTop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type API, useChannel } from "@storybook/manager-api";
import { type API, useChannel, useStorybookState } from "@storybook/manager-api";
import { color } from "@storybook/theming";
import pluralize from "pluralize";
import React, { useEffect, useRef } from "react";
Expand Down Expand Up @@ -37,6 +37,9 @@ export const SidebarTop = ({ api }: SidebarTopProps) => {
const [gitInfoError] = useSharedState<Error>(GIT_INFO_ERROR);

const lastStep = useRef(localBuildProgress?.currentStep);
const { status } = useStorybookState();
const changedStoryCount = Object.values(status).filter((value) => value[ADDON_ID]?.status === "warn");

useEffect(() => {
if (localBuildProgress?.currentStep === lastStep.current) return;
lastStep.current = localBuildProgress?.currentStep;
Expand Down Expand Up @@ -83,8 +86,8 @@ export const SidebarTop = ({ api }: SidebarTopProps) => {
// eslint-disable-next-line no-nested-ternary
subHeadline: localBuildProgress.errorCount
? `Encountered ${pluralize("component error", localBuildProgress.errorCount, true)}`
: localBuildProgress.changeCount
? `Found ${pluralize("change", localBuildProgress.changeCount, true)}`
: changedStoryCount.length
? `Found ${pluralize("change", changedStoryCount.length, true)}`
: "No visual changes detected",
},
icon: {
Expand Down

0 comments on commit 04928d3

Please sign in to comment.