Skip to content

Commit

Permalink
Don't show eyebrow unnecessarily
Browse files Browse the repository at this point in the history
If the `StoryInfo` is already going to prompt you to switch, there's no point in redundantly showing you also in the eyebrow:

https://www.chromatic.com/review?appId=6480e1b0042842f149cfd74c&number=87&activeElementId=comment-thread-64ff2a5781851ff6d5e44492
  • Loading branch information
tmeasday committed Sep 12, 2023
1 parent ea70fc7 commit fc95b12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
28 changes: 14 additions & 14 deletions src/screens/VisualTests/BuildResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ interface BuildResultsProps {
nextBuild: NextBuildFieldsFragment;
switchToNextBuild?: () => void;
startDevBuild: () => void;
isOutdated: boolean;
isReviewing: boolean;
onAccept: (testId: string, batch: ReviewTestBatch) => Promise<void>;
onUnaccept: (testId: string) => Promise<void>;
Expand All @@ -43,7 +42,6 @@ export const BuildResults = ({
nextBuild,
switchToNextBuild,
startDevBuild,
isOutdated,
isReviewing,
onAccept,
onUnaccept,
Expand All @@ -57,18 +55,6 @@ export const BuildResults = ({

const isRunningBuildInProgress = runningBuild && runningBuild.step !== "complete";
const isReviewable = nextBuild.id === storyBuild.id;
const showBuildStatus =
// We always want to show the status of the running build (until it is done)
isRunningBuildInProgress ||
// Even if there's no build running, we want to show the next build if it hasn't been selected.
!isReviewable;
const runningBuildIsNextBuild = runningBuild && runningBuild?.buildId === nextBuild.id;
const buildStatus = showBuildStatus && (
<BuildProgress
runningBuild={(runningBuildIsNextBuild || isRunningBuildInProgress) && runningBuild}
switchToNextBuild={switchToNextBuild}
/>
);

const storyTests = [
...getFragment(
Expand All @@ -85,6 +71,20 @@ export const BuildResults = ({
const isStorySuperseded =
!isReviewable && nextStoryTests.every(({ status }) => status !== TestStatus.InProgress);

const showBuildStatus =
// We always want to show the status of the running build (until it is done)
isRunningBuildInProgress ||
// Even if there's no build running, we want to show the next build if it hasn't been selected,
// unless the story info itself is going to tell us to switch already
(!isReviewable && !(isStorySuperseded && switchToNextBuild));
const runningBuildIsNextBuild = runningBuild && runningBuild?.buildId === nextBuild.id;
const buildStatus = showBuildStatus && (
<BuildProgress
runningBuild={(runningBuildIsNextBuild || isRunningBuildInProgress) && runningBuild}
switchToNextBuild={switchToNextBuild}
/>
);

// It shouldn't be possible for one test to be skipped but not all of them
const isSkipped = !!storyTests?.find((t) => t.result === TestResult.Skipped);
if (isSkipped) {
Expand Down
8 changes: 4 additions & 4 deletions src/screens/VisualTests/VisualTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export const VisualTests = ({
data?.storyBuild ?? data?.project?.nextBuild
);

// Currently only used by the sidebar button to show a blue dot ("build outdated")
const isOutdated = storyBuild?.uncommittedHash !== gitInfo.uncommittedHash;
useEffect(() => setOutdated(isOutdated), [isOutdated, setOutdated]);

// If the next build is *newer* than the current commit, we don't want to switch to the build
const nextBuildNewer = nextBuild && nextBuild.committedAt > gitInfo.committedAt;
const canSwitchToNextBuild = nextBuild && !nextBuildNewer;
Expand Down Expand Up @@ -178,9 +182,6 @@ export const VisualTests = ({
);

const isRunningBuildStarting = runningBuild && !["success", "error"].includes(runningBuild.step);
const isOutdated = storyBuild?.uncommittedHash !== gitInfo.uncommittedHash;

useEffect(() => setOutdated(isOutdated), [isOutdated, setOutdated]);

return !nextBuild || error ? (
<NoBuild
Expand All @@ -201,7 +202,6 @@ export const VisualTests = ({
nextBuild,
switchToNextBuild: canSwitchToNextBuild && switchToNextBuild,
startDevBuild,
isOutdated,
isReviewing,
onAccept,
onUnaccept,
Expand Down

0 comments on commit fc95b12

Please sign in to comment.