Remove criticity on assets

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-13 22:06:49 +02:00
parent 344b340d1a
commit f808a90bba
22 changed files with 71 additions and 409 deletions

View File

@@ -26,13 +26,12 @@ import { PeopleSelectField } from "/components/form/PeopleSelectField";
import { VendorsMultiSelectField } from "/components/form/VendorsMultiSelectField";
import { useFormWithSchema } from "/hooks/useFormWithSchema";
import z from "zod";
import { getAssetTypeVariant, getCriticityVariant, validateSnapshotConsistency } from "@probo/helpers";
import { getAssetTypeVariant, validateSnapshotConsistency } from "@probo/helpers";
import { SnapshotBanner } from "/components/SnapshotBanner";
const updateAssetSchema = z.object({
name: z.string().min(1, "Name is required"),
amount: z.number().min(1, "Amount is required"),
criticity: z.enum(["LOW", "MEDIUM", "HIGH"]),
assetType: z.enum(["PHYSICAL", "VIRTUAL"]),
dataTypesStored: z.string().min(1, "Data types stored is required"),
ownerId: z.string().min(1, "Owner is required"),
@@ -71,7 +70,6 @@ export default function AssetDetailsPage(props: Props) {
defaultValues: {
name: assetEntry?.name || "",
amount: assetEntry?.amount || 0,
criticity: assetEntry?.criticity || "LOW",
assetType: assetEntry?.assetType || "VIRTUAL",
dataTypesStored: assetEntry?.dataTypesStored || "",
ownerId: assetEntry?.owner?.id || "",
@@ -118,9 +116,6 @@ export default function AssetDetailsPage(props: Props) {
<Badge variant={getAssetTypeVariant(assetEntry?.assetType)}>
{assetEntry?.assetType === "PHYSICAL" ? __("Physical") : __("Virtual")}
</Badge>
<Badge variant={getCriticityVariant(assetEntry?.criticity)}>
{assetEntry?.criticity}
</Badge>
</div>
{!isSnapshotMode && (
<ActionDropdown variant="secondary">
@@ -150,18 +145,6 @@ export default function AssetDetailsPage(props: Props) {
disabled={isSnapshotMode}
/>
<ControlledField
control={control}
name="criticity"
type="select"
label={__("Criticity")}
disabled={isSnapshotMode}
>
<Option value="LOW">{__("Low")}</Option>
<Option value="MEDIUM">{__("Medium")}</Option>
<Option value="HIGH">{__("High")}</Option>
</ControlledField>
<ControlledField
control={control}
name="assetType"

View File

@@ -28,7 +28,7 @@ import { useDeleteAsset, assetsQuery } from "../../../hooks/graph/AssetGraph";
import type { AssetGraphListQuery } from "/hooks/graph/__generated__/AssetGraphListQuery.graphql";
import { faviconUrl } from "@probo/helpers";
import type { NodeOf } from "/types";
import { getAssetTypeVariant, getCriticityVariant } from "@probo/helpers";
import { getAssetTypeVariant } from "@probo/helpers";
import type {
AssetsPageFragment$data,
AssetsPageFragment$key,
@@ -62,7 +62,6 @@ const paginatedAssetsFragment = graphql`
snapshotId
name
amount
criticity
assetType
dataTypesStored
owner {
@@ -130,7 +129,6 @@ export default function AssetsPage(props: Props) {
<Tr>
<Th>{__("Name")}</Th>
<Th>{__("Type")}</Th>
<Th>{__("Criticity")}</Th>
<Th>{__("Amount")}</Th>
<Th>{__("Owner")}</Th>
<Th>{__("Vendors")}</Th>
@@ -177,11 +175,6 @@ function AssetRow({
{entry.assetType === "PHYSICAL" ? __("Physical") : __("Virtual")}
</Badge>
</Td>
<Td>
<Badge variant={getCriticityVariant(entry.criticity)}>
{entry.criticity}
</Badge>
</Td>
<Td>{entry.amount}</Td>
<Td>{entry.owner?.fullName ?? __("Unassigned")}</Td>
<Td>

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<f2135bf85e1d0dffde8c1bcaa7940504>>
* @generated SignedSource<<794ba3ed2ccc75355a8c69c83d143587>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -10,7 +10,7 @@
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type AssetOrderField = "AMOUNT" | "CREATED_AT" | "CRITICITY";
export type AssetOrderField = "AMOUNT" | "CREATED_AT";
export type OrderDirection = "ASC" | "DESC";
export type AssetOrder = {
direction: OrderDirection;
@@ -252,13 +252,6 @@ return {
"name": "amount",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "criticity",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -436,16 +429,16 @@ return {
]
},
"params": {
"cacheID": "2eab5fe4d402f48ac4dcd8220284ea41",
"cacheID": "71aa6b89d4eba225262e326fdfe04cf7",
"id": null,
"metadata": {},
"name": "AssetsListQuery",
"operationKind": "query",
"text": "query AssetsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 10\n $last: Int = null\n $orderBy: AssetOrder = null\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...AssetsPageFragment_38J9tm\n id\n }\n}\n\nfragment AssetsPageFragment_38J9tm on Organization {\n assets(first: $first, after: $after, last: $last, before: $before, orderBy: $orderBy, filter: {snapshotId: $snapshotId}) {\n edges {\n node {\n id\n snapshotId\n name\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors(first: 50) {\n edges {\n node {\n id\n name\n websiteUrl\n }\n }\n }\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
"text": "query AssetsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 10\n $last: Int = null\n $orderBy: AssetOrder = null\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...AssetsPageFragment_38J9tm\n id\n }\n}\n\nfragment AssetsPageFragment_38J9tm on Organization {\n assets(first: $first, after: $after, last: $last, before: $before, orderBy: $orderBy, filter: {snapshotId: $snapshotId}) {\n edges {\n node {\n id\n snapshotId\n name\n amount\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors(first: 50) {\n edges {\n node {\n id\n name\n websiteUrl\n }\n }\n }\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
}
};
})();
(node as any).hash = "4bc1af55d208f3c773c49b753a76aa5c";
(node as any).hash = "a230182c928f189b50fdc39950602ffd";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<663b14d82ccaeebe2dda8dc256fddfc5>>
* @generated SignedSource<<6f077a71ef62a9c059bee1b50d3a23ef>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -10,7 +10,6 @@
import { ReaderFragment } from 'relay-runtime';
export type AssetType = "PHYSICAL" | "VIRTUAL";
export type CriticityLevel = "HIGH" | "LOW" | "MEDIUM";
import { FragmentRefs } from "relay-runtime";
export type AssetsPageFragment$data = {
readonly assets: {
@@ -20,7 +19,6 @@ export type AssetsPageFragment$data = {
readonly amount: number;
readonly assetType: AssetType;
readonly createdAt: any;
readonly criticity: CriticityLevel;
readonly dataTypesStored: string;
readonly id: string;
readonly name: string;
@@ -188,13 +186,6 @@ return {
"name": "amount",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "criticity",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -364,6 +355,6 @@ return {
};
})();
(node as any).hash = "4bc1af55d208f3c773c49b753a76aa5c";
(node as any).hash = "a230182c928f189b50fdc39950602ffd";
export default node;

View File

@@ -19,7 +19,6 @@ import { useCreateAsset } from "/hooks/graph/AssetGraph";
const schema = z.object({
name: z.string().min(1, "Name is required"),
amount: z.number().min(1, "Amount is required"),
criticity: z.enum(["LOW", "MEDIUM", "HIGH"]),
assetType: z.enum(["PHYSICAL", "VIRTUAL"]),
ownerId: z.string().min(1, "Owner is required"),
vendorIds: z.array(z.string()).optional(),
@@ -43,7 +42,6 @@ export function CreateAssetDialog({
defaultValues: {
name: "",
amount: 0,
criticity: "LOW",
assetType: "VIRTUAL",
ownerId: "",
vendorIds: [],
@@ -79,16 +77,6 @@ export function CreateAssetDialog({
{...register("amount", { valueAsNumber: true })}
type="number"
/>
<ControlledField
control={control}
name="criticity"
type="select"
label={__("Criticity")}
>
<Option value="LOW">{__("Low")}</Option>
<Option value="MEDIUM">{__("Medium")}</Option>
<Option value="HIGH">{__("High")}</Option>
</ControlledField>
<ControlledField
control={control}
name="assetType"