Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: manage provisioner tags in template editor#11600

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
f0ssel merged 11 commits intomainfromf0ssel/manage-tags
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
1 change: 1 addition & 0 deletionssite/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,7 @@
"@storybook/addon-links": "7.5.2",
"@storybook/addon-mdx-gfm": "7.5.2",
"@storybook/addon-themes": "7.6.4",
"@storybook/preview-api": "7.6.9",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What does it do?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is for theuseArgs hook I'm using to update state of a rendered component in storybook.

"@storybook/react": "7.5.2",
"@storybook/react-vite": "7.5.2",
"@swc/core": "1.3.38",
Expand Down
88 changes: 71 additions & 17 deletionssite/pnpm-lock.yaml
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

8 changes: 2 additions & 6 deletionssite/src/pages/HealthPage/Content.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,7 +170,7 @@ export const Pill = forwardRef<HTMLDivElement, PillProps>((props, ref) => {
border: `1px solid ${theme.palette.divider}`,
fontSize: 12,
fontWeight: 500,
padding:"8px 16px 8px 8px",
padding:8,
gap: 8,
cursor: "default",
}}
Expand All@@ -182,11 +182,7 @@ export const Pill = forwardRef<HTMLDivElement, PillProps>((props, ref) => {
);
});

type BooleanPillProps = Omit<
ComponentProps<typeof Pill>,
"children" | "icon" | "value"
> & {
children: string;
type BooleanPillProps = Omit<ComponentProps<typeof Pill>, "icon" | "value"> & {
value: boolean;
};

Expand Down
44 changes: 38 additions & 6 deletionssite/src/pages/HealthPage/ProvisionerDaemonsPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ import Person from "@mui/icons-material/Person";
import SwapHoriz from "@mui/icons-material/SwapHoriz";
import Tooltip from "@mui/material/Tooltip";
import Sell from "@mui/icons-material/Sell";
import { FC } from "react";
import CloseIcon from "@mui/icons-material/Close";
import IconButton from "@mui/material/IconButton";

export const ProvisionerDaemonsPage = () => {
const healthStatus = useOutletContext<HealthcheckReport>();
Expand DownExpand Up@@ -129,9 +132,9 @@ export const ProvisionerDaemonsPage = () => {
</span>
</Pill>
</Tooltip>
{Object.keys(extraTags).map((k) =>
renderTag(k,extraTags[k]),
)}
{Object.keys(extraTags).map((k) => (
<ProvisionerTag key={k} k={k} v={extraTags[k]} />
))}
</div>
</header>

Expand DownExpand Up@@ -188,13 +191,42 @@ const parseBool = (s: string): { valid: boolean; value: boolean } => {
}
};

const renderTag = (k: string, v: string) => {
interface ProvisionerTagProps {
k: string;
v: string;
onDelete?: (key: string) => void;
}

export const ProvisionerTag: FC<ProvisionerTagProps> = ({ k, v, onDelete }) => {
const { valid, value: boolValue } = parseBool(v);
const kv = `${k}: ${v}`;
const content = onDelete ? (
<>
{kv}
<IconButton
aria-label={"delete-" + k}
size="small"
color="secondary"
onClick={() => {
onDelete(k);
}}
>
<CloseIcon
fontSize="inherit"
css={{
width: 14,
height: 14,
}}
/>
</IconButton>
</>
) : (
kv
);
if (valid) {
return <BooleanPill value={boolValue}>{kv}</BooleanPill>;
return <BooleanPill value={boolValue}>{content}</BooleanPill>;
}
return <Pill icon={<Sell />}>{kv}</Pill>;
return <Pill icon={<Sell />}>{content}</Pill>;
};

export default ProvisionerDaemonsPage;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
import type { Meta, StoryObj } from "@storybook/react";
import { chromatic } from "testHelpers/chromatic";
import { MockTemplateVersion } from "testHelpers/entities";
import { ProvisionerTagsPopover } from "./ProvisionerTagsPopover";
import { useArgs } from "@storybook/preview-api";

const meta: Meta<typeof ProvisionerTagsPopover> = {
title: "component/ProvisionerTagsPopover",
parameters: {
chromatic,
layout: "centered",
},
component: ProvisionerTagsPopover,
args: {
tags: MockTemplateVersion.job.tags,
},
render: function Render(args) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Since you are passing the component you don't need this render function at all. At least if you are using it just to test with Chromatic.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I wanted this to function in Storybook live, and my understanding was that this was the way to manipulate args getting passed into the component withuseArgs().

const [{ tags }, updateArgs] = useArgs();

return (
<ProvisionerTagsPopover
{...args}
tags={tags}
onSubmit={({ key, value }) => {
updateArgs({ tags: { ...tags, [key]: value } });
}}
onDelete={(key) => {
const newTags = { ...tags };
delete newTags[key];
updateArgs({ tags: newTags });
}}
/>
);
},
};

export default meta;
type Story = StoryObj<typeof ProvisionerTagsPopover>;

export const Example: Story = {};
Loading

[8]ページ先頭

©2009-2025 Movatter.jp