Skip to content

Commit d1e6ab0

Browse files
authored
feat: Add resource ID to pages (#6584)
1 parent cbf8b93 commit d1e6ab0

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

.changeset/purple-bats-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
Add readonly resource ID to settings pages

packages/web/app/src/components/ui/input-copy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button';
44
import { Input } from '@/components/ui/input';
55
import { useClipboard } from '@/lib/hooks';
66

7-
export function InputCopy(props: { value: string }) {
7+
export function InputCopy(props: { value: string; className?: string }) {
88
const [isCopied, setIsCopied] = useState(false);
99
const copyToClipboard = useClipboard();
1010

@@ -31,7 +31,7 @@ export function InputCopy(props: { value: string }) {
3131
type="text"
3232
value={props.value}
3333
readOnly
34-
className="bg-secondary truncate text-white"
34+
className={`bg-secondary truncate text-white ${props.className}`}
3535
onFocus={ev => ev.target.select()}
3636
/>
3737
</div>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ReactElement } from 'react';
2+
import { InfoCircledIcon } from '@radix-ui/react-icons';
3+
import { InputCopy } from './input-copy';
4+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './tooltip';
5+
6+
/** Renders readonly properties for resources. Used on settings pages. */
7+
export function ResourceDetails(props: { id: string }): ReactElement {
8+
return (
9+
<div className="flex items-center">
10+
<div className="border-input text-muted-foreground h-10 whitespace-nowrap rounded-md rounded-r-none border-y border-l bg-gray-900 px-3 py-2 text-sm">
11+
Resource ID
12+
</div>
13+
<InputCopy value={props.id} className="rounded-l-none" />
14+
<TooltipProvider>
15+
<Tooltip>
16+
<TooltipTrigger>
17+
<InfoCircledIcon className="ml-2 size-4" />
18+
</TooltipTrigger>
19+
<TooltipContent className="max-w-sm text-pretty">
20+
This UUID can be used in API calls or CLI commands to Hive instead of passing the full
21+
resource path. I.e. "org/project/target".
22+
</TooltipContent>
23+
</Tooltip>
24+
</TooltipProvider>
25+
</div>
26+
);
27+
}

packages/web/app/src/pages/organization-settings.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Input } from '@/components/ui/input';
3030
import { Meta } from '@/components/ui/meta';
3131
import { NavLayout, PageLayout, PageLayoutContent } from '@/components/ui/page-content-layout';
3232
import { QueryError } from '@/components/ui/query-error';
33+
import { ResourceDetails } from '@/components/ui/resource-details';
3334
import { useToast } from '@/components/ui/use-toast';
3435
import { TransferOrganizationOwnershipModal } from '@/components/v2/modals';
3536
import { env } from '@/env/frontend';
@@ -263,6 +264,7 @@ const SettingsPageRenderer = (props: {
263264

264265
return (
265266
<div className="flex flex-col gap-y-4">
267+
<ResourceDetails id={organization.id} />
266268
{organization.viewerCanModifySlug && (
267269
<Form {...slugForm}>
268270
<form onSubmit={slugForm.handleSubmit(onSlugFormSubmit)}>

packages/web/app/src/pages/project-settings.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Input } from '@/components/ui/input';
3030
import { Meta } from '@/components/ui/meta';
3131
import { Subtitle, Title } from '@/components/ui/page';
3232
import { QueryError } from '@/components/ui/query-error';
33+
import { ResourceDetails } from '@/components/ui/resource-details';
3334
import { useToast } from '@/components/ui/use-toast';
3435
import { env } from '@/env/frontend';
3536
import { graphql, useFragment } from '@/gql';
@@ -319,6 +320,7 @@ const ProjectSettingsPage_OrganizationFragment = graphql(`
319320

320321
const ProjectSettingsPage_ProjectFragment = graphql(`
321322
fragment ProjectSettingsPage_ProjectFragment on Project {
323+
id
322324
slug
323325
type
324326
isProjectNameInGitHubCheckEnabled
@@ -399,6 +401,7 @@ function ProjectSettingsContent(props: { organizationSlug: string; projectSlug:
399401
<div className="flex flex-col gap-y-4">
400402
{project && organization ? (
401403
<>
404+
<ResourceDetails id={project.id} />
402405
<ProjectSettingsPage_SlugForm
403406
organizationSlug={props.organizationSlug}
404407
projectSlug={props.projectSlug}

packages/web/app/src/pages/target-settings.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
} from '@/components/ui/page-content-layout';
3636
import { QueryError } from '@/components/ui/query-error';
3737
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
38+
import { ResourceDetails } from '@/components/ui/resource-details';
3839
import { Spinner } from '@/components/ui/spinner';
3940
import { TimeAgo } from '@/components/ui/time-ago';
4041
import { useToast } from '@/components/ui/use-toast';
@@ -1169,6 +1170,14 @@ const TargetSettingsPageQuery = graphql(`
11691170
}
11701171
`);
11711172

1173+
function TargetInfo(props: { targetId: string }) {
1174+
return (
1175+
<div>
1176+
<ResourceDetails id={props.targetId} />
1177+
</div>
1178+
);
1179+
}
1180+
11721181
function TargetSettingsContent(props: {
11731182
organizationSlug: string;
11741183
projectSlug: string;
@@ -1313,6 +1322,7 @@ function TargetSettingsContent(props: {
13131322
<div className="space-y-12">
13141323
{resolvedPage.key === 'general' ? (
13151324
<>
1325+
<TargetInfo targetId={currentTarget.id} />
13161326
<TargetSlug
13171327
targetSlug={props.targetSlug}
13181328
projectSlug={props.projectSlug}

0 commit comments

Comments
 (0)