Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show screen when there's no dev server #205

Merged
merged 2 commits into from
Mar 8, 2024
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
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;
}
}
Loading