Move console to a relay multi project config

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-30 10:37:23 +01:00
committed by Bryan Frimin
parent c1df98cec1
commit 6b2864e160
572 changed files with 6400 additions and 4263 deletions

View File

@@ -1,6 +1,19 @@
import { getAssetTypeVariant, promisifyMutation, sprintf } from "@probo/helpers";
import {
getAssetTypeVariant,
promisifyMutation,
sprintf,
} from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import { ActionDropdown, Badge, DropdownItem, IconPencil, IconTrashCan, SelectCell, TextCell, useConfirm } from "@probo/ui";
import {
ActionDropdown,
Badge,
DropdownItem,
IconPencil,
IconTrashCan,
SelectCell,
TextCell,
useConfirm,
} from "@probo/ui";
import { useMutation } from "react-relay";
import type { usePaginationFragmentHookType } from "react-relay/relay-hooks/usePaginationFragment";
import { Link } from "react-router";
@@ -8,9 +21,16 @@ import { z } from "zod";
import { EditableTable } from "../table/EditableTable";
import { PeopleCell } from "../table/PeopleCell";
import { VendorsCell } from "../table/VendorsCell";
import { createAssetMutation, deleteAssetMutation, updateAssetMutation } from "/hooks/graph/AssetGraph";
import type { AssetGraphDeleteMutation } from "/hooks/graph/__generated__/AssetGraphDeleteMutation.graphql";
import type { AssetsPageFragment$data, AssetsPageFragment$key } from "/pages/organizations/assets/__generated__/AssetsPageFragment.graphql";
import {
createAssetMutation,
deleteAssetMutation,
updateAssetMutation,
} from "/hooks/graph/AssetGraph";
import type { AssetGraphDeleteMutation } from "/__generated__/core/AssetGraphDeleteMutation.graphql";
import type {
AssetsPageFragment$data,
AssetsPageFragment$key,
} from "/__generated__/core/AssetsPageFragment.graphql";
import type { OperationType } from "relay-runtime";
import { useOrganizationId } from "/hooks/useOrganizationId";
@@ -73,7 +93,7 @@ export function AssetsTable(props: Props) {
...defaultValue,
organizationId,
}}
action={({ item }) =>
action={({ item }) => (
<ActionDropdown>
<DropdownItem asChild>
<Link to={`/organizations/${organizationId}/assets/${item.id}`}>
@@ -89,7 +109,7 @@ export function AssetsTable(props: Props) {
{__("Delete")}
</DropdownItem>
</ActionDropdown>
}
)}
row={({ item }) => (
<>
<TextCell name="name" defaultValue={item?.name ?? ""} required />
@@ -105,9 +125,7 @@ export function AssetsTable(props: Props) {
/>
<TextCell
name="dataTypesStored"
defaultValue={
item?.dataTypesStored ?? defaultValue.dataTypesStored
}
defaultValue={item?.dataTypesStored ?? defaultValue.dataTypesStored}
required
/>
<TextCell
@@ -123,9 +141,7 @@ export function AssetsTable(props: Props) {
<VendorsCell
name="vendorIds"
organizationId={organizationId}
defaultValue={
item?.vendors?.edges?.map((edge) => edge.node) ?? []
}
defaultValue={item?.vendors?.edges?.map((edge) => edge.node) ?? []}
/>
</>
)}
@@ -162,4 +178,4 @@ const useDeleteAsset = (connectionId: string) => {
},
);
};
};
};

View File

@@ -2,7 +2,10 @@ import { Avatar, Badge, Tbody, Td, Th, Thead, Tr } from "@probo/ui";
import { SortableTable } from "../SortableTable";
import { useTranslate } from "@probo/i18n";
import type { usePaginationFragmentHookType } from "react-relay/relay-hooks/usePaginationFragment";
import type { AssetsPageFragment$data, AssetsPageFragment$key } from "/pages/organizations/assets/__generated__/AssetsPageFragment.graphql";
import type {
AssetsPageFragment$data,
AssetsPageFragment$key,
} from "/__generated__/core/AssetsPageFragment.graphql";
import type { OperationType } from "relay-runtime";
import type { NodeOf } from "/types";
import { useOrganizationId } from "/hooks/useOrganizationId";
@@ -26,32 +29,25 @@ export function ReadOnlyAssetsTable(props: Props) {
return (
<SortableTable {...pagination} pageSize={10}>
<Thead>
<Tr>
<Th>{__("Name")}</Th>
<Th>{__("Type")}</Th>
<Th>{__("Amount")}</Th>
<Th>{__("Owner")}</Th>
<Th>{__("Vendors")}</Th>
</Tr>
</Thead>
<Tbody>
{assets.map((entry) => (
<AssetRow
key={entry.id}
entry={entry}
/>
))}
</Tbody>
</SortableTable>
<Thead>
<Tr>
<Th>{__("Name")}</Th>
<Th>{__("Type")}</Th>
<Th>{__("Amount")}</Th>
<Th>{__("Owner")}</Th>
<Th>{__("Vendors")}</Th>
</Tr>
</Thead>
<Tbody>
{assets.map((entry) => (
<AssetRow key={entry.id} entry={entry} />
))}
</Tbody>
</SortableTable>
);
}
function AssetRow({
entry,
}: {
entry: AssetEntry;
}) {
function AssetRow({ entry }: { entry: AssetEntry }) {
const organizationId = useOrganizationId();
const { __ } = useTranslate();
const { snapshotId } = useParams<{ snapshotId?: string }>();
@@ -60,8 +56,9 @@ function AssetRow({
return (
<Tr
to={
snapshotId ?
`/organizations/${organizationId}/snapshots/${snapshotId}/assets/${entry.id}` : `/organizations/${organizationId}/assets/${entry.id}`
snapshotId
? `/organizations/${organizationId}/snapshots/${snapshotId}/assets/${entry.id}`
: `/organizations/${organizationId}/assets/${entry.id}`
}
>
<Td>{entry.name}</Td>
@@ -101,4 +98,4 @@ function AssetRow({
</Td>
</Tr>
);
}
}