Skip to content

Commit

Permalink
Removal of ignore notation in storybook eslint and transition to acti…
Browse files Browse the repository at this point in the history
…ons function (#489)

* fix: desprecated .storybook/main.ts and actions-addons

* remove: ignore notation in storybook eslint and transition to actions function

* remove: unnecessary eslint ignore code
  • Loading branch information
kamegoro committed Nov 4, 2023
1 parent de1915e commit 4c84b79
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 38 deletions.
6 changes: 3 additions & 3 deletions frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// .storybook/main.ts

import type { StorybookViteConfig } from "@storybook/builder-vite";
import path from "path";
const config: StorybookViteConfig = {
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-styling",
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/components/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-console */
import { Meta } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import Button from "./Button";

const meta = {
Expand All @@ -13,16 +12,16 @@ const meta = {

export default meta;

export const Default = {
export const Default: StoryObj<typeof Button> = {
args: {
children: (
<>
<span>&uarr;</span>
<span>Update</span>
</>
),
onClick: () => {
console.log("click");
},
},
argTypes: {
onClick: { action: "clicked" },
},
};
24 changes: 10 additions & 14 deletions frontend/src/components/ClustersList.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-console */
import { StoryFn, Meta } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import ClustersList from "./ClustersList";

const meta = {
Expand All @@ -14,17 +13,14 @@ const meta = {
export default meta;

//👇 We create a “template” of how args map to rendering
const Template: StoryFn<typeof ClustersList> = () => (
<ClustersList
filteredNamespaces={[""]}
installedReleases={[]}
onClusterChange={() => {
console.log("onClusterChange called");
}}
selectedCluster={""}
/>
);
export const Default: StoryObj<typeof ClustersList> = {
args: {
filteredNamespaces: [""],
installedReleases: [],
selectedCluster: "",
},

export const Default = {
render: Template,
argTypes: {
onClusterChange: { actions: "onClusterChange called" },
},
};
8 changes: 4 additions & 4 deletions frontend/src/components/SelectMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
/**
* @file SelectMenu.stories.tsx
* @description This file contains the SelectMenu
Expand All @@ -7,7 +6,8 @@
* The default story renders the component with the default props.
*/

import { Meta } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import SelectMenu, { SelectMenuItem } from "./SelectMenu";

const meta = {
Expand All @@ -21,7 +21,7 @@ const meta = {

export default meta;

export const Default = {
export const Default: StoryObj<typeof SelectMenu> = {
args: {
header: "Header",
children: [
Expand All @@ -30,6 +30,6 @@ export const Default = {
<SelectMenuItem label="Item 3" id={3} key="item3" />,
],
selected: 1,
onSelect: (id: number) => console.log(id),
onSelect: (id: number) => action("onSelect")(id),
},
};
4 changes: 2 additions & 2 deletions frontend/src/components/common/DropDown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meta } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import DropDown from "./DropDown";
import { BsSlack, BsGithub } from "react-icons/bs";

Expand All @@ -14,8 +15,7 @@ const meta = {
export default meta;

const onClick = () => {
// eslint-disable-next-line no-console
console.log("drop down clicked");
action("onClick")("drop down clicked");
};

export const Default = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/modal/ErrorModal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */
import { action } from "@storybook/addon-actions";
import { Meta } from "@storybook/react";
import ErrorModal from "./ErrorModal";

Expand All @@ -16,7 +16,7 @@ export default meta;
export const Default = {
args: {
onClose: () => {
console.log("on Close clicked");
action("onClose")("on Close clicked");
},
titleText: "Failed to get list of charts",
contentText:
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */
import { action } from "@storybook/addon-actions";
import { StoryObj, StoryFn, Meta } from "@storybook/react";
import Modal, { ModalAction, ModalButtonStyle } from "./Modal";

Expand All @@ -23,14 +23,14 @@ const confirmModalActions: ModalAction[] = [
id: "1",
text: "Cancel",
callback: () => {
console.log("confirmModal: clicked Cancel");
action("cancelCallback")("confirmModal: clicked Cancel");
},
},
{
id: "2",
text: "Confirm",
callback: () => {
console.log("confirmModal: clicked Confirm");
action("confirmCallback")("confirmModal: clicked Confirm");
},
variant: ModalButtonStyle.info,
},
Expand All @@ -53,14 +53,14 @@ const customModalActions: ModalAction[] = [
className:
"text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800",
callback: () => {
console.log("confirmModal: clicked custom button 1");
action("clickCustomButton")("confirmModal: clicked custom button 1");
},
},
{
id: "2",
text: "custom button 2",
callback: () => {
console.log("confirmModal: clicked custom button 2");
action("clickCustomButton")("confirmModal: clicked custom button 2");
},
variant: ModalButtonStyle.error,
},
Expand All @@ -76,7 +76,7 @@ export const CustomModal: StoryObj<typeof Modal> = {
<button
className="bg-cyan-500 p-2"
type="button"
onClick={() => console.log("just a button")}
onClick={() => action("onClick")("just a button")}
>
Just a button
</button>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ const Modal = ({
</div>
)}
</>,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
document.getElementById("portal")!
);
};
Expand Down

0 comments on commit 4c84b79

Please sign in to comment.