8000 chore: bump the react group across 2 directories with 2 updates by dependabot[bot] · Pull Request #14895 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: bump the react group across 2 directories with 2 updates #14895

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix types
  • Loading branch information
BrunoQuaresma committed Oct 1, 2024
commit 8e3d987c9fcad1733ae17b4560ef1bbafb678ca5
30 changes: 20 additions & 10 deletions site/src/modules/resources/ResourceCard.tsx
8000
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CopyableValue } from "components/CopyableValue/CopyableValue";
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
import { Stack } from "components/Stack/Stack";
import { Children, type FC, type PropsWithChildren, useState } from "react";
import { Children, type FC, useState } from "react";
import { ResourceAvatar } from "./ResourceAvatar";
import { SensitiveValue } from "./SensitiveValue";

Expand Down Expand Up @@ -75,14 +75,6 @@ export interface ResourceCardProps {
agentRow: (agent: WorkspaceAgent) => JSX.Element;
}

const p: FC<PropsWithChildren> = ({ children }) => {
const childrens = Children.toArray(children);
if (childrens.every((child) => typeof child === "string")) {
return <CopyableValue value={childrens.join("")}>{children}</CopyableValue>;
}
return <>{children}</>;
};

export const ResourceCard: FC<ResourceCardProps> = ({ resource, agentRow }) => {
const [shouldDisplayAllMetadata, setShouldDisplayAllMetadata] =
useState(false);
Expand Down Expand Up @@ -146,7 +138,25 @@ export const ResourceCard: FC<ResourceCardProps> = ({ resource, agentRow }) => {
{meta.sensitive ? (
<SensitiveValue value={meta.value} />
) : (
<MemoizedInlineMarkdown components={{ p }}>
<MemoizedInlineMarkdown
components={{
p: ({ children }) => {
const childrens = Children.toArray(children);
if (
childrens.every(
(child) => typeof child === "string",
)
) {
return (
<CopyableValue value={childrens.join("")}>
{children}
</CopyableValue>
);
}
return <>{children}</>;
},
}}
>
{meta.value}
</MemoizedInlineMarkdown>
)}
Expand Down
37 changes: 20 additions & 17 deletions site/src/pages/WorkspacePage/ResourceMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import type { WorkspaceResource } from "api/typesGenerated";
import { CopyableValue } from "components/CopyableValue/CopyableValue";
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
import { SensitiveValue } from "modules/resources/SensitiveValue";
import {
Children,
type FC,
type HTMLAttributes,
type PropsWithChildren,
} from "react";
import { Children, type FC, type HTMLAttributes } from "react";

type ResourceMetadataProps = Omit<HTMLAttributes<HTMLElement>, "resource"> & {
resource: WorkspaceResource;
Expand Down Expand Up @@ -41,7 +36,25 @@ export const ResourceMetadata: FC<ResourceMetadataProps> = ({
{meta.sensitive ? (
<SensitiveValue value={meta.value} />
) : (
<MemoizedInlineMarkdown components={{ p: MetaValue }}>
<MemoizedInlineMarkdown
components={{
p: ({ children }) => {
const childrenArray = Children.toArray(children);
if (
childrenArray.every(
(child) => typeof child === "string",
)
) {
return (
<CopyableValue value={childrenArray.join("")}>
{children}
</CopyableValue>
);
}
return <>{children}</>;
},
}}
>
{meta.value}
</MemoizedInlineMarkdown>
)}
Expand All @@ -54,16 +67,6 @@ export const ResourceMetadata: FC<ResourceMetadataProps> = ({
);
};

const MetaValue: FC<PropsWithChildren> = ({ children }) => {
const childrenArray = Children.toArray(children);
if (childrenArray.every((child) => typeof child === "string")) {
return (
<CopyableValue value={childrenArray.join("")}>{children}</CopyableValue>
);
}
return <>{children}</>;
};

const styles = {
root: (theme) => ({
padding: 24,
Expand Down
Loading
0