Skip to content

Commit

Permalink
Merge pull request #205 from chromaui/no-dev-server
Browse files Browse the repository at this point in the history
Show screen when there's no dev server
  • Loading branch information
thafryer authored Mar 8, 2024
2 parents ffb1b95 + d4d987c commit 1c4cdd9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { GitNotFound } from "./screens/Errors/GitNotFound";
import { LinkedProject } from "./screens/LinkProject/LinkedProject";
import { LinkingProjectFailed } from "./screens/LinkProject/LinkingProjectFailed";
import { LinkProject } from "./screens/LinkProject/LinkProject";
import { NoDevServer } from "./screens/NoDevServer/NoDevServer";
import { UninstallProvider } from "./screens/Uninstalled/UninstallContext";
import { Uninstalled } from "./screens/Uninstalled/Uninstalled";
import { ControlsProvider } from "./screens/VisualTests/ControlsContext";
Expand Down Expand Up @@ -89,6 +90,10 @@ export const Panel = ({ active, api }: PanelProps) => {
</Provider>
);

if (global.CONFIG_TYPE !== "DEVELOPMENT") {
return withProviders(<NoDevServer />);
}

if (addonUninstalled) {
return withProviders(<Uninstalled />);
}
Expand Down
4 changes: 4 additions & 0 deletions src/SidebarTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export const SidebarTop = ({ api }: SidebarTopProps) => {
if (gitInfoError) warning = "Visual tests locked due to Git synchronization problem.";
if (hasConfigProblem) warning = "Visual tests locked due to configuration problem.";

if (global.CONFIG_TYPE !== "DEVELOPMENT") {
return null;
}

return (
<SidebarTopButton
isDisabled={!!warning}
Expand Down
11 changes: 11 additions & 0 deletions src/screens/NoDevServer/NoDevServer.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Meta, StoryObj } from "@storybook/react";

import { NoDevServer } from "./NoDevServer";

const meta = {
component: NoDevServer,
} satisfies Meta<typeof NoDevServer>;

export const Default = {} satisfies StoryObj<typeof meta>;

export default meta;
28 changes: 28 additions & 0 deletions src/screens/NoDevServer/NoDevServer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";

import { Code } from "../../components/Code";
import { Container } from "../../components/Container";
import { Heading } from "../../components/Heading";
import { VisualTestsIcon } from "../../components/icons/VisualTestsIcon";
import { Screen } from "../../components/Screen";
import { Stack } from "../../components/Stack";
import { Text } from "../../components/Text";

export const NoDevServer = () => {
return (
<Screen footer={null}>
<Container>
<Stack>
<div>
<VisualTestsIcon />
<Heading>Visual tests</Heading>
<Text>
Visual tests only runs locally. To test this Storybook, clone it to your machine and
run <Code>npx storybook dev</Code>.
</Text>
</div>
</Stack>
</Container>
</Screen>
);
};
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import type { Configuration, getConfiguration, GitInfo, TaskName } from "chromat

import { SelectedBuildFieldsFragment } from "./gql/graphql";

declare global {
// eslint-disable-next-line no-var, vars-on-top
var CONFIG_TYPE: string;
}

export type AnnouncedBuild = Extract<SelectedBuildFieldsFragment, { __typename: "AnnouncedBuild" }>;
export type PublishedBuild = Extract<SelectedBuildFieldsFragment, { __typename: "PublishedBuild" }>;
export type StartedBuild = Extract<SelectedBuildFieldsFragment, { __typename: "StartedBuild" }>;
Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "*.png" {
const content: any;
export default content;
}
}

0 comments on commit 1c4cdd9

Please sign in to comment.