@@ -25,7 +25,7 @@ import {
|
|||||||
SidebarMenuSubButton,
|
SidebarMenuSubButton,
|
||||||
SidebarMenuSubItem,
|
SidebarMenuSubItem,
|
||||||
} from "@/components/ui/sidebar";
|
} from "@/components/ui/sidebar";
|
||||||
import { BookOpen, FileText, Settings, ToyBrick, Users } from "lucide-react";
|
import { BookOpen, FileText, Settings, Users, Box } from "lucide-react";
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -180,6 +180,13 @@ function getNavItems(organizationId?: string): NavItem[] {
|
|||||||
: undefined,
|
: undefined,
|
||||||
icon: FileText,
|
icon: FileText,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Assets",
|
||||||
|
url: organizationId
|
||||||
|
? `/organizations/${organizationId}/assets`
|
||||||
|
: undefined,
|
||||||
|
icon: Box,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Settings",
|
title: "Settings",
|
||||||
url: organizationId
|
url: organizationId
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { OrganizationBreadcrumbOrganizationQuery } from "./__generated__/Organiz
|
|||||||
import { OrganizationBreadcrumbBreadcrumbMeasureViewQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbMeasureViewQuery.graphql";
|
import { OrganizationBreadcrumbBreadcrumbMeasureViewQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbMeasureViewQuery.graphql";
|
||||||
import { OrganizationBreadcrumbBreadcrumbControlQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbControlQuery.graphql";
|
import { OrganizationBreadcrumbBreadcrumbControlQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbControlQuery.graphql";
|
||||||
import { OrganizationBreadcrumbBreadcrumbRiskShowQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbRiskShowQuery.graphql";
|
import { OrganizationBreadcrumbBreadcrumbRiskShowQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbRiskShowQuery.graphql";
|
||||||
|
import { OrganizationBreadcrumbBreadcrumbAssetOverviewQuery } from "./__generated__/OrganizationBreadcrumbBreadcrumbAssetOverviewQuery.graphql";
|
||||||
import ErrorBoundary from "@/components/ErrorBoundary";
|
import ErrorBoundary from "@/components/ErrorBoundary";
|
||||||
|
|
||||||
const New = () => {
|
const New = () => {
|
||||||
@@ -451,6 +452,53 @@ function BreadcrumbRiskShow() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function BreadcrumbAssetList() {
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BreadcrumbSeparator />
|
||||||
|
<BreadcrumbItem>
|
||||||
|
<BreadcrumbNavLink to={`/organizations/${organizationId}/assets`}>
|
||||||
|
Assets
|
||||||
|
</BreadcrumbNavLink>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
<Outlet />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbAssetOverview() {
|
||||||
|
const { organizationId, assetId } = useParams();
|
||||||
|
const data = useLazyLoadQuery<OrganizationBreadcrumbBreadcrumbAssetOverviewQuery>(
|
||||||
|
graphql`
|
||||||
|
query OrganizationBreadcrumbBreadcrumbAssetOverviewQuery($assetId: ID!) {
|
||||||
|
asset: node(id: $assetId) {
|
||||||
|
id
|
||||||
|
... on Asset {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ assetId: assetId! },
|
||||||
|
{ fetchPolicy: "store-or-network" },
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BreadcrumbSeparator />
|
||||||
|
<BreadcrumbItem>
|
||||||
|
<BreadcrumbNavLink
|
||||||
|
to={`/organizations/${organizationId}/assets/${assetId}`}
|
||||||
|
>
|
||||||
|
{data.asset?.name}
|
||||||
|
</BreadcrumbNavLink>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
<Outlet />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function BreadCrumb() {
|
export function BreadCrumb() {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
@@ -544,6 +592,19 @@ export function BreadCrumb() {
|
|||||||
</Route>
|
</Route>
|
||||||
<Route path="new" element={<New />} />
|
<Route path="new" element={<New />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="assets" element={<BreadcrumbAssetList />}>
|
||||||
|
<Route path="new" element={<New />} />
|
||||||
|
<Route
|
||||||
|
path=":assetId"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<BreadcrumbAssetOverview />
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Route path="edit" element={<Edit />} />
|
||||||
|
</Route>
|
||||||
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
path="settings"
|
path="settings"
|
||||||
element={
|
element={
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import ShowRiskView from "./risks/ShowRiskView";
|
|||||||
import { ListVendorPage } from "./vendors/ListVendorPage";
|
import { ListVendorPage } from "./vendors/ListVendorPage";
|
||||||
import { VendorPage } from "./vendors/VendorPage";
|
import { VendorPage } from "./vendors/VendorPage";
|
||||||
import { ListTaskPage } from "./tasks/ListTaskPage";
|
import { ListTaskPage } from "./tasks/ListTaskPage";
|
||||||
|
import { AssetsListPage } from "./assets/AssetsListPage";
|
||||||
|
import { NewAssetPage } from "./assets/NewAssetPage";
|
||||||
|
import { AssetPage } from "./assets/AssetPage";
|
||||||
|
|
||||||
export function OrganizationsRoutes() {
|
export function OrganizationsRoutes() {
|
||||||
return (
|
return (
|
||||||
@@ -64,6 +67,9 @@ export function OrganizationsRoutes() {
|
|||||||
<Route path="risks/new" element={<NewRiskPage />} />
|
<Route path="risks/new" element={<NewRiskPage />} />
|
||||||
<Route path="risks/:riskId" element={<ShowRiskView />} />
|
<Route path="risks/:riskId" element={<ShowRiskView />} />
|
||||||
<Route path="risks/:riskId/edit" element={<EditRiskPage />} />
|
<Route path="risks/:riskId/edit" element={<EditRiskPage />} />
|
||||||
|
<Route path="assets" element={<AssetsListPage />} />
|
||||||
|
<Route path="assets/new" element={<NewAssetPage />} />
|
||||||
|
<Route path="assets/:assetId" element={<AssetPage />} />
|
||||||
<Route path="settings" element={<SettingsPage />} />
|
<Route path="settings" element={<SettingsPage />} />
|
||||||
<Route path="*" element={<NotFoundPage />} />
|
<Route path="*" element={<NotFoundPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<7ee0fb485c12093374bdcbdf43d0a2df>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type OrganizationBreadcrumbBreadcrumbAssetOverviewQuery$variables = {
|
||||||
|
assetId: string;
|
||||||
|
};
|
||||||
|
export type OrganizationBreadcrumbBreadcrumbAssetOverviewQuery$data = {
|
||||||
|
readonly asset: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type OrganizationBreadcrumbBreadcrumbAssetOverviewQuery = {
|
||||||
|
response: OrganizationBreadcrumbBreadcrumbAssetOverviewQuery$data;
|
||||||
|
variables: OrganizationBreadcrumbBreadcrumbAssetOverviewQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "assetId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "assetId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Asset",
|
||||||
|
"abstractKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "OrganizationBreadcrumbBreadcrumbAssetOverviewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "asset",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "OrganizationBreadcrumbBreadcrumbAssetOverviewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "asset",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "41b1d32aad685d08edfdbf989207e758",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "OrganizationBreadcrumbBreadcrumbAssetOverviewQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query OrganizationBreadcrumbBreadcrumbAssetOverviewQuery(\n $assetId: ID!\n) {\n asset: node(id: $assetId) {\n __typename\n id\n ... on Asset {\n name\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "4c3d736cb93af42b7dcb88cdcb293e8f";
|
||||||
|
|
||||||
|
export default node;
|
||||||
40
apps/console/src/pages/organizations/assets/AssetPage.tsx
Normal file
40
apps/console/src/pages/organizations/assets/AssetPage.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { PageTemplateSkeleton } from "@/components/PageTemplate";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
import { lazy } from "@probo/react-lazy";
|
||||||
|
import { useLocation } from "react-router";
|
||||||
|
import { ErrorBoundaryWithLocation } from "../ErrorBoundary";
|
||||||
|
|
||||||
|
const AssetView = lazy(() => import("./AssetView"));
|
||||||
|
|
||||||
|
export function AssetViewSkeleton() {
|
||||||
|
return (
|
||||||
|
<PageTemplateSkeleton>
|
||||||
|
<div className="space-y-6">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="h-8 w-48 bg-subtle-bg animate-pulse rounded" />
|
||||||
|
<div className="h-4 w-96 bg-subtle-bg animate-pulse rounded" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{[1, 2].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="h-20 bg-subtle-bg animate-pulse rounded-lg"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageTemplateSkeleton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AssetPage() {
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense key={location.pathname} fallback={<AssetViewSkeleton />}>
|
||||||
|
<ErrorBoundaryWithLocation>
|
||||||
|
<AssetView />
|
||||||
|
</ErrorBoundaryWithLocation>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
445
apps/console/src/pages/organizations/assets/AssetView.tsx
Normal file
445
apps/console/src/pages/organizations/assets/AssetView.tsx
Normal file
@@ -0,0 +1,445 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Card } from "@/components/ui/card";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
import {
|
||||||
|
graphql,
|
||||||
|
PreloadedQuery,
|
||||||
|
usePreloadedQuery,
|
||||||
|
useQueryLoader,
|
||||||
|
useMutation,
|
||||||
|
} from "react-relay";
|
||||||
|
import { Suspense, useEffect, useState, useCallback } from "react";
|
||||||
|
import type { AssetViewQuery as AssetViewQueryType } from "./__generated__/AssetViewQuery.graphql";
|
||||||
|
import { useParams } from "react-router";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
import { AssetViewSkeleton } from "./AssetPage";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import PeopleSelector from "@/components/PeopleSelector";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { X } from "lucide-react";
|
||||||
|
|
||||||
|
const assetViewQuery = graphql`
|
||||||
|
query AssetViewQuery($assetId: ID!, $organizationId: ID!) {
|
||||||
|
node(id: $assetId) {
|
||||||
|
... on Asset {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
amount
|
||||||
|
criticity
|
||||||
|
assetType
|
||||||
|
dataTypesStored
|
||||||
|
owner {
|
||||||
|
id
|
||||||
|
fullName
|
||||||
|
}
|
||||||
|
vendors {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
organization: node(id: $organizationId) {
|
||||||
|
...PeopleSelector_organization
|
||||||
|
... on Organization {
|
||||||
|
vendors(first: 100, orderBy: { direction: ASC, field: NAME }) @connection(key: "AssetView_vendors") {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const updateAssetMutation = graphql`
|
||||||
|
mutation AssetViewUpdateAssetMutation($input: UpdateAssetInput!) {
|
||||||
|
updateAsset(input: $input) {
|
||||||
|
asset {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
amount
|
||||||
|
criticity
|
||||||
|
assetType
|
||||||
|
dataTypesStored
|
||||||
|
owner {
|
||||||
|
id
|
||||||
|
fullName
|
||||||
|
}
|
||||||
|
vendors {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
type AssetType = "PHYSICAL" | "VIRTUAL";
|
||||||
|
type CriticityLevel = "LOW" | "MEDIUM" | "HIGH";
|
||||||
|
|
||||||
|
interface Vendor {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Organization {
|
||||||
|
readonly id?: string;
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: Vendor;
|
||||||
|
} | null> | null;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Asset {
|
||||||
|
readonly id?: string;
|
||||||
|
readonly name?: string;
|
||||||
|
readonly amount?: number;
|
||||||
|
readonly criticity?: CriticityLevel;
|
||||||
|
readonly assetType?: AssetType;
|
||||||
|
readonly dataTypesStored?: string;
|
||||||
|
readonly owner?: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly fullName: string;
|
||||||
|
} | null;
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
} | null> | null;
|
||||||
|
} | null;
|
||||||
|
readonly createdAt?: string;
|
||||||
|
readonly updatedAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function EditableField({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
type = "text",
|
||||||
|
helpText,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
|
onChange: (value: string | number) => void;
|
||||||
|
type?: string;
|
||||||
|
helpText?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">{label}</Label>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Input
|
||||||
|
type={type}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(type === "number" ? parseInt(e.target.value, 10) || 0 : e.target.value)}
|
||||||
|
/>
|
||||||
|
{helpText && <p className="text-sm text-secondary">{helpText}</p>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AssetViewContent({
|
||||||
|
queryRef,
|
||||||
|
}: {
|
||||||
|
queryRef: PreloadedQuery<AssetViewQueryType>;
|
||||||
|
}) {
|
||||||
|
const data = usePreloadedQuery(assetViewQuery, queryRef);
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
const [editedFields, setEditedFields] = useState<Set<string>>(new Set());
|
||||||
|
const asset = data.node as Asset | null;
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: asset?.name || "",
|
||||||
|
amount: asset?.amount || 0,
|
||||||
|
criticity: asset?.criticity || "LOW",
|
||||||
|
assetType: asset?.assetType || "VIRTUAL",
|
||||||
|
dataTypesStored: asset?.dataTypesStored || "",
|
||||||
|
ownerId: asset?.owner?.id || "",
|
||||||
|
selectedVendorIds: (asset?.vendors?.edges || [])
|
||||||
|
.map(edge => edge?.node?.id)
|
||||||
|
.filter((id): id is string => id != null) || [],
|
||||||
|
});
|
||||||
|
const [commit] = useMutation(updateAssetMutation);
|
||||||
|
const [, loadQuery] = useQueryLoader<AssetViewQueryType>(assetViewQuery);
|
||||||
|
const { toast } = useToast();
|
||||||
|
const hasChanges = editedFields.size > 0;
|
||||||
|
|
||||||
|
const handleSave = useCallback(() => {
|
||||||
|
const nodeId = data.node?.id;
|
||||||
|
if (!nodeId) return;
|
||||||
|
|
||||||
|
commit({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
id: nodeId,
|
||||||
|
name: formData.name,
|
||||||
|
amount: formData.amount,
|
||||||
|
criticity: formData.criticity,
|
||||||
|
assetType: formData.assetType,
|
||||||
|
dataTypesStored: formData.dataTypesStored,
|
||||||
|
ownerId: formData.ownerId,
|
||||||
|
vendorIds: formData.selectedVendorIds.length > 0 ? formData.selectedVendorIds : undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onCompleted: () => {
|
||||||
|
toast({
|
||||||
|
title: "Success",
|
||||||
|
description: "Changes saved successfully",
|
||||||
|
variant: "default",
|
||||||
|
});
|
||||||
|
setEditedFields(new Set());
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
const defaultErrorValues = {
|
||||||
|
title: "Error",
|
||||||
|
description: error.message || "Failed to save changes",
|
||||||
|
variant: "destructive" as const
|
||||||
|
};
|
||||||
|
|
||||||
|
if (error.message?.includes("concurrent modification")) {
|
||||||
|
toast({
|
||||||
|
...defaultErrorValues,
|
||||||
|
description: "Someone else modified this asset. Reloading latest data.",
|
||||||
|
});
|
||||||
|
loadQuery({ assetId: nodeId, organizationId: organizationId! });
|
||||||
|
} else {
|
||||||
|
toast(defaultErrorValues);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [commit, data.node?.id, formData, loadQuery, toast, organizationId]);
|
||||||
|
|
||||||
|
const handleFieldChange = (field: keyof typeof formData, value: unknown) => {
|
||||||
|
setFormData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[field]: value,
|
||||||
|
}));
|
||||||
|
setEditedFields((prev) => new Set(prev).add(field));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVendorSelect = (vendorId: string) => {
|
||||||
|
handleFieldChange(
|
||||||
|
"selectedVendorIds",
|
||||||
|
formData.selectedVendorIds.includes(vendorId)
|
||||||
|
? formData.selectedVendorIds.filter((id) => id !== vendorId)
|
||||||
|
: [...formData.selectedVendorIds, vendorId]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
const asset = data.node as Asset | null;
|
||||||
|
setFormData({
|
||||||
|
name: asset?.name || "",
|
||||||
|
amount: asset?.amount || 0,
|
||||||
|
criticity: asset?.criticity || "LOW",
|
||||||
|
assetType: asset?.assetType || "VIRTUAL",
|
||||||
|
dataTypesStored: asset?.dataTypesStored || "",
|
||||||
|
ownerId: asset?.owner?.id || "",
|
||||||
|
selectedVendorIds: (asset?.vendors?.edges || [])
|
||||||
|
.map((edge) => edge?.node?.id)
|
||||||
|
.filter((id): id is string => id != null) || [],
|
||||||
|
});
|
||||||
|
setEditedFields(new Set());
|
||||||
|
};
|
||||||
|
|
||||||
|
const organization = data.organization as Organization;
|
||||||
|
const vendors = (organization.vendors?.edges || [])
|
||||||
|
.map((edge) => edge?.node)
|
||||||
|
.filter((node): node is Vendor => node != null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageTemplate title={formData.name || "Asset Details"}>
|
||||||
|
<div className="space-y-6">
|
||||||
|
<div className="max-w-4xl space-y-6">
|
||||||
|
<EditableField
|
||||||
|
label="Name"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={(value) => handleFieldChange("name", value)}
|
||||||
|
helpText="Enter the name of the asset"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<EditableField
|
||||||
|
label="Amount"
|
||||||
|
value={formData.amount}
|
||||||
|
type="number"
|
||||||
|
onChange={(value) => handleFieldChange("amount", value)}
|
||||||
|
helpText="Enter the amount of the asset"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Card className="p-6">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<h2 className="text-lg font-medium">Asset Details</h2>
|
||||||
|
<p className="text-sm text-secondary">
|
||||||
|
Additional details about the asset
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">Owner</Label>
|
||||||
|
</div>
|
||||||
|
<PeopleSelector
|
||||||
|
organizationRef={data.organization}
|
||||||
|
selectedPersonId={formData.ownerId}
|
||||||
|
onSelect={(value) => handleFieldChange("ownerId", value)}
|
||||||
|
placeholder="Select asset owner"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Vendors</Label>
|
||||||
|
<Select
|
||||||
|
value=""
|
||||||
|
onValueChange={handleVendorSelect}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select vendors" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{vendors.map((vendor) => (
|
||||||
|
<SelectItem key={vendor.id} value={vendor.id}>
|
||||||
|
{vendor.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<div className="flex flex-wrap gap-2 mt-2">
|
||||||
|
{formData.selectedVendorIds.map((vendorId) => {
|
||||||
|
const vendor = vendors.find((v) => v.id === vendorId);
|
||||||
|
if (!vendor) return null;
|
||||||
|
return (
|
||||||
|
<Badge key={vendorId} variant="secondary" className="flex items-center gap-1">
|
||||||
|
{vendor.name}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleVendorSelect(vendorId)}
|
||||||
|
className="hover:bg-secondary-hover rounded-full p-0.5"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">Criticity Level</Label>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
value={formData.criticity}
|
||||||
|
onValueChange={(value) => handleFieldChange("criticity", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full">
|
||||||
|
<SelectValue placeholder="Select criticity level" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="HIGH">High</SelectItem>
|
||||||
|
<SelectItem value="MEDIUM">Medium</SelectItem>
|
||||||
|
<SelectItem value="LOW">Low</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">Asset Type</Label>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
value={formData.assetType}
|
||||||
|
onValueChange={(value) => handleFieldChange("assetType", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full">
|
||||||
|
<SelectValue placeholder="Select asset type" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="PHYSICAL">Physical</SelectItem>
|
||||||
|
<SelectItem value="VIRTUAL">Virtual</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">Data Types Stored</Label>
|
||||||
|
</div>
|
||||||
|
<Textarea
|
||||||
|
value={formData.dataTypesStored}
|
||||||
|
onChange={(e) => handleFieldChange("dataTypesStored", e.target.value)}
|
||||||
|
placeholder="Enter the types of data stored in this asset..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<div className="mt-6 flex justify-end gap-2">
|
||||||
|
<Button variant="outline" onClick={handleCancel}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={handleSave}
|
||||||
|
className="bg-primary text-invert hover:bg-primary/90"
|
||||||
|
disabled={!hasChanges}
|
||||||
|
>
|
||||||
|
Save Changes
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageTemplate>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AssetView() {
|
||||||
|
const { assetId, organizationId } = useParams();
|
||||||
|
const [queryRef, loadQuery] =
|
||||||
|
useQueryLoader<AssetViewQueryType>(assetViewQuery);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadQuery({ assetId: assetId!, organizationId: organizationId! });
|
||||||
|
}, [loadQuery, assetId, organizationId]);
|
||||||
|
|
||||||
|
if (!queryRef) {
|
||||||
|
return <AssetViewSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<AssetViewSkeleton />}>
|
||||||
|
<AssetViewContent queryRef={queryRef} />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
import { useLocation } from "react-router";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
import { ErrorBoundaryWithLocation } from "../ErrorBoundary";
|
||||||
|
import { lazy } from "@probo/react-lazy";
|
||||||
|
|
||||||
|
|
||||||
|
const AssetsListView = lazy(() => import("./AssetsListView"));
|
||||||
|
|
||||||
|
export function AssetsListViewSkeleton() {
|
||||||
|
return (
|
||||||
|
<PageTemplate
|
||||||
|
title="Assets"
|
||||||
|
description="Keep track of your organization's assets and their criticality levels."
|
||||||
|
>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex items-center justify-between p-4 rounded-xl border bg-level-1"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Skeleton className="h-8 w-8 rounded-full" />
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Skeleton className="h-4 w-48" />
|
||||||
|
<Skeleton className="h-3 w-32" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Skeleton className="h-5 w-16" />
|
||||||
|
<Skeleton className="h-5 w-16" />
|
||||||
|
<Skeleton className="h-8 w-8" />
|
||||||
|
<Skeleton className="h-4 w-4" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</PageTemplate>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AssetsListPage() {
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense key={location.pathname} fallback={<AssetsListViewSkeleton />}>
|
||||||
|
<ErrorBoundaryWithLocation>
|
||||||
|
<AssetsListView />
|
||||||
|
</ErrorBoundaryWithLocation>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
367
apps/console/src/pages/organizations/assets/AssetsListView.tsx
Normal file
367
apps/console/src/pages/organizations/assets/AssetsListView.tsx
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
import { Suspense, useEffect, useTransition, useRef } from "react";
|
||||||
|
import {
|
||||||
|
graphql,
|
||||||
|
PreloadedQuery,
|
||||||
|
usePreloadedQuery,
|
||||||
|
useQueryLoader,
|
||||||
|
useMutation,
|
||||||
|
usePaginationFragment,
|
||||||
|
} from "react-relay";
|
||||||
|
import { useSearchParams, useParams } from "react-router";
|
||||||
|
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { Box, Plus, Trash2, ChevronRight } from "lucide-react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
import type { AssetsListViewQuery as AssetsListViewQueryType } from "./__generated__/AssetsListViewQuery.graphql";
|
||||||
|
import type { AssetsListViewDeleteAssetMutation } from "./__generated__/AssetsListViewDeleteAssetMutation.graphql";
|
||||||
|
import { AssetsListViewPaginationQuery } from "./__generated__/AssetsListViewPaginationQuery.graphql";
|
||||||
|
import { AssetsListView_assets$key } from "./__generated__/AssetsListView_assets.graphql";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
import { AssetsListViewSkeleton } from "./AssetsListViewSkeleton";
|
||||||
|
import { BreadCrumb } from "../OrganizationBreadcrumb";
|
||||||
|
|
||||||
|
const ITEMS_PER_PAGE = 25;
|
||||||
|
|
||||||
|
const assetsListViewQuery = graphql`
|
||||||
|
query AssetsListViewQuery(
|
||||||
|
$organizationId: ID!
|
||||||
|
$first: Int
|
||||||
|
$after: CursorKey
|
||||||
|
$last: Int
|
||||||
|
$before: CursorKey
|
||||||
|
) {
|
||||||
|
organization: node(id: $organizationId) {
|
||||||
|
...AssetsListView_assets
|
||||||
|
@arguments(first: $first, after: $after, last: $last, before: $before)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const assetsListFragment = graphql`
|
||||||
|
fragment AssetsListView_assets on Organization
|
||||||
|
@refetchable(queryName: "AssetsListViewPaginationQuery")
|
||||||
|
@argumentDefinitions(
|
||||||
|
first: { type: "Int" }
|
||||||
|
after: { type: "CursorKey" }
|
||||||
|
last: { type: "Int" }
|
||||||
|
before: { type: "CursorKey" }
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
assets(
|
||||||
|
first: $first
|
||||||
|
after: $after
|
||||||
|
last: $last
|
||||||
|
before: $before
|
||||||
|
orderBy: { direction: ASC, field: AMOUNT }
|
||||||
|
) @connection(key: "AssetsListView_assets") {
|
||||||
|
__id
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
amount
|
||||||
|
criticity
|
||||||
|
assetType
|
||||||
|
dataTypesStored
|
||||||
|
owner {
|
||||||
|
id
|
||||||
|
fullName
|
||||||
|
}
|
||||||
|
vendors {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageInfo {
|
||||||
|
hasNextPage
|
||||||
|
hasPreviousPage
|
||||||
|
startCursor
|
||||||
|
endCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const deleteAssetMutation = graphql`
|
||||||
|
mutation AssetsListViewDeleteAssetMutation(
|
||||||
|
$input: DeleteAssetInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
deleteAsset(input: $input) {
|
||||||
|
deletedAssetId @deleteEdge(connections: $connections)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
function LoadAboveButton({
|
||||||
|
isLoading,
|
||||||
|
hasMore,
|
||||||
|
onLoadMore,
|
||||||
|
}: {
|
||||||
|
isLoading: boolean;
|
||||||
|
hasMore: boolean;
|
||||||
|
onLoadMore: () => void;
|
||||||
|
}) {
|
||||||
|
if (!hasMore) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={onLoadMore}
|
||||||
|
disabled={isLoading}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
{isLoading ? "Loading..." : "Load above"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LoadBelowButton({
|
||||||
|
isLoading,
|
||||||
|
hasMore,
|
||||||
|
onLoadMore,
|
||||||
|
}: {
|
||||||
|
isLoading: boolean;
|
||||||
|
hasMore: boolean;
|
||||||
|
onLoadMore: () => void;
|
||||||
|
}) {
|
||||||
|
if (!hasMore) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={onLoadMore}
|
||||||
|
disabled={isLoading || !hasMore}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
{isLoading ? "Loading..." : "Load below"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AssetsListContent({
|
||||||
|
queryRef,
|
||||||
|
}: {
|
||||||
|
queryRef: PreloadedQuery<AssetsListViewQueryType>;
|
||||||
|
}) {
|
||||||
|
const data = usePreloadedQuery<AssetsListViewQueryType>(
|
||||||
|
assetsListViewQuery,
|
||||||
|
queryRef,
|
||||||
|
);
|
||||||
|
const [, setSearchParams] = useSearchParams();
|
||||||
|
const [, startTransition] = useTransition();
|
||||||
|
const [deleteAsset] =
|
||||||
|
useMutation<AssetsListViewDeleteAssetMutation>(deleteAssetMutation);
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: assetsConnection,
|
||||||
|
loadNext,
|
||||||
|
loadPrevious,
|
||||||
|
hasNext,
|
||||||
|
hasPrevious,
|
||||||
|
isLoadingNext,
|
||||||
|
isLoadingPrevious,
|
||||||
|
} = usePaginationFragment<
|
||||||
|
AssetsListViewPaginationQuery,
|
||||||
|
AssetsListView_assets$key
|
||||||
|
>(assetsListFragment, data.organization);
|
||||||
|
|
||||||
|
const assets = assetsConnection.assets.edges.map((edge) => edge.node) ?? [];
|
||||||
|
const pageInfo = assetsConnection.assets.pageInfo;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageTemplate
|
||||||
|
title="Assets"
|
||||||
|
description="Keep track of your organization's assets and their criticality levels."
|
||||||
|
actions={
|
||||||
|
<Button asChild variant="secondary" className="gap-2">
|
||||||
|
<Link to={`/organizations/${organizationId}/assets/new`}>
|
||||||
|
<Plus className="h-4 w-4" />
|
||||||
|
Add an asset
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="space-y-6">
|
||||||
|
<div className="space-y-2">
|
||||||
|
{assets.map((asset) => (
|
||||||
|
<Link
|
||||||
|
key={asset?.id}
|
||||||
|
to={`/organizations/${organizationId}/assets/${asset?.id}`}
|
||||||
|
className="block"
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-between p-4 rounded-xl border bg-level-1 hover:bg-accent-bg/5 transition-colors">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Avatar className="h-8 w-8">
|
||||||
|
<AvatarFallback>
|
||||||
|
<Box className="h-4 w-4" />
|
||||||
|
</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<p className="font-medium">
|
||||||
|
{asset?.name} ({asset?.amount})
|
||||||
|
</p>
|
||||||
|
{asset?.owner?.fullName && (
|
||||||
|
<>
|
||||||
|
<span className="text-tertiary">•</span>
|
||||||
|
<p className="text-sm text-tertiary">
|
||||||
|
Owned by {asset.owner.fullName}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm text-tertiary">
|
||||||
|
Data types: {asset?.dataTypesStored}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm text-tertiary">
|
||||||
|
{asset?.vendors?.edges?.length > 0 && (
|
||||||
|
<>
|
||||||
|
<p className="text-sm text-tertiary">
|
||||||
|
Vendors: {asset.vendors.edges.map(edge => edge?.node?.name).join(", ")}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Badge className="px-3 py-0.5 text-xs font-medium">
|
||||||
|
{asset?.assetType === "PHYSICAL" ? "Physical" : "Virtual"}
|
||||||
|
</Badge>
|
||||||
|
<Badge
|
||||||
|
variant={
|
||||||
|
asset?.criticity === "HIGH"
|
||||||
|
? "destructive"
|
||||||
|
: asset?.criticity === "MEDIUM"
|
||||||
|
? "warning"
|
||||||
|
: asset?.criticity === "LOW"
|
||||||
|
? "success"
|
||||||
|
: "default"
|
||||||
|
}
|
||||||
|
className="px-3 py-0.5 text-xs font-medium"
|
||||||
|
>
|
||||||
|
{asset?.criticity}
|
||||||
|
</Badge>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-8 w-8 text-tertiary hover:bg-transparent hover:[&>svg]:text-danger"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (
|
||||||
|
window.confirm(
|
||||||
|
"Are you sure you want to delete this asset?",
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
deleteAsset({
|
||||||
|
variables: {
|
||||||
|
connections: [assetsConnection.assets.__id],
|
||||||
|
input: {
|
||||||
|
assetId: asset.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 className="h-4 w-4 transition-colors" />
|
||||||
|
</Button>
|
||||||
|
<ChevronRight className="h-4 w-4 text-tertiary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<LoadAboveButton
|
||||||
|
isLoading={isLoadingPrevious}
|
||||||
|
hasMore={hasPrevious}
|
||||||
|
onLoadMore={() => {
|
||||||
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
|
setSearchParams((prev) => {
|
||||||
|
prev.set("before", pageInfo?.startCursor || "");
|
||||||
|
prev.delete("after");
|
||||||
|
return prev;
|
||||||
|
});
|
||||||
|
loadPrevious(ITEMS_PER_PAGE);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<LoadBelowButton
|
||||||
|
isLoading={isLoadingNext}
|
||||||
|
hasMore={hasNext}
|
||||||
|
onLoadMore={() => {
|
||||||
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
|
setSearchParams((prev) => {
|
||||||
|
prev.set("after", pageInfo?.endCursor || "");
|
||||||
|
prev.delete("before");
|
||||||
|
return prev;
|
||||||
|
});
|
||||||
|
loadNext(ITEMS_PER_PAGE);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</PageTemplate>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AssetsListView() {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const [queryRef, loadQuery] =
|
||||||
|
useQueryLoader<AssetsListViewQueryType>(assetsListViewQuery);
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const after = searchParams.get("after");
|
||||||
|
const before = searchParams.get("before");
|
||||||
|
|
||||||
|
// Skip the query if this was triggered by pagination
|
||||||
|
if (isPaginationUpdate.current) {
|
||||||
|
isPaginationUpdate.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadQuery({
|
||||||
|
organizationId: organizationId!,
|
||||||
|
first: before ? undefined : ITEMS_PER_PAGE,
|
||||||
|
after: after || undefined,
|
||||||
|
last: before ? ITEMS_PER_PAGE : undefined,
|
||||||
|
before: before || undefined,
|
||||||
|
});
|
||||||
|
}, [loadQuery, organizationId, searchParams]);
|
||||||
|
|
||||||
|
if (!queryRef) {
|
||||||
|
return <AssetsListViewSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<AssetsListViewSkeleton />}>
|
||||||
|
<AssetsListContent queryRef={queryRef} />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
|
||||||
|
export function AssetsListViewSkeleton() {
|
||||||
|
return (
|
||||||
|
<PageTemplate
|
||||||
|
title="Assets"
|
||||||
|
description="Keep track of your organization's assets and their criticality levels."
|
||||||
|
>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex items-center justify-between p-4 rounded-xl border bg-level-1"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Skeleton className="h-8 w-8 rounded-full" />
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Skeleton className="h-4 w-48" />
|
||||||
|
<Skeleton className="h-3 w-32" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Skeleton className="h-5 w-16" />
|
||||||
|
<Skeleton className="h-5 w-16" />
|
||||||
|
<Skeleton className="h-8 w-8" />
|
||||||
|
<Skeleton className="h-4 w-4" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</PageTemplate>
|
||||||
|
);
|
||||||
|
}
|
||||||
42
apps/console/src/pages/organizations/assets/NewAssetPage.tsx
Normal file
42
apps/console/src/pages/organizations/assets/NewAssetPage.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { Suspense } from "react";
|
||||||
|
import { ErrorBoundaryWithLocation } from "../ErrorBoundary";
|
||||||
|
import { lazy } from "@probo/react-lazy";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
|
const NewAssetView = lazy(() => import("./NewAssetView"));
|
||||||
|
|
||||||
|
export function NewAssetViewSkeleton() {
|
||||||
|
return (
|
||||||
|
<PageTemplate
|
||||||
|
title="New Asset"
|
||||||
|
description="Add a new asset to your organization."
|
||||||
|
>
|
||||||
|
<div className="space-y-6 max-w-2xl">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-64" />
|
||||||
|
<Skeleton className="h-20 w-full" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-10 w-32" />
|
||||||
|
</div>
|
||||||
|
</PageTemplate>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NewAssetPage() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<NewAssetViewSkeleton />}>
|
||||||
|
<ErrorBoundaryWithLocation>
|
||||||
|
<NewAssetView />
|
||||||
|
</ErrorBoundaryWithLocation>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
363
apps/console/src/pages/organizations/assets/NewAssetView.tsx
Normal file
363
apps/console/src/pages/organizations/assets/NewAssetView.tsx
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
import { useState, Suspense, useEffect } from "react";
|
||||||
|
import { useNavigate, useParams } from "react-router";
|
||||||
|
import { graphql, useMutation, ConnectionHandler, useQueryLoader, PreloadedQuery, usePreloadedQuery } from "react-relay";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
|
import { NewAssetViewCreateAssetMutation } from "./__generated__/NewAssetViewCreateAssetMutation.graphql";
|
||||||
|
import { NewAssetViewQuery } from "./__generated__/NewAssetViewQuery.graphql";
|
||||||
|
import PeopleSelector from "@/components/PeopleSelector";
|
||||||
|
import { NewAssetViewSkeleton } from "./NewAssetPage";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { X } from "lucide-react";
|
||||||
|
|
||||||
|
const newAssetViewQuery = graphql`
|
||||||
|
query NewAssetViewQuery($organizationId: ID!) {
|
||||||
|
organization: node(id: $organizationId) {
|
||||||
|
... on Organization {
|
||||||
|
id
|
||||||
|
...PeopleSelector_organization
|
||||||
|
vendors(first: 100, orderBy: { direction: ASC, field: NAME }) @connection(key: "NewAssetView_vendors") {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const createAssetMutation = graphql`
|
||||||
|
mutation NewAssetViewCreateAssetMutation(
|
||||||
|
$input: CreateAssetInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
createAsset(input: $input) {
|
||||||
|
assetEdge @prependEdge(connections: $connections) {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
amount
|
||||||
|
criticity
|
||||||
|
assetType
|
||||||
|
dataTypesStored
|
||||||
|
owner {
|
||||||
|
id
|
||||||
|
fullName
|
||||||
|
}
|
||||||
|
vendors {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface Vendor {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Organization {
|
||||||
|
readonly id?: string;
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: Vendor;
|
||||||
|
} | null> | null;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function EditableField({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
type = "text",
|
||||||
|
helpText,
|
||||||
|
required,
|
||||||
|
min,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
type?: string;
|
||||||
|
helpText?: string;
|
||||||
|
required?: boolean;
|
||||||
|
min?: number;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Label className="text-sm">{label}</Label>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Input
|
||||||
|
type={type}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
required={required}
|
||||||
|
min={min}
|
||||||
|
/>
|
||||||
|
{helpText && <p className="text-sm text-secondary">{helpText}</p>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function NewAssetViewContent({
|
||||||
|
queryRef,
|
||||||
|
}: {
|
||||||
|
queryRef: PreloadedQuery<NewAssetViewQuery>;
|
||||||
|
}) {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
const [createAsset] = useMutation<NewAssetViewCreateAssetMutation>(createAssetMutation);
|
||||||
|
const { toast } = useToast();
|
||||||
|
const data = usePreloadedQuery(newAssetViewQuery, queryRef);
|
||||||
|
|
||||||
|
if (!data.organization) {
|
||||||
|
return <div>Organization not found</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const organization = data.organization as Organization;
|
||||||
|
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: "",
|
||||||
|
amount: 1,
|
||||||
|
criticity: "MEDIUM" as "LOW" | "MEDIUM" | "HIGH",
|
||||||
|
assetType: "VIRTUAL" as "PHYSICAL" | "VIRTUAL",
|
||||||
|
dataTypesStored: "",
|
||||||
|
ownerId: "",
|
||||||
|
selectedVendorIds: [] as string[],
|
||||||
|
});
|
||||||
|
|
||||||
|
type FormData = typeof formData;
|
||||||
|
|
||||||
|
const handleFieldChange = <K extends keyof FormData>(
|
||||||
|
field: K,
|
||||||
|
value: FormData[K]
|
||||||
|
) => {
|
||||||
|
setFormData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[field]: value,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVendorSelect = (vendorId: string) => {
|
||||||
|
setFormData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
selectedVendorIds: prev.selectedVendorIds.includes(vendorId)
|
||||||
|
? prev.selectedVendorIds.filter((id) => id !== vendorId)
|
||||||
|
: [...prev.selectedVendorIds, vendorId],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!formData.ownerId) {
|
||||||
|
toast({
|
||||||
|
title: "Error",
|
||||||
|
description: "Please select an owner",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createAsset({
|
||||||
|
variables: {
|
||||||
|
connections: [
|
||||||
|
ConnectionHandler.getConnectionID(
|
||||||
|
organizationId!,
|
||||||
|
"AssetsListView_assets",
|
||||||
|
{
|
||||||
|
orderBy: {
|
||||||
|
direction: "ASC",
|
||||||
|
field: "AMOUNT",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
input: {
|
||||||
|
organizationId: organizationId!,
|
||||||
|
name: formData.name,
|
||||||
|
amount: Number(formData.amount),
|
||||||
|
criticity: formData.criticity,
|
||||||
|
assetType: formData.assetType,
|
||||||
|
dataTypesStored: formData.dataTypesStored,
|
||||||
|
ownerId: formData.ownerId,
|
||||||
|
vendorIds: formData.selectedVendorIds.length > 0 ? formData.selectedVendorIds : undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onCompleted: () => {
|
||||||
|
toast({
|
||||||
|
title: "Success",
|
||||||
|
description: "Asset created successfully",
|
||||||
|
variant: "default",
|
||||||
|
});
|
||||||
|
navigate(`/organizations/${organizationId}/assets`);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast({
|
||||||
|
title: "Error",
|
||||||
|
description: error.message || "Failed to create asset",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const vendors = (organization.vendors?.edges || [])
|
||||||
|
.map((edge) => edge?.node)
|
||||||
|
.filter((node): node is Vendor => node != null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageTemplate
|
||||||
|
title="Create Asset"
|
||||||
|
description="Add a new asset to your organization"
|
||||||
|
>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className="max-w-2xl space-y-6">
|
||||||
|
<EditableField
|
||||||
|
label="Name"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={(value) => handleFieldChange("name", value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<EditableField
|
||||||
|
label="Amount"
|
||||||
|
value={formData.amount}
|
||||||
|
onChange={(value) => handleFieldChange("amount", Number(value))}
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Owner</Label>
|
||||||
|
<PeopleSelector
|
||||||
|
organizationRef={data.organization}
|
||||||
|
selectedPersonId={formData.ownerId}
|
||||||
|
onSelect={(value) => handleFieldChange("ownerId", value)}
|
||||||
|
placeholder="Select asset owner"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Vendors</Label>
|
||||||
|
<Select
|
||||||
|
value=""
|
||||||
|
onValueChange={handleVendorSelect}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select vendors" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{vendors.map((vendor) => (
|
||||||
|
<SelectItem key={vendor.id} value={vendor.id}>
|
||||||
|
{vendor.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<div className="flex flex-wrap gap-2 mt-2">
|
||||||
|
{formData.selectedVendorIds.map((vendorId) => {
|
||||||
|
const vendor = vendors.find((v) => v.id === vendorId);
|
||||||
|
if (!vendor) return null;
|
||||||
|
return (
|
||||||
|
<Badge key={vendorId} variant="secondary" className="flex items-center gap-1">
|
||||||
|
{vendor.name}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleVendorSelect(vendorId)}
|
||||||
|
className="hover:bg-secondary-hover rounded-full p-0.5"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Criticity Level</Label>
|
||||||
|
<Select
|
||||||
|
value={formData.criticity}
|
||||||
|
onValueChange={(value: string) =>
|
||||||
|
handleFieldChange("criticity", value as "LOW" | "MEDIUM" | "HIGH")}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select criticity level" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="LOW">Low</SelectItem>
|
||||||
|
<SelectItem value="MEDIUM">Medium</SelectItem>
|
||||||
|
<SelectItem value="HIGH">High</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Asset Type</Label>
|
||||||
|
<Select
|
||||||
|
value={formData.assetType}
|
||||||
|
onValueChange={(value: string) =>
|
||||||
|
handleFieldChange("assetType", value as "PHYSICAL" | "VIRTUAL")}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select asset type" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="PHYSICAL">Physical</SelectItem>
|
||||||
|
<SelectItem value="VIRTUAL">Virtual</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-sm">Data Types Stored</Label>
|
||||||
|
<Textarea
|
||||||
|
value={formData.dataTypesStored}
|
||||||
|
onChange={(e) => handleFieldChange("dataTypesStored", e.target.value)}
|
||||||
|
placeholder="Enter the types of data stored in this asset..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button type="submit">Create Asset</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</PageTemplate>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function NewAssetView() {
|
||||||
|
const { organizationId } = useParams();
|
||||||
|
const [queryRef, loadQuery] = useQueryLoader<NewAssetViewQuery>(newAssetViewQuery);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadQuery({ organizationId: organizationId! });
|
||||||
|
}, [loadQuery, organizationId]);
|
||||||
|
|
||||||
|
if (!queryRef) {
|
||||||
|
return <NewAssetViewSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<NewAssetViewSkeleton />}>
|
||||||
|
<NewAssetViewContent queryRef={queryRef} />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
525
apps/console/src/pages/organizations/assets/__generated__/AssetViewQuery.graphql.ts
generated
Normal file
525
apps/console/src/pages/organizations/assets/__generated__/AssetViewQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,525 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<d65c60ca11d871511fd92f55e8aa321d>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AssetType = "PHYSICAL" | "VIRTUAL";
|
||||||
|
export type CriticityLevel = "HIGH" | "LOW" | "MEDIUM";
|
||||||
|
export type AssetViewQuery$variables = {
|
||||||
|
assetId: string;
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
export type AssetViewQuery$data = {
|
||||||
|
readonly node: {
|
||||||
|
readonly amount?: number;
|
||||||
|
readonly assetType?: AssetType;
|
||||||
|
readonly createdAt?: string;
|
||||||
|
readonly criticity?: CriticityLevel;
|
||||||
|
readonly dataTypesStored?: string;
|
||||||
|
readonly id?: string;
|
||||||
|
readonly name?: string;
|
||||||
|
readonly owner?: {
|
||||||
|
readonly fullName: string;
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
readonly updatedAt?: string;
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly organization: {
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"PeopleSelector_organization">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AssetViewQuery = {
|
||||||
|
response: AssetViewQuery$data;
|
||||||
|
variables: AssetViewQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "assetId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "assetId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v5 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v6 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v7 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v8 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v9 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v8/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v10 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v11 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v12 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v13 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v14 = {
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "NAME"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
v15 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v16 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v17 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v18 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v15/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v16/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v17/*: any*/)
|
||||||
|
],
|
||||||
|
v19 = {
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "first",
|
||||||
|
"value": 100
|
||||||
|
},
|
||||||
|
v20 = [
|
||||||
|
(v19/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "FULL_NAME"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v21 = [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
v22 = [
|
||||||
|
(v19/*: any*/),
|
||||||
|
(v14/*: any*/)
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AssetViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v5/*: any*/),
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v9/*: any*/),
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v12/*: any*/)
|
||||||
|
],
|
||||||
|
"type": "Asset",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v13/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": null,
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "PeopleSelector_organization"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "vendors",
|
||||||
|
"args": [
|
||||||
|
(v14/*: any*/)
|
||||||
|
],
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "__AssetView_vendors_connection",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v18/*: any*/),
|
||||||
|
"storageKey": "__AssetView_vendors_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"NAME\"})"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AssetViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v15/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v5/*: any*/),
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v9/*: any*/),
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v12/*: any*/)
|
||||||
|
],
|
||||||
|
"type": "Asset",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v13/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v15/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v20/*: any*/),
|
||||||
|
"concreteType": "PeopleConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "peoples",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PeopleEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "primaryEmailAddress",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v15/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v16/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v17/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": "peoples(first:100,orderBy:{\"direction\":\"ASC\",\"field\":\"FULL_NAME\"})"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v20/*: any*/),
|
||||||
|
"filters": (v21/*: any*/),
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "PeopleSelector_organization_peoples",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "peoples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v22/*: any*/),
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v18/*: any*/),
|
||||||
|
"storageKey": "vendors(first:100,orderBy:{\"direction\":\"ASC\",\"field\":\"NAME\"})"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v22/*: any*/),
|
||||||
|
"filters": (v21/*: any*/),
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "AssetView_vendors",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "vendors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "90ae7758672dc097178bd9ab462b91fa",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"count": null,
|
||||||
|
"cursor": null,
|
||||||
|
"direction": "forward",
|
||||||
|
"path": [
|
||||||
|
"organization",
|
||||||
|
"vendors"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": "AssetViewQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AssetViewQuery(\n $assetId: ID!\n $organizationId: ID!\n) {\n node(id: $assetId) {\n __typename\n ... on Asset {\n id\n name\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n createdAt\n updatedAt\n }\n id\n }\n organization: node(id: $organizationId) {\n __typename\n ...PeopleSelector_organization\n ... on Organization {\n vendors(first: 100, orderBy: {direction: ASC, field: NAME}) {\n edges {\n node {\n id\n name\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100, orderBy: {direction: ASC, field: FULL_NAME}) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "e2b32fe12d61063010d5a3b0a818331b";
|
||||||
|
|
||||||
|
export default node;
|
||||||
230
apps/console/src/pages/organizations/assets/__generated__/AssetViewUpdateAssetMutation.graphql.ts
generated
Normal file
230
apps/console/src/pages/organizations/assets/__generated__/AssetViewUpdateAssetMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<78e1b25933acfc51a857df68fe5a595c>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AssetType = "PHYSICAL" | "VIRTUAL";
|
||||||
|
export type CriticityLevel = "HIGH" | "LOW" | "MEDIUM";
|
||||||
|
export type UpdateAssetInput = {
|
||||||
|
amount?: number | null | undefined;
|
||||||
|
assetType?: AssetType | null | undefined;
|
||||||
|
criticity?: CriticityLevel | null | undefined;
|
||||||
|
dataTypesStored?: string | null | undefined;
|
||||||
|
id: string;
|
||||||
|
name?: string | null | undefined;
|
||||||
|
ownerId?: string | null | undefined;
|
||||||
|
vendorIds?: ReadonlyArray<string> | null | undefined;
|
||||||
|
};
|
||||||
|
export type AssetViewUpdateAssetMutation$variables = {
|
||||||
|
input: UpdateAssetInput;
|
||||||
|
};
|
||||||
|
export type AssetViewUpdateAssetMutation$data = {
|
||||||
|
readonly updateAsset: {
|
||||||
|
readonly asset: {
|
||||||
|
readonly amount: number;
|
||||||
|
readonly assetType: AssetType;
|
||||||
|
readonly criticity: CriticityLevel;
|
||||||
|
readonly dataTypesStored: string;
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly owner: {
|
||||||
|
readonly fullName: string;
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
readonly updatedAt: string;
|
||||||
|
readonly vendors: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AssetViewUpdateAssetMutation = {
|
||||||
|
response: AssetViewUpdateAssetMutation$data;
|
||||||
|
variables: AssetViewUpdateAssetMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "UpdateAssetPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "updateAsset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "asset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AssetViewUpdateAssetMutation",
|
||||||
|
"selections": (v3/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AssetViewUpdateAssetMutation",
|
||||||
|
"selections": (v3/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "7a2a8504da4e44785e141f7118760c26",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AssetViewUpdateAssetMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AssetViewUpdateAssetMutation(\n $input: UpdateAssetInput!\n) {\n updateAsset(input: $input) {\n asset {\n id\n name\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n updatedAt\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "c57436cc8a742b3b48987bc702a2fa0e";
|
||||||
|
|
||||||
|
export default node;
|
||||||
132
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewDeleteAssetMutation.graphql.ts
generated
Normal file
132
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewDeleteAssetMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<e56af42bed63f99011e9565c0364ea0c>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type DeleteAssetInput = {
|
||||||
|
assetId: string;
|
||||||
|
};
|
||||||
|
export type AssetsListViewDeleteAssetMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
|
input: DeleteAssetInput;
|
||||||
|
};
|
||||||
|
export type AssetsListViewDeleteAssetMutation$data = {
|
||||||
|
readonly deleteAsset: {
|
||||||
|
readonly deletedAssetId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AssetsListViewDeleteAssetMutation = {
|
||||||
|
response: AssetsListViewDeleteAssetMutation$data;
|
||||||
|
variables: AssetsListViewDeleteAssetMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "connections"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "deletedAssetId",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AssetsListViewDeleteAssetMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteAssetPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteAsset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AssetsListViewDeleteAssetMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteAssetPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteAsset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "deleteEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "ScalarHandle",
|
||||||
|
"name": "deletedAssetId",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "d7987550f982b36de3911f3e7c8e9677",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AssetsListViewDeleteAssetMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AssetsListViewDeleteAssetMutation(\n $input: DeleteAssetInput!\n) {\n deleteAsset(input: $input) {\n deletedAssetId\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "3f576871aa0d4495afcca5ecaf1aefca";
|
||||||
|
|
||||||
|
export default node;
|
||||||
404
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewPaginationQuery.graphql.ts
generated
Normal file
404
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewPaginationQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,404 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<80b2431e63ecff11f93733ef7b235bb8>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AssetsListViewPaginationQuery$variables = {
|
||||||
|
after?: string | null | undefined;
|
||||||
|
before?: string | null | undefined;
|
||||||
|
first?: number | null | undefined;
|
||||||
|
id: string;
|
||||||
|
last?: number | null | undefined;
|
||||||
|
};
|
||||||
|
export type AssetsListViewPaginationQuery$data = {
|
||||||
|
readonly node: {
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AssetsListView_assets">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AssetsListViewPaginationQuery = {
|
||||||
|
response: AssetsListViewPaginationQuery$data;
|
||||||
|
variables: AssetsListViewPaginationQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "after"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "before"
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "first"
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "id"
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "last"
|
||||||
|
},
|
||||||
|
v5 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "id"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v6 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "after",
|
||||||
|
"variableName": "after"
|
||||||
|
},
|
||||||
|
v7 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "before",
|
||||||
|
"variableName": "before"
|
||||||
|
},
|
||||||
|
v8 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "first",
|
||||||
|
"variableName": "first"
|
||||||
|
},
|
||||||
|
v9 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "last",
|
||||||
|
"variableName": "last"
|
||||||
|
},
|
||||||
|
v10 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v11 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v12 = [
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "AMOUNT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v13 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AssetsListViewPaginationQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v5/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v9/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "AssetsListView_assets"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AssetsListViewPaginationQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v5/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v12/*: any*/),
|
||||||
|
"concreteType": "AssetConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "assets",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AssetEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v13/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v13/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v10/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v12/*: any*/),
|
||||||
|
"filters": [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "AssetsListView_assets",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "assets"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "52c46484b71323276f81a31b48987698",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AssetsListViewPaginationQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AssetsListViewPaginationQuery(\n $after: CursorKey\n $before: CursorKey\n $first: Int\n $last: Int\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...AssetsListView_assets_pbnwq\n id\n }\n}\n\nfragment AssetsListView_assets_pbnwq on Organization {\n id\n assets(first: $first, after: $after, last: $last, before: $before, orderBy: {direction: ASC, field: AMOUNT}) {\n edges {\n node {\n id\n name\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "b7ef7bd1063b9a578b82124ebbdbbbd2";
|
||||||
|
|
||||||
|
export default node;
|
||||||
404
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewQuery.graphql.ts
generated
Normal file
404
apps/console/src/pages/organizations/assets/__generated__/AssetsListViewQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,404 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<e4043a80f688b96635dde8a9cff9f7e7>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AssetsListViewQuery$variables = {
|
||||||
|
after?: string | null | undefined;
|
||||||
|
before?: string | null | undefined;
|
||||||
|
first?: number | null | undefined;
|
||||||
|
last?: number | null | undefined;
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
export type AssetsListViewQuery$data = {
|
||||||
|
readonly organization: {
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AssetsListView_assets">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AssetsListViewQuery = {
|
||||||
|
response: AssetsListViewQuery$data;
|
||||||
|
variables: AssetsListViewQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "after"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "before"
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "first"
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "last"
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationId"
|
||||||
|
},
|
||||||
|
v5 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v6 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "after",
|
||||||
|
"variableName": "after"
|
||||||
|
},
|
||||||
|
v7 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "before",
|
||||||
|
"variableName": "before"
|
||||||
|
},
|
||||||
|
v8 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "first",
|
||||||
|
"variableName": "first"
|
||||||
|
},
|
||||||
|
v9 = {
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "last",
|
||||||
|
"variableName": "last"
|
||||||
|
},
|
||||||
|
v10 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v11 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v12 = [
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "AMOUNT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v13 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AssetsListViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v5/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v9/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "AssetsListView_assets"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AssetsListViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v5/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v12/*: any*/),
|
||||||
|
"concreteType": "AssetConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "assets",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AssetEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v13/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v13/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v10/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v12/*: any*/),
|
||||||
|
"filters": [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "AssetsListView_assets",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "assets"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "dd13d90d325e9f1eaa4d7be061c5a242",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AssetsListViewQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AssetsListViewQuery(\n $organizationId: ID!\n $first: Int\n $after: CursorKey\n $last: Int\n $before: CursorKey\n) {\n organization: node(id: $organizationId) {\n __typename\n ...AssetsListView_assets_pbnwq\n id\n }\n}\n\nfragment AssetsListView_assets_pbnwq on Organization {\n id\n assets(first: $first, after: $after, last: $last, before: $before, orderBy: {direction: ASC, field: AMOUNT}) {\n edges {\n node {\n id\n name\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "ce9a262aef17deeb6a9ca87b35014fb6";
|
||||||
|
|
||||||
|
export default node;
|
||||||
346
apps/console/src/pages/organizations/assets/__generated__/AssetsListView_assets.graphql.ts
generated
Normal file
346
apps/console/src/pages/organizations/assets/__generated__/AssetsListView_assets.graphql.ts
generated
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<2ddf214d0baa06962b8ffde078089c42>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ReaderFragment } from 'relay-runtime';
|
||||||
|
export type AssetType = "PHYSICAL" | "VIRTUAL";
|
||||||
|
export type CriticityLevel = "HIGH" | "LOW" | "MEDIUM";
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AssetsListView_assets$data = {
|
||||||
|
readonly assets: {
|
||||||
|
readonly __id: string;
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly amount: number;
|
||||||
|
readonly assetType: AssetType;
|
||||||
|
readonly createdAt: string;
|
||||||
|
readonly criticity: CriticityLevel;
|
||||||
|
readonly dataTypesStored: string;
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly owner: {
|
||||||
|
readonly fullName: string;
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
readonly updatedAt: string;
|
||||||
|
readonly vendors: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
readonly pageInfo: {
|
||||||
|
readonly endCursor: string | null | undefined;
|
||||||
|
readonly hasNextPage: boolean;
|
||||||
|
readonly hasPreviousPage: boolean;
|
||||||
|
readonly startCursor: string | null | undefined;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly id: string;
|
||||||
|
readonly " $fragmentType": "AssetsListView_assets";
|
||||||
|
};
|
||||||
|
export type AssetsListView_assets$key = {
|
||||||
|
readonly " $data"?: AssetsListView_assets$data;
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AssetsListView_assets">;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ReaderFragment = (function(){
|
||||||
|
var v0 = [
|
||||||
|
"assets"
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "after"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "before"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "first"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": {
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"count": null,
|
||||||
|
"cursor": null,
|
||||||
|
"direction": "bidirectional",
|
||||||
|
"path": (v0/*: any*/)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"refetch": {
|
||||||
|
"connection": {
|
||||||
|
"forward": {
|
||||||
|
"count": "first",
|
||||||
|
"cursor": "after"
|
||||||
|
},
|
||||||
|
"backward": {
|
||||||
|
"count": "last",
|
||||||
|
"cursor": "before"
|
||||||
|
},
|
||||||
|
"path": (v0/*: any*/)
|
||||||
|
},
|
||||||
|
"fragmentPathInResult": [
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"operation": require('./AssetsListViewPaginationQuery.graphql'),
|
||||||
|
"identifierInfo": {
|
||||||
|
"identifierField": "id",
|
||||||
|
"identifierQueryVariableName": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "AssetsListView_assets",
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": "assets",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "AMOUNT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "AssetConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "__AssetsListView_assets_connection",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AssetEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": "__AssetsListView_assets_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"AMOUNT\"})"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "b7ef7bd1063b9a578b82124ebbdbbbd2";
|
||||||
|
|
||||||
|
export default node;
|
||||||
156
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewAddAssetVendorMutation.graphql.ts
generated
Normal file
156
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewAddAssetVendorMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<29c3688b6280f97bc3713b4e107f012a>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AddAssetVendorInput = {
|
||||||
|
assetId: string;
|
||||||
|
vendorId: string;
|
||||||
|
};
|
||||||
|
export type NewAssetViewAddAssetVendorMutation$variables = {
|
||||||
|
input: AddAssetVendorInput;
|
||||||
|
};
|
||||||
|
export type NewAssetViewAddAssetVendorMutation$data = {
|
||||||
|
readonly addAssetVendor: {
|
||||||
|
readonly asset: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly vendors: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type NewAssetViewAddAssetVendorMutation = {
|
||||||
|
response: NewAssetViewAddAssetVendorMutation$data;
|
||||||
|
variables: NewAssetViewAddAssetVendorMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "AddAssetVendorPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "addAssetVendor",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "asset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "NewAssetViewAddAssetVendorMutation",
|
||||||
|
"selections": (v2/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "NewAssetViewAddAssetVendorMutation",
|
||||||
|
"selections": (v2/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "5e1ee36fdf08abfcfc75ffe7e9f6f81f",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "NewAssetViewAddAssetVendorMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation NewAssetViewAddAssetVendorMutation(\n $input: AddAssetVendorInput!\n) {\n addAssetVendor(input: $input) {\n asset {\n id\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "856e34e5fb3ca94b3cc38fe7edca156d";
|
||||||
|
|
||||||
|
export default node;
|
||||||
272
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewCreateAssetMutation.graphql.ts
generated
Normal file
272
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewCreateAssetMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<d3201cc709c2b7c947f4875520fb8960>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AssetType = "PHYSICAL" | "VIRTUAL";
|
||||||
|
export type CriticityLevel = "HIGH" | "LOW" | "MEDIUM";
|
||||||
|
export type CreateAssetInput = {
|
||||||
|
amount: number;
|
||||||
|
assetType: AssetType;
|
||||||
|
criticity?: CriticityLevel;
|
||||||
|
dataTypesStored: string;
|
||||||
|
name: string;
|
||||||
|
organizationId: string;
|
||||||
|
ownerId: string;
|
||||||
|
vendorIds?: ReadonlyArray<string> | null | undefined;
|
||||||
|
};
|
||||||
|
export type NewAssetViewCreateAssetMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
|
input: CreateAssetInput;
|
||||||
|
};
|
||||||
|
export type NewAssetViewCreateAssetMutation$data = {
|
||||||
|
readonly createAsset: {
|
||||||
|
readonly assetEdge: {
|
||||||
|
readonly node: {
|
||||||
|
readonly amount: number;
|
||||||
|
readonly assetType: AssetType;
|
||||||
|
readonly criticity: CriticityLevel;
|
||||||
|
readonly dataTypesStored: string;
|
||||||
|
readonly id: string;
|
||||||
|
readonly owner: {
|
||||||
|
readonly fullName: string;
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
readonly vendors: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type NewAssetViewCreateAssetMutation = {
|
||||||
|
response: NewAssetViewCreateAssetMutation$data;
|
||||||
|
variables: NewAssetViewCreateAssetMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "connections"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AssetEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "assetEdge",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Asset",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "criticity",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "assetType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "dataTypesStored",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "owner",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "NewAssetViewCreateAssetMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateAssetPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createAsset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "NewAssetViewCreateAssetMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateAssetPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createAsset",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "prependEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "assetEdge",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "2c2aaa87fd4a17b47fb6207c9be861b5",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "NewAssetViewCreateAssetMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation NewAssetViewCreateAssetMutation(\n $input: CreateAssetInput!\n) {\n createAsset(input: $input) {\n assetEdge {\n node {\n id\n amount\n criticity\n assetType\n dataTypesStored\n owner {\n id\n fullName\n }\n vendors {\n edges {\n node {\n id\n name\n }\n }\n }\n }\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "56f34aeeaca0d8165b8145c83b30fe67";
|
||||||
|
|
||||||
|
export default node;
|
||||||
341
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewQuery.graphql.ts
generated
Normal file
341
apps/console/src/pages/organizations/assets/__generated__/NewAssetViewQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<166441573cdbf7c3c7aaccc74eb2edc7>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type NewAssetViewQuery$variables = {
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
export type NewAssetViewQuery$data = {
|
||||||
|
readonly organization: {
|
||||||
|
readonly id?: string;
|
||||||
|
readonly vendors?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"PeopleSelector_organization">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type NewAssetViewQuery = {
|
||||||
|
response: NewAssetViewQuery$data;
|
||||||
|
variables: NewAssetViewQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "NAME"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v5 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v6 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v7 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "VendorEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Vendor",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v5/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v6/*: any*/)
|
||||||
|
],
|
||||||
|
v8 = {
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "first",
|
||||||
|
"value": 100
|
||||||
|
},
|
||||||
|
v9 = [
|
||||||
|
(v8/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "orderBy",
|
||||||
|
"value": {
|
||||||
|
"direction": "ASC",
|
||||||
|
"field": "FULL_NAME"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v10 = [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
v11 = [
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "NewAssetViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"args": null,
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "PeopleSelector_organization"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "vendors",
|
||||||
|
"args": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "__NewAssetView_vendors_connection",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v7/*: any*/),
|
||||||
|
"storageKey": "__NewAssetView_vendors_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"NAME\"})"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "NewAssetViewQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v9/*: any*/),
|
||||||
|
"concreteType": "PeopleConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "peoples",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PeopleEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "People",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "fullName",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "primaryEmailAddress",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v5/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v6/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": "peoples(first:100,orderBy:{\"direction\":\"ASC\",\"field\":\"FULL_NAME\"})"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v9/*: any*/),
|
||||||
|
"filters": (v10/*: any*/),
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "PeopleSelector_organization_peoples",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "peoples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v11/*: any*/),
|
||||||
|
"concreteType": "VendorConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "vendors",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v7/*: any*/),
|
||||||
|
"storageKey": "vendors(first:100,orderBy:{\"direction\":\"ASC\",\"field\":\"NAME\"})"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v11/*: any*/),
|
||||||
|
"filters": (v10/*: any*/),
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "NewAssetView_vendors",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "vendors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "feaf4563ef8c073edbbbfbb935b1a802",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"count": null,
|
||||||
|
"cursor": null,
|
||||||
|
"direction": "forward",
|
||||||
|
"path": [
|
||||||
|
"organization",
|
||||||
|
"vendors"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": "NewAssetViewQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query NewAssetViewQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n ...PeopleSelector_organization\n vendors(first: 100, orderBy: {direction: ASC, field: NAME}) {\n edges {\n node {\n id\n name\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100, orderBy: {direction: ASC, field: FULL_NAME}) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "9f48276b2f88367acfd95b4d95167e73";
|
||||||
|
|
||||||
|
export default node;
|
||||||
40
apps/console/src/pages/organizations/assets/__generated__/NewAssetView_organization.graphql.ts
generated
Normal file
40
apps/console/src/pages/organizations/assets/__generated__/NewAssetView_organization.graphql.ts
generated
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<cbf5b6ff35e9f54f26becd5378ccb4cd>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ReaderFragment } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type NewAssetView_organization$data = {
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"PeopleSelector_organization">;
|
||||||
|
readonly " $fragmentType": "NewAssetView_organization";
|
||||||
|
};
|
||||||
|
export type NewAssetView_organization$key = {
|
||||||
|
readonly " $data"?: NewAssetView_organization$data;
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"NewAssetView_organization">;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ReaderFragment = {
|
||||||
|
"argumentDefinitions": [],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "NewAssetView_organization",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": null,
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "PeopleSelector_organization"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
};
|
||||||
|
|
||||||
|
(node as any).hash = "96eb63be6b58e29a7bd3dafaaa07d5a4";
|
||||||
|
|
||||||
|
export default node;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Suspense, useEffect, useTransition } from "react";
|
import { Suspense, useEffect, useTransition, useRef } from "react";
|
||||||
import {
|
import {
|
||||||
graphql,
|
graphql,
|
||||||
PreloadedQuery,
|
PreloadedQuery,
|
||||||
@@ -155,6 +155,7 @@ function PeopleListContent({
|
|||||||
const [deletePeople] =
|
const [deletePeople] =
|
||||||
useMutation<PeopleListViewDeletePeopleMutation>(deletePeopleMutation);
|
useMutation<PeopleListViewDeletePeopleMutation>(deletePeopleMutation);
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: peoplesConnection,
|
data: peoplesConnection,
|
||||||
@@ -258,6 +259,7 @@ function PeopleListContent({
|
|||||||
hasMore={hasPrevious}
|
hasMore={hasPrevious}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("before", pageInfo?.startCursor || "");
|
prev.set("before", pageInfo?.startCursor || "");
|
||||||
prev.delete("after");
|
prev.delete("after");
|
||||||
@@ -272,6 +274,7 @@ function PeopleListContent({
|
|||||||
hasMore={hasNext}
|
hasMore={hasNext}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("after", pageInfo?.endCursor || "");
|
prev.set("after", pageInfo?.endCursor || "");
|
||||||
prev.delete("before");
|
prev.delete("before");
|
||||||
@@ -290,13 +293,19 @@ export default function PeopleListView() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [queryRef, loadQuery] =
|
const [queryRef, loadQuery] =
|
||||||
useQueryLoader<PeopleListViewQueryType>(peopleListViewQuery);
|
useQueryLoader<PeopleListViewQueryType>(peopleListViewQuery);
|
||||||
|
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const after = searchParams.get("after");
|
const after = searchParams.get("after");
|
||||||
const before = searchParams.get("before");
|
const before = searchParams.get("before");
|
||||||
|
|
||||||
|
// Skip the query if this was triggered by pagination
|
||||||
|
if (isPaginationUpdate.current) {
|
||||||
|
isPaginationUpdate.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loadQuery({
|
loadQuery({
|
||||||
organizationId: organizationId!,
|
organizationId: organizationId!,
|
||||||
first: before ? undefined : ITEMS_PER_PAGE,
|
first: before ? undefined : ITEMS_PER_PAGE,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
useTransition,
|
useTransition,
|
||||||
|
useRef,
|
||||||
} from "react";
|
} from "react";
|
||||||
import type { ListRiskViewQuery } from "./__generated__/ListRiskViewQuery.graphql";
|
import type { ListRiskViewQuery } from "./__generated__/ListRiskViewQuery.graphql";
|
||||||
import { useParams, useSearchParams } from "react-router";
|
import { useParams, useSearchParams } from "react-router";
|
||||||
@@ -532,6 +533,7 @@ function ListRiskViewContent({
|
|||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
const { organizationId } = useParams<{ organizationId: string }>();
|
const { organizationId } = useParams<{ organizationId: string }>();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
// State for delete confirmation dialog
|
// State for delete confirmation dialog
|
||||||
const [riskToDelete, setRiskToDelete] = useState<{
|
const [riskToDelete, setRiskToDelete] = useState<{
|
||||||
@@ -656,6 +658,7 @@ function ListRiskViewContent({
|
|||||||
hasMore={hasPrevious}
|
hasMore={hasPrevious}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("before", pageInfo?.startCursor || "");
|
prev.set("before", pageInfo?.startCursor || "");
|
||||||
prev.delete("after");
|
prev.delete("after");
|
||||||
@@ -923,6 +926,7 @@ function ListRiskViewContent({
|
|||||||
hasMore={hasNext}
|
hasMore={hasNext}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("after", pageInfo?.endCursor || "");
|
prev.set("after", pageInfo?.endCursor || "");
|
||||||
prev.delete("before");
|
prev.delete("before");
|
||||||
@@ -941,13 +945,19 @@ export default function ListRiskView() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [queryRef, loadQuery] =
|
const [queryRef, loadQuery] =
|
||||||
useQueryLoader<ListRiskViewQuery>(listRiskViewQuery);
|
useQueryLoader<ListRiskViewQuery>(listRiskViewQuery);
|
||||||
|
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const after = searchParams.get("after");
|
const after = searchParams.get("after");
|
||||||
const before = searchParams.get("before");
|
const before = searchParams.get("before");
|
||||||
|
|
||||||
|
// Skip the query if this was triggered by pagination
|
||||||
|
if (isPaginationUpdate.current) {
|
||||||
|
isPaginationUpdate.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loadQuery({
|
loadQuery({
|
||||||
organizationId: organizationId!,
|
organizationId: organizationId!,
|
||||||
first: before ? undefined : defaultPageSize,
|
first: before ? undefined : defaultPageSize,
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ function ListVendorContent({
|
|||||||
useMutation<ListVendorViewDeleteVendorMutation>(deleteVendorMutation);
|
useMutation<ListVendorViewDeleteVendorMutation>(deleteVendorMutation);
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadVendorsData = async () => {
|
const loadVendorsData = async () => {
|
||||||
@@ -698,6 +699,7 @@ function ListVendorContent({
|
|||||||
hasMore={hasPrevious}
|
hasMore={hasPrevious}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("before", pageInfo?.startCursor || "");
|
prev.set("before", pageInfo?.startCursor || "");
|
||||||
prev.delete("after");
|
prev.delete("after");
|
||||||
@@ -712,6 +714,7 @@ function ListVendorContent({
|
|||||||
hasMore={hasNext}
|
hasMore={hasNext}
|
||||||
onLoadMore={() => {
|
onLoadMore={() => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
isPaginationUpdate.current = true;
|
||||||
setSearchParams((prev) => {
|
setSearchParams((prev) => {
|
||||||
prev.set("after", pageInfo?.endCursor || "");
|
prev.set("after", pageInfo?.endCursor || "");
|
||||||
prev.delete("before");
|
prev.delete("before");
|
||||||
@@ -729,13 +732,19 @@ export default function ListVendorView() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [queryRef, loadQuery] =
|
const [queryRef, loadQuery] =
|
||||||
useQueryLoader<ListVendorViewQuery>(listVendorViewQuery);
|
useQueryLoader<ListVendorViewQuery>(listVendorViewQuery);
|
||||||
|
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
|
const isPaginationUpdate = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const after = searchParams.get("after");
|
const after = searchParams.get("after");
|
||||||
const before = searchParams.get("before");
|
const before = searchParams.get("before");
|
||||||
|
|
||||||
|
// Skip the query if this was triggered by pagination
|
||||||
|
if (isPaginationUpdate.current) {
|
||||||
|
isPaginationUpdate.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loadQuery({
|
loadQuery({
|
||||||
organizationId: organizationId!,
|
organizationId: organizationId!,
|
||||||
first: before ? undefined : ITEMS_PER_PAGE,
|
first: before ? undefined : ITEMS_PER_PAGE,
|
||||||
@@ -743,7 +752,7 @@ export default function ListVendorView() {
|
|||||||
last: before ? ITEMS_PER_PAGE : undefined,
|
last: before ? ITEMS_PER_PAGE : undefined,
|
||||||
before: before || undefined,
|
before: before || undefined,
|
||||||
});
|
});
|
||||||
}, [loadQuery, organizationId]);
|
}, [loadQuery, organizationId, searchParams]);
|
||||||
|
|
||||||
if (!queryRef) {
|
if (!queryRef) {
|
||||||
return <ListVendorViewSkeleton />;
|
return <ListVendorViewSkeleton />;
|
||||||
|
|||||||
427
pkg/coredata/asset.go
Normal file
427
pkg/coredata/asset.go
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"maps"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Asset struct {
|
||||||
|
ID gid.GID `db:"id"`
|
||||||
|
Name string `db:"name"`
|
||||||
|
Amount int `db:"amount"`
|
||||||
|
OwnerID gid.GID `db:"owner_id"`
|
||||||
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
|
Criticity CriticityLevel `db:"criticity"`
|
||||||
|
AssetType AssetType `db:"asset_type"`
|
||||||
|
DataTypesStored string `db:"data_types_stored"`
|
||||||
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) CursorKey(field AssetOrderField) page.CursorKey {
|
||||||
|
switch field {
|
||||||
|
case AssetOrderFieldCreatedAt:
|
||||||
|
return page.NewCursorKey(a.ID, a.CreatedAt)
|
||||||
|
case AssetOrderFieldAmount:
|
||||||
|
return page.NewCursorKey(a.ID, a.Amount)
|
||||||
|
case AssetOrderFieldCriticity:
|
||||||
|
return page.NewCursorKey(a.ID, a.Criticity)
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||||
|
}
|
||||||
|
|
||||||
|
type Assets []*Asset
|
||||||
|
|
||||||
|
func (a *Asset) LoadByID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
assetID gid.GID,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
organization_id,
|
||||||
|
owner_id,
|
||||||
|
amount,
|
||||||
|
criticity,
|
||||||
|
asset_type,
|
||||||
|
data_types_stored,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
assets
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @asset_id
|
||||||
|
LIMIT 1;
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"asset_id": assetID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query assets: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
asset, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Asset])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = asset
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) LoadByOwnerID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
organization_id,
|
||||||
|
owner_id,
|
||||||
|
amount,
|
||||||
|
criticity,
|
||||||
|
asset_type,
|
||||||
|
data_types_stored,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
assets
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND owner_id = @owner_id
|
||||||
|
LIMIT 1;
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"owner_id": a.OwnerID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query assets: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
asset, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Asset])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = asset
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Assets) LoadByOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
organizationID gid.GID,
|
||||||
|
cursor *page.Cursor[AssetOrderField],
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
organization_id,
|
||||||
|
owner_id,
|
||||||
|
amount,
|
||||||
|
criticity,
|
||||||
|
asset_type,
|
||||||
|
data_types_stored,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
assets
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND organization_id = @organization_id
|
||||||
|
AND %s
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
maps.Copy(args, cursor.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query assets: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assets, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Asset])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect assets: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = assets
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) Insert(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
INSERT INTO assets (
|
||||||
|
id,
|
||||||
|
tenant_id,
|
||||||
|
name,
|
||||||
|
organization_id,
|
||||||
|
owner_id,
|
||||||
|
amount,
|
||||||
|
criticity,
|
||||||
|
asset_type,
|
||||||
|
data_types_stored,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
@id,
|
||||||
|
@tenant_id,
|
||||||
|
@name,
|
||||||
|
@organization_id,
|
||||||
|
@owner_id,
|
||||||
|
@amount,
|
||||||
|
@criticity,
|
||||||
|
@asset_type,
|
||||||
|
@data_types_stored,
|
||||||
|
@created_at,
|
||||||
|
@updated_at
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": a.ID,
|
||||||
|
"tenant_id": scope.GetTenantID(),
|
||||||
|
"organization_id": a.OrganizationID,
|
||||||
|
"name": a.Name,
|
||||||
|
"owner_id": a.OwnerID,
|
||||||
|
"amount": a.Amount,
|
||||||
|
"criticity": a.Criticity,
|
||||||
|
"asset_type": a.AssetType,
|
||||||
|
"data_types_stored": a.DataTypesStored,
|
||||||
|
"created_at": a.CreatedAt,
|
||||||
|
"updated_at": a.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) Update(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
UPDATE assets
|
||||||
|
SET
|
||||||
|
name = @name,
|
||||||
|
owner_id = @owner_id,
|
||||||
|
amount = @amount,
|
||||||
|
criticity = @criticity,
|
||||||
|
asset_type = @asset_type,
|
||||||
|
data_types_stored = @data_types_stored,
|
||||||
|
updated_at = @updated_at
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
RETURNING
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
organization_id,
|
||||||
|
owner_id,
|
||||||
|
amount,
|
||||||
|
criticity,
|
||||||
|
asset_type,
|
||||||
|
data_types_stored,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": a.ID,
|
||||||
|
"name": a.Name,
|
||||||
|
"owner_id": a.OwnerID,
|
||||||
|
"amount": a.Amount,
|
||||||
|
"criticity": a.Criticity,
|
||||||
|
"asset_type": a.AssetType,
|
||||||
|
"data_types_stored": a.DataTypesStored,
|
||||||
|
"updated_at": time.Now(),
|
||||||
|
}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot update asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
asset, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Asset])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect updated asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = asset
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
DELETE FROM assets
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"id": a.ID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetVendor struct {
|
||||||
|
AssetID int64 `db:"asset_id"`
|
||||||
|
VendorID int64 `db:"vendor_id"`
|
||||||
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) CreateWithVendors(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
organization *Organization,
|
||||||
|
vendorIDs []gid.GID,
|
||||||
|
now time.Time,
|
||||||
|
) error {
|
||||||
|
if err := organization.LoadByID(ctx, conn, scope, a.OrganizationID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load organization %q: %w", a.OrganizationID, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := a.Insert(ctx, conn, scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot insert asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(vendorIDs) > 0 {
|
||||||
|
for _, vendorID := range vendorIDs {
|
||||||
|
_, err := conn.Exec(ctx, `
|
||||||
|
INSERT INTO asset_vendors (tenant_id, asset_id, vendor_id, created_at)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
`, scope.GetTenantID(), a.ID, vendorID, now)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert asset vendor: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Asset) UpdateWithVendors(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
vendorIDs []gid.GID,
|
||||||
|
now time.Time,
|
||||||
|
) error {
|
||||||
|
existing := &Asset{}
|
||||||
|
if err := existing.LoadByID(ctx, conn, scope, a.ID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
a.OrganizationID = existing.OrganizationID
|
||||||
|
a.CreatedAt = existing.CreatedAt
|
||||||
|
a.UpdatedAt = now
|
||||||
|
|
||||||
|
if err := a.Update(ctx, conn, scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot update asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, `
|
||||||
|
DELETE FROM asset_vendors
|
||||||
|
WHERE tenant_id = $1 AND asset_id = $2
|
||||||
|
`, scope.GetTenantID(), a.ID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete asset vendors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(vendorIDs) > 0 {
|
||||||
|
for _, vendorID := range vendorIDs {
|
||||||
|
_, err := conn.Exec(ctx, `
|
||||||
|
INSERT INTO asset_vendors (tenant_id, asset_id, vendor_id, created_at)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
`, scope.GetTenantID(), a.ID, vendorID, now)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert asset vendor: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateWithVendorsTx updates an asset and its vendor relationships in a single transaction
|
||||||
|
func (a *Asset) UpdateWithVendorsTx(
|
||||||
|
ctx context.Context,
|
||||||
|
db *pg.Client,
|
||||||
|
scope Scoper,
|
||||||
|
vendorIDs []gid.GID,
|
||||||
|
now time.Time,
|
||||||
|
) error {
|
||||||
|
return db.WithTx(ctx, func(conn pg.Conn) error {
|
||||||
|
return a.UpdateWithVendors(ctx, conn, scope, vendorIDs, now)
|
||||||
|
})
|
||||||
|
}
|
||||||
32
pkg/coredata/asset_order_field.go
Normal file
32
pkg/coredata/asset_order_field.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type AssetOrderField string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AssetOrderFieldCreatedAt AssetOrderField = "CREATED_AT"
|
||||||
|
AssetOrderFieldAmount AssetOrderField = "AMOUNT"
|
||||||
|
AssetOrderFieldCriticity AssetOrderField = "CRITICITY"
|
||||||
|
AssetOrderFieldName AssetOrderField = "NAME"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p AssetOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p AssetOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
65
pkg/coredata/asset_type.go
Normal file
65
pkg/coredata/asset_type.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql/driver"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
AssetType string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
AssetTypePhysical AssetType = "PHYSICAL"
|
||||||
|
AssetTypeVirtual AssetType = "VIRTUAL"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (at AssetType) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(at.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (at *AssetType) UnmarshalText(data []byte) error {
|
||||||
|
val := string(data)
|
||||||
|
|
||||||
|
switch val {
|
||||||
|
case AssetTypePhysical.String():
|
||||||
|
*at = AssetTypePhysical
|
||||||
|
case AssetTypeVirtual.String():
|
||||||
|
*at = AssetTypeVirtual
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid AssetType value: %q", val)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (at AssetType) String() string {
|
||||||
|
return string(at)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (at *AssetType) Scan(value any) error {
|
||||||
|
val, ok := value.(string)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("invalid scan source for AssetType, expected string got %T", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return at.UnmarshalText([]byte(val))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (at AssetType) Value() (driver.Value, error) {
|
||||||
|
return at.String(), nil
|
||||||
|
}
|
||||||
23
pkg/coredata/criticity_level.go
Normal file
23
pkg/coredata/criticity_level.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type CriticityLevel string
|
||||||
|
|
||||||
|
const (
|
||||||
|
CriticityLevelLow CriticityLevel = "LOW"
|
||||||
|
CriticityLevelMedium CriticityLevel = "MEDIUM"
|
||||||
|
CriticityLevelHigh CriticityLevel = "HIGH"
|
||||||
|
)
|
||||||
@@ -33,4 +33,5 @@ const (
|
|||||||
RiskEntityType
|
RiskEntityType
|
||||||
DocumentVersionEntityType
|
DocumentVersionEntityType
|
||||||
DocumentVersionSignatureEntityType
|
DocumentVersionSignatureEntityType
|
||||||
|
AssetEntityType
|
||||||
)
|
)
|
||||||
|
|||||||
27
pkg/coredata/migrations/20250530T215914Z.sql
Normal file
27
pkg/coredata/migrations/20250530T215914Z.sql
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
-- Create enum types
|
||||||
|
CREATE TYPE criticity_level AS ENUM ('LOW', 'MEDIUM', 'HIGH');
|
||||||
|
CREATE TYPE asset_type AS ENUM ('PHYSICAL', 'VIRTUAL');
|
||||||
|
|
||||||
|
-- Create assets table
|
||||||
|
CREATE TABLE IF NOT EXISTS assets (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
tenant_id TEXT NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
amount INTEGER NOT NULL,
|
||||||
|
owner_id TEXT NOT NULL REFERENCES peoples(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
organization_id TEXT NOT NULL REFERENCES organizations(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
criticity criticity_level DEFAULT 'MEDIUM',
|
||||||
|
asset_type asset_type NOT NULL DEFAULT 'VIRTUAL',
|
||||||
|
data_types_stored TEXT,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create junction table for many-to-many relationship with vendors
|
||||||
|
CREATE TABLE IF NOT EXISTS asset_vendors (
|
||||||
|
asset_id TEXT REFERENCES assets(id) ON DELETE CASCADE,
|
||||||
|
vendor_id TEXT REFERENCES vendors(id) ON DELETE CASCADE,
|
||||||
|
tenant_id TEXT NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
PRIMARY KEY (asset_id, vendor_id)
|
||||||
|
);
|
||||||
@@ -29,6 +29,7 @@ import (
|
|||||||
type (
|
type (
|
||||||
Vendor struct {
|
Vendor struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
|
TenantID gid.TenantID `db:"tenant_id"`
|
||||||
OrganizationID gid.GID `db:"organization_id"`
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
Description *string `db:"description"`
|
Description *string `db:"description"`
|
||||||
@@ -77,6 +78,7 @@ func (v *Vendor) LoadByID(
|
|||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
@@ -243,6 +245,7 @@ func (v *Vendors) LoadByOrganizationID(
|
|||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
@@ -386,3 +389,93 @@ func (v Vendor) ExpireNonExpiredRiskAssessments(
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *Vendors) LoadByAssetID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
assetID gid.GID,
|
||||||
|
cursor *page.Cursor[VendorOrderField],
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
WITH vend AS (
|
||||||
|
SELECT
|
||||||
|
v.id,
|
||||||
|
v.tenant_id,
|
||||||
|
v.organization_id,
|
||||||
|
v.name,
|
||||||
|
v.description,
|
||||||
|
v.category,
|
||||||
|
v.headquarter_address,
|
||||||
|
v.legal_name,
|
||||||
|
v.website_url,
|
||||||
|
v.privacy_policy_url,
|
||||||
|
v.service_level_agreement_url,
|
||||||
|
v.data_processing_agreement_url,
|
||||||
|
v.business_associate_agreement_url,
|
||||||
|
v.subprocessors_list_url,
|
||||||
|
v.certifications,
|
||||||
|
v.business_owner_id,
|
||||||
|
v.security_owner_id,
|
||||||
|
v.status_page_url,
|
||||||
|
v.terms_of_service_url,
|
||||||
|
v.security_page_url,
|
||||||
|
v.trust_page_url,
|
||||||
|
v.created_at,
|
||||||
|
v.updated_at
|
||||||
|
FROM
|
||||||
|
vendors v
|
||||||
|
INNER JOIN
|
||||||
|
asset_vendors av ON v.id = av.vendor_id
|
||||||
|
WHERE
|
||||||
|
av.asset_id = @asset_id
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
tenant_id,
|
||||||
|
organization_id,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
category,
|
||||||
|
headquarter_address,
|
||||||
|
legal_name,
|
||||||
|
website_url,
|
||||||
|
privacy_policy_url,
|
||||||
|
service_level_agreement_url,
|
||||||
|
data_processing_agreement_url,
|
||||||
|
business_associate_agreement_url,
|
||||||
|
subprocessors_list_url,
|
||||||
|
certifications,
|
||||||
|
business_owner_id,
|
||||||
|
security_owner_id,
|
||||||
|
status_page_url,
|
||||||
|
terms_of_service_url,
|
||||||
|
security_page_url,
|
||||||
|
trust_page_url,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
vend
|
||||||
|
WHERE %s
|
||||||
|
AND %s
|
||||||
|
`
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.NamedArgs{"asset_id": assetID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
maps.Copy(args, cursor.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query vendors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
vendors, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Vendor])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect vendors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*v = vendors
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
228
pkg/probo/asset_service.go
Normal file
228
pkg/probo/asset_service.go
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
package probo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AssetService struct {
|
||||||
|
svc *TenantService
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAssetRequest struct {
|
||||||
|
OrganizationID gid.GID
|
||||||
|
Name string
|
||||||
|
Amount int
|
||||||
|
OwnerID gid.GID
|
||||||
|
Criticity coredata.CriticityLevel
|
||||||
|
AssetType coredata.AssetType
|
||||||
|
DataTypesStored string
|
||||||
|
VendorIDs []gid.GID
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAssetRequest struct {
|
||||||
|
ID gid.GID
|
||||||
|
Name *string
|
||||||
|
Amount *int
|
||||||
|
OwnerID *gid.GID
|
||||||
|
Criticity *coredata.CriticityLevel
|
||||||
|
AssetType *coredata.AssetType
|
||||||
|
DataTypesStored *string
|
||||||
|
VendorIDs []gid.GID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) Get(
|
||||||
|
ctx context.Context,
|
||||||
|
assetID gid.GID,
|
||||||
|
) (*coredata.Asset, error) {
|
||||||
|
asset := &coredata.Asset{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return asset.LoadByID(ctx, conn, s.svc.scope, assetID)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) GetByOwnerID(
|
||||||
|
ctx context.Context,
|
||||||
|
ownerID gid.GID,
|
||||||
|
) (*coredata.Asset, error) {
|
||||||
|
asset := &coredata.Asset{OwnerID: ownerID}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return asset.LoadByOwnerID(ctx, conn, s.svc.scope)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) ListForOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
organizationID gid.GID,
|
||||||
|
cursor *page.Cursor[coredata.AssetOrderField],
|
||||||
|
) (*page.Page[*coredata.Asset, coredata.AssetOrderField], error) {
|
||||||
|
var assets coredata.Assets
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return assets.LoadByOrganizationID(
|
||||||
|
ctx,
|
||||||
|
conn,
|
||||||
|
s.svc.scope,
|
||||||
|
organizationID,
|
||||||
|
cursor,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return page.NewPage(assets, cursor), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) Update(
|
||||||
|
ctx context.Context,
|
||||||
|
req UpdateAssetRequest,
|
||||||
|
) (*coredata.Asset, error) {
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
existing := &coredata.Asset{}
|
||||||
|
if err := s.svc.pg.WithConn(ctx, func(conn pg.Conn) error {
|
||||||
|
return existing.LoadByID(ctx, conn, s.svc.scope, req.ID)
|
||||||
|
}); err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
asset := &coredata.Asset{
|
||||||
|
ID: req.ID,
|
||||||
|
OrganizationID: existing.OrganizationID,
|
||||||
|
Name: existing.Name,
|
||||||
|
Amount: existing.Amount,
|
||||||
|
OwnerID: existing.OwnerID,
|
||||||
|
Criticity: existing.Criticity,
|
||||||
|
AssetType: existing.AssetType,
|
||||||
|
DataTypesStored: existing.DataTypesStored,
|
||||||
|
CreatedAt: existing.CreatedAt,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update fields from request
|
||||||
|
if req.Name != nil {
|
||||||
|
asset.Name = *req.Name
|
||||||
|
}
|
||||||
|
if req.Amount != nil {
|
||||||
|
asset.Amount = *req.Amount
|
||||||
|
}
|
||||||
|
if req.OwnerID != nil {
|
||||||
|
asset.OwnerID = *req.OwnerID
|
||||||
|
}
|
||||||
|
if req.Criticity != nil {
|
||||||
|
asset.Criticity = *req.Criticity
|
||||||
|
}
|
||||||
|
if req.AssetType != nil {
|
||||||
|
asset.AssetType = *req.AssetType
|
||||||
|
}
|
||||||
|
if req.DataTypesStored != nil {
|
||||||
|
asset.DataTypesStored = *req.DataTypesStored
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := asset.UpdateWithVendorsTx(ctx, s.svc.pg, s.svc.scope, req.VendorIDs, now); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) Create(
|
||||||
|
ctx context.Context,
|
||||||
|
req CreateAssetRequest,
|
||||||
|
) (*coredata.Asset, error) {
|
||||||
|
now := time.Now()
|
||||||
|
assetID := gid.New(s.svc.scope.GetTenantID(), coredata.AssetEntityType)
|
||||||
|
|
||||||
|
organization := &coredata.Organization{}
|
||||||
|
asset := &coredata.Asset{
|
||||||
|
ID: assetID,
|
||||||
|
OrganizationID: req.OrganizationID,
|
||||||
|
Name: req.Name,
|
||||||
|
Amount: req.Amount,
|
||||||
|
OwnerID: req.OwnerID,
|
||||||
|
Criticity: req.Criticity,
|
||||||
|
AssetType: req.AssetType,
|
||||||
|
DataTypesStored: req.DataTypesStored,
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithTx(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return asset.CreateWithVendors(ctx, conn, s.svc.scope, organization, req.VendorIDs, now)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
assetID gid.GID,
|
||||||
|
) error {
|
||||||
|
asset := &coredata.Asset{ID: assetID}
|
||||||
|
|
||||||
|
return s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return asset.Delete(ctx, conn, s.svc.scope)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AssetService) ListVendors(
|
||||||
|
ctx context.Context,
|
||||||
|
assetID gid.GID,
|
||||||
|
cursor *page.Cursor[coredata.VendorOrderField],
|
||||||
|
) (*page.Page[*coredata.Vendor, coredata.VendorOrderField], error) {
|
||||||
|
var vendors coredata.Vendors
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return vendors.LoadByAssetID(ctx, conn, s.svc.scope, assetID, cursor)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return page.NewPage(vendors, cursor), nil
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@ type (
|
|||||||
Risks *RiskService
|
Risks *RiskService
|
||||||
VendorComplianceReports *VendorComplianceReportService
|
VendorComplianceReports *VendorComplianceReportService
|
||||||
Connectors *ConnectorService
|
Connectors *ConnectorService
|
||||||
|
Assets *AssetService
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -129,5 +130,6 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
|||||||
tenantService.Risks = &RiskService{svc: tenantService}
|
tenantService.Risks = &RiskService{svc: tenantService}
|
||||||
tenantService.VendorComplianceReports = &VendorComplianceReportService{svc: tenantService}
|
tenantService.VendorComplianceReports = &VendorComplianceReportService{svc: tenantService}
|
||||||
tenantService.Connectors = &ConnectorService{svc: tenantService}
|
tenantService.Connectors = &ConnectorService{svc: tenantService}
|
||||||
|
tenantService.Assets = &AssetService{svc: tenantService}
|
||||||
return tenantService
|
return tenantService
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,6 +343,23 @@ enum DocumentType @goModel(model: "github.com/getprobo/probo/pkg/coredata.Docume
|
|||||||
POLICY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DocumentTypePolicy")
|
POLICY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DocumentTypePolicy")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AssetType @goModel(model: "github.com/getprobo/probo/pkg/coredata.AssetType") {
|
||||||
|
PHYSICAL @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetTypePhysical")
|
||||||
|
VIRTUAL @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetTypeVirtual")
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CriticityLevel @goModel(model: "github.com/getprobo/probo/pkg/coredata.CriticityLevel") {
|
||||||
|
LOW @goEnum(value: "github.com/getprobo/probo/pkg/coredata.CriticityLevelLow")
|
||||||
|
MEDIUM @goEnum(value: "github.com/getprobo/probo/pkg/coredata.CriticityLevelMedium")
|
||||||
|
HIGH @goEnum(value: "github.com/getprobo/probo/pkg/coredata.CriticityLevelHigh")
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AssetOrderField @goModel(model: "github.com/getprobo/probo/pkg/coredata.AssetOrderField") {
|
||||||
|
CREATED_AT @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetOrderFieldCreatedAt")
|
||||||
|
AMOUNT @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetOrderFieldAmount")
|
||||||
|
CRITICITY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetOrderFieldCriticity")
|
||||||
|
}
|
||||||
|
|
||||||
# Order Input Types
|
# Order Input Types
|
||||||
input UserOrder
|
input UserOrder
|
||||||
@goModel(
|
@goModel(
|
||||||
@@ -532,6 +549,14 @@ type Organization implements Node {
|
|||||||
orderBy: TaskOrder
|
orderBy: TaskOrder
|
||||||
): TaskConnection! @goField(forceResolver: true)
|
): TaskConnection! @goField(forceResolver: true)
|
||||||
|
|
||||||
|
assets(
|
||||||
|
first: Int
|
||||||
|
after: CursorKey
|
||||||
|
last: Int
|
||||||
|
before: CursorKey
|
||||||
|
orderBy: AssetOrder
|
||||||
|
): AssetConnection! @goField(forceResolver: true)
|
||||||
|
|
||||||
createdAt: Datetime!
|
createdAt: Datetime!
|
||||||
updatedAt: Datetime!
|
updatedAt: Datetime!
|
||||||
}
|
}
|
||||||
@@ -1126,6 +1151,12 @@ type Mutation {
|
|||||||
exportAudit(input: ExportAuditInput!): ExportAuditPayload!
|
exportAudit(input: ExportAuditInput!): ExportAuditPayload!
|
||||||
|
|
||||||
assessVendor(input: AssessVendorInput!): AssessVendorPayload!
|
assessVendor(input: AssessVendorInput!): AssessVendorPayload!
|
||||||
|
|
||||||
|
createAsset(input: CreateAssetInput!): CreateAssetPayload!
|
||||||
|
updateAsset(input: UpdateAssetInput!): UpdateAssetPayload!
|
||||||
|
deleteAsset(input: DeleteAssetInput!): DeleteAssetPayload!
|
||||||
|
addAssetVendor(input: AddAssetVendorInput!): AddAssetVendorPayload!
|
||||||
|
removeAssetVendor(input: RemoveAssetVendorInput!): RemoveAssetVendorPayload!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Input Types
|
# Input Types
|
||||||
@@ -1832,3 +1863,94 @@ input AssessVendorInput {
|
|||||||
type AssessVendorPayload {
|
type AssessVendorPayload {
|
||||||
vendor: Vendor!
|
vendor: Vendor!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Asset implements Node {
|
||||||
|
id: ID!
|
||||||
|
name: String!
|
||||||
|
amount: Int!
|
||||||
|
owner: People! @goField(forceResolver: true)
|
||||||
|
vendors(
|
||||||
|
first: Int
|
||||||
|
after: CursorKey
|
||||||
|
last: Int
|
||||||
|
before: CursorKey
|
||||||
|
orderBy: VendorOrder
|
||||||
|
): VendorConnection! @goField(forceResolver: true)
|
||||||
|
criticity: CriticityLevel!
|
||||||
|
assetType: AssetType! @goField(forceResolver: true)
|
||||||
|
dataTypesStored: String!
|
||||||
|
organization: Organization! @goField(forceResolver: true)
|
||||||
|
createdAt: Datetime!
|
||||||
|
updatedAt: Datetime!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetConnection {
|
||||||
|
edges: [AssetEdge!]!
|
||||||
|
pageInfo: PageInfo!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetEdge {
|
||||||
|
cursor: CursorKey!
|
||||||
|
node: Asset!
|
||||||
|
}
|
||||||
|
|
||||||
|
input AssetOrder {
|
||||||
|
direction: OrderDirection!
|
||||||
|
field: AssetOrderField!
|
||||||
|
}
|
||||||
|
|
||||||
|
input CreateAssetInput {
|
||||||
|
organizationId: ID!
|
||||||
|
name: String!
|
||||||
|
amount: Int!
|
||||||
|
ownerId: ID!
|
||||||
|
criticity: CriticityLevel! = MEDIUM
|
||||||
|
assetType: AssetType!
|
||||||
|
dataTypesStored: String!
|
||||||
|
vendorIds: [ID!]
|
||||||
|
}
|
||||||
|
|
||||||
|
input UpdateAssetInput {
|
||||||
|
id: ID!
|
||||||
|
name: String
|
||||||
|
amount: Int
|
||||||
|
ownerId: ID
|
||||||
|
criticity: CriticityLevel
|
||||||
|
assetType: AssetType
|
||||||
|
dataTypesStored: String
|
||||||
|
vendorIds: [ID!]
|
||||||
|
}
|
||||||
|
|
||||||
|
input DeleteAssetInput {
|
||||||
|
assetId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
input AddAssetVendorInput {
|
||||||
|
assetId: ID!
|
||||||
|
vendorId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
input RemoveAssetVendorInput {
|
||||||
|
assetId: ID!
|
||||||
|
vendorId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAssetPayload {
|
||||||
|
assetEdge: AssetEdge!
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAssetPayload {
|
||||||
|
asset: Asset!
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAssetPayload {
|
||||||
|
deletedAssetId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddAssetVendorPayload {
|
||||||
|
asset: Asset!
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemoveAssetVendorPayload {
|
||||||
|
asset: Asset!
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
38
pkg/server/api/console/v1/types/asset.go
Normal file
38
pkg/server/api/console/v1/types/asset.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewAsset(asset *coredata.Asset) *Asset {
|
||||||
|
return &Asset{
|
||||||
|
ID: asset.ID,
|
||||||
|
Name: asset.Name,
|
||||||
|
Amount: asset.Amount,
|
||||||
|
Criticity: asset.Criticity,
|
||||||
|
AssetType: asset.AssetType,
|
||||||
|
DataTypesStored: asset.DataTypesStored,
|
||||||
|
CreatedAt: asset.CreatedAt,
|
||||||
|
UpdatedAt: asset.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAssetEdge(asset *coredata.Asset, orderField coredata.AssetOrderField) *AssetEdge {
|
||||||
|
return &AssetEdge{
|
||||||
|
Node: NewAsset(asset),
|
||||||
|
Cursor: asset.CursorKey(orderField),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAssetConnection(page *page.Page[*coredata.Asset, coredata.AssetOrderField]) *AssetConnection {
|
||||||
|
edges := make([]*AssetEdge, len(page.Data))
|
||||||
|
for i, asset := range page.Data {
|
||||||
|
edges[i] = NewAssetEdge(asset, page.Cursor.OrderBy.Field)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &AssetConnection{
|
||||||
|
Edges: edges,
|
||||||
|
PageInfo: NewPageInfo(page),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,15 @@ type Node interface {
|
|||||||
GetID() gid.GID
|
GetID() gid.GID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AddAssetVendorInput struct {
|
||||||
|
AssetID gid.GID `json:"assetId"`
|
||||||
|
VendorID gid.GID `json:"vendorId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddAssetVendorPayload struct {
|
||||||
|
Asset *Asset `json:"asset"`
|
||||||
|
}
|
||||||
|
|
||||||
type AssessVendorInput struct {
|
type AssessVendorInput struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
WebsiteURL string `json:"websiteUrl"`
|
WebsiteURL string `json:"websiteUrl"`
|
||||||
@@ -29,6 +38,38 @@ type AssessVendorPayload struct {
|
|||||||
Vendor *Vendor `json:"vendor"`
|
Vendor *Vendor `json:"vendor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Asset struct {
|
||||||
|
ID gid.GID `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Amount int `json:"amount"`
|
||||||
|
Owner *People `json:"owner"`
|
||||||
|
Vendors *VendorConnection `json:"vendors"`
|
||||||
|
Criticity coredata.CriticityLevel `json:"criticity"`
|
||||||
|
AssetType coredata.AssetType `json:"assetType"`
|
||||||
|
DataTypesStored string `json:"dataTypesStored"`
|
||||||
|
Organization *Organization `json:"organization"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Asset) IsNode() {}
|
||||||
|
func (this Asset) GetID() gid.GID { return this.ID }
|
||||||
|
|
||||||
|
type AssetConnection struct {
|
||||||
|
Edges []*AssetEdge `json:"edges"`
|
||||||
|
PageInfo *PageInfo `json:"pageInfo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetEdge struct {
|
||||||
|
Cursor page.CursorKey `json:"cursor"`
|
||||||
|
Node *Asset `json:"node"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetOrder struct {
|
||||||
|
Direction page.OrderDirection `json:"direction"`
|
||||||
|
Field coredata.AssetOrderField `json:"field"`
|
||||||
|
}
|
||||||
|
|
||||||
type AssignTaskInput struct {
|
type AssignTaskInput struct {
|
||||||
TaskID gid.GID `json:"taskId"`
|
TaskID gid.GID `json:"taskId"`
|
||||||
AssignedToID gid.GID `json:"assignedToId"`
|
AssignedToID gid.GID `json:"assignedToId"`
|
||||||
@@ -97,6 +138,21 @@ type ControlEdge struct {
|
|||||||
Node *Control `json:"node"`
|
Node *Control `json:"node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateAssetInput struct {
|
||||||
|
OrganizationID gid.GID `json:"organizationId"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Amount int `json:"amount"`
|
||||||
|
OwnerID gid.GID `json:"ownerId"`
|
||||||
|
Criticity coredata.CriticityLevel `json:"criticity"`
|
||||||
|
AssetType coredata.AssetType `json:"assetType"`
|
||||||
|
DataTypesStored string `json:"dataTypesStored"`
|
||||||
|
VendorIds []gid.GID `json:"vendorIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAssetPayload struct {
|
||||||
|
AssetEdge *AssetEdge `json:"assetEdge"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateControlDocumentMappingInput struct {
|
type CreateControlDocumentMappingInput struct {
|
||||||
ControlID gid.GID `json:"controlId"`
|
ControlID gid.GID `json:"controlId"`
|
||||||
DocumentID gid.GID `json:"documentId"`
|
DocumentID gid.GID `json:"documentId"`
|
||||||
@@ -285,6 +341,14 @@ type CreateVendorRiskAssessmentPayload struct {
|
|||||||
VendorRiskAssessmentEdge *VendorRiskAssessmentEdge `json:"vendorRiskAssessmentEdge"`
|
VendorRiskAssessmentEdge *VendorRiskAssessmentEdge `json:"vendorRiskAssessmentEdge"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteAssetInput struct {
|
||||||
|
AssetID gid.GID `json:"assetId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAssetPayload struct {
|
||||||
|
DeletedAssetID gid.GID `json:"deletedAssetId"`
|
||||||
|
}
|
||||||
|
|
||||||
type DeleteControlDocumentMappingInput struct {
|
type DeleteControlDocumentMappingInput struct {
|
||||||
ControlID gid.GID `json:"controlId"`
|
ControlID gid.GID `json:"controlId"`
|
||||||
DocumentID gid.GID `json:"documentId"`
|
DocumentID gid.GID `json:"documentId"`
|
||||||
@@ -635,6 +699,7 @@ type Organization struct {
|
|||||||
Measures *MeasureConnection `json:"measures"`
|
Measures *MeasureConnection `json:"measures"`
|
||||||
Risks *RiskConnection `json:"risks"`
|
Risks *RiskConnection `json:"risks"`
|
||||||
Tasks *TaskConnection `json:"tasks"`
|
Tasks *TaskConnection `json:"tasks"`
|
||||||
|
Assets *AssetConnection `json:"assets"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
@@ -702,6 +767,15 @@ type PublishDocumentVersionPayload struct {
|
|||||||
type Query struct {
|
type Query struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RemoveAssetVendorInput struct {
|
||||||
|
AssetID gid.GID `json:"assetId"`
|
||||||
|
VendorID gid.GID `json:"vendorId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemoveAssetVendorPayload struct {
|
||||||
|
Asset *Asset `json:"asset"`
|
||||||
|
}
|
||||||
|
|
||||||
type RemoveUserInput struct {
|
type RemoveUserInput struct {
|
||||||
OrganizationID gid.GID `json:"organizationId"`
|
OrganizationID gid.GID `json:"organizationId"`
|
||||||
UserID gid.GID `json:"userId"`
|
UserID gid.GID `json:"userId"`
|
||||||
@@ -814,6 +888,21 @@ type UnassignTaskPayload struct {
|
|||||||
Task *Task `json:"task"`
|
Task *Task `json:"task"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateAssetInput struct {
|
||||||
|
ID gid.GID `json:"id"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Amount *int `json:"amount,omitempty"`
|
||||||
|
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||||
|
Criticity *coredata.CriticityLevel `json:"criticity,omitempty"`
|
||||||
|
AssetType *coredata.AssetType `json:"assetType,omitempty"`
|
||||||
|
DataTypesStored *string `json:"dataTypesStored,omitempty"`
|
||||||
|
VendorIds []gid.GID `json:"vendorIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAssetPayload struct {
|
||||||
|
Asset *Asset `json:"asset"`
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateDocumentInput struct {
|
type UpdateDocumentInput struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
Title *string `json:"title,omitempty"`
|
Title *string `json:"title,omitempty"`
|
||||||
|
|||||||
@@ -20,6 +20,65 @@ import (
|
|||||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Owner is the resolver for the owner field.
|
||||||
|
func (r *assetResolver) Owner(ctx context.Context, obj *types.Asset) (*types.People, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
|
|
||||||
|
asset, err := svc.Assets.Get(ctx, obj.ID)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get asset: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
owner, err := svc.Peoples.Get(ctx, asset.OwnerID)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get owner: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewPeople(owner), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vendors is the resolver for the vendors field.
|
||||||
|
func (r *assetResolver) Vendors(ctx context.Context, obj *types.Asset, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorOrderBy) (*types.VendorConnection, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
|
|
||||||
|
pageOrderBy := page.OrderBy[coredata.VendorOrderField]{
|
||||||
|
Field: coredata.VendorOrderFieldCreatedAt,
|
||||||
|
Direction: page.OrderDirectionDesc,
|
||||||
|
}
|
||||||
|
if orderBy != nil {
|
||||||
|
pageOrderBy = page.OrderBy[coredata.VendorOrderField]{
|
||||||
|
Field: orderBy.Field,
|
||||||
|
Direction: orderBy.Direction,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||||
|
|
||||||
|
page, err := svc.Assets.ListVendors(ctx, obj.ID, cursor)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot list asset vendors: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewVendorConnection(page), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssetType is the resolver for the assetType field.
|
||||||
|
func (r *assetResolver) AssetType(ctx context.Context, obj *types.Asset) (coredata.AssetType, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
|
|
||||||
|
asset, err := svc.Assets.Get(ctx, obj.ID)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get asset: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset.AssetType, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Organization is the resolver for the organization field.
|
||||||
|
func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*types.Organization, error) {
|
||||||
|
panic(fmt.Errorf("not implemented: Organization - organization"))
|
||||||
|
}
|
||||||
|
|
||||||
// Framework is the resolver for the framework field.
|
// Framework is the resolver for the framework field.
|
||||||
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
||||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
@@ -1557,6 +1616,77 @@ func (r *mutationResolver) AssessVendor(ctx context.Context, input types.AssessV
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateAsset is the resolver for the createAsset field.
|
||||||
|
func (r *mutationResolver) CreateAsset(ctx context.Context, input types.CreateAssetInput) (*types.CreateAssetPayload, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||||
|
|
||||||
|
asset, err := svc.Assets.Create(ctx, probo.CreateAssetRequest{
|
||||||
|
OrganizationID: input.OrganizationID,
|
||||||
|
Name: input.Name,
|
||||||
|
Amount: input.Amount,
|
||||||
|
OwnerID: input.OwnerID,
|
||||||
|
Criticity: input.Criticity,
|
||||||
|
AssetType: input.AssetType,
|
||||||
|
DataTypesStored: input.DataTypesStored,
|
||||||
|
VendorIDs: input.VendorIds,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot create asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.CreateAssetPayload{
|
||||||
|
AssetEdge: types.NewAssetEdge(asset, coredata.AssetOrderFieldCreatedAt),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAsset is the resolver for the updateAsset field.
|
||||||
|
func (r *mutationResolver) UpdateAsset(ctx context.Context, input types.UpdateAssetInput) (*types.UpdateAssetPayload, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||||
|
|
||||||
|
asset, err := svc.Assets.Update(ctx, probo.UpdateAssetRequest{
|
||||||
|
ID: input.ID,
|
||||||
|
Name: input.Name,
|
||||||
|
Amount: input.Amount,
|
||||||
|
OwnerID: input.OwnerID,
|
||||||
|
Criticity: input.Criticity,
|
||||||
|
AssetType: input.AssetType,
|
||||||
|
DataTypesStored: input.DataTypesStored,
|
||||||
|
VendorIDs: input.VendorIds,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot update asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.UpdateAssetPayload{
|
||||||
|
Asset: types.NewAsset(asset),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAsset is the resolver for the deleteAsset field.
|
||||||
|
func (r *mutationResolver) DeleteAsset(ctx context.Context, input types.DeleteAssetInput) (*types.DeleteAssetPayload, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, input.AssetID.TenantID())
|
||||||
|
|
||||||
|
err := svc.Assets.Delete(ctx, input.AssetID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot delete asset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.DeleteAssetPayload{
|
||||||
|
DeletedAssetID: input.AssetID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddAssetVendor is the resolver for the addAssetVendor field.
|
||||||
|
func (r *mutationResolver) AddAssetVendor(ctx context.Context, input types.AddAssetVendorInput) (*types.AddAssetVendorPayload, error) {
|
||||||
|
panic(fmt.Errorf("not implemented: AddAssetVendor - addAssetVendor"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveAssetVendor is the resolver for the removeAssetVendor field.
|
||||||
|
func (r *mutationResolver) RemoveAssetVendor(ctx context.Context, input types.RemoveAssetVendorInput) (*types.RemoveAssetVendorPayload, error) {
|
||||||
|
panic(fmt.Errorf("not implemented: RemoveAssetVendor - removeAssetVendor"))
|
||||||
|
}
|
||||||
|
|
||||||
// LogoURL is the resolver for the logoUrl field.
|
// LogoURL is the resolver for the logoUrl field.
|
||||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
@@ -1787,6 +1917,31 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio
|
|||||||
return types.NewTaskConnection(page), nil
|
return types.NewTaskConnection(page), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assets is the resolver for the assets field.
|
||||||
|
func (r *organizationResolver) Assets(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AssetOrder) (*types.AssetConnection, error) {
|
||||||
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
|
|
||||||
|
pageOrderBy := page.OrderBy[coredata.AssetOrderField]{
|
||||||
|
Field: coredata.AssetOrderFieldCreatedAt,
|
||||||
|
Direction: page.OrderDirectionDesc,
|
||||||
|
}
|
||||||
|
if orderBy != nil {
|
||||||
|
pageOrderBy = page.OrderBy[coredata.AssetOrderField]{
|
||||||
|
Field: orderBy.Field,
|
||||||
|
Direction: orderBy.Direction,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||||
|
|
||||||
|
page, err := svc.Assets.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot list organization assets: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewAssetConnection(page), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Node is the resolver for the node field.
|
// Node is the resolver for the node field.
|
||||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||||
svc := GetTenantService(ctx, r.proboSvc, id.TenantID())
|
svc := GetTenantService(ctx, r.proboSvc, id.TenantID())
|
||||||
@@ -1878,6 +2033,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||||
}
|
}
|
||||||
return types.NewDocumentVersionSignature(documentVersionSignature), nil
|
return types.NewDocumentVersionSignature(documentVersionSignature), nil
|
||||||
|
case coredata.AssetEntityType:
|
||||||
|
asset, err := svc.Assets.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get asset: %w", err))
|
||||||
|
}
|
||||||
|
return types.NewAsset(asset), nil
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2190,7 +2351,6 @@ func (r *vendorResolver) BusinessOwner(ctx context.Context, obj *types.Vendor) (
|
|||||||
// SecurityOwner is the resolver for the securityOwner field.
|
// SecurityOwner is the resolver for the securityOwner field.
|
||||||
func (r *vendorResolver) SecurityOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
func (r *vendorResolver) SecurityOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
||||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||||
|
|
||||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to get vendor: %w", err))
|
panic(fmt.Errorf("failed to get vendor: %w", err))
|
||||||
@@ -2286,6 +2446,9 @@ func (r *viewerResolver) Organizations(ctx context.Context, obj *types.Viewer, f
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Asset returns schema.AssetResolver implementation.
|
||||||
|
func (r *Resolver) Asset() schema.AssetResolver { return &assetResolver{r} }
|
||||||
|
|
||||||
// Control returns schema.ControlResolver implementation.
|
// Control returns schema.ControlResolver implementation.
|
||||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||||
|
|
||||||
@@ -2345,6 +2508,7 @@ func (r *Resolver) VendorRiskAssessment() schema.VendorRiskAssessmentResolver {
|
|||||||
// Viewer returns schema.ViewerResolver implementation.
|
// Viewer returns schema.ViewerResolver implementation.
|
||||||
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||||
|
|
||||||
|
type assetResolver struct{ *Resolver }
|
||||||
type controlResolver struct{ *Resolver }
|
type controlResolver struct{ *Resolver }
|
||||||
type documentResolver struct{ *Resolver }
|
type documentResolver struct{ *Resolver }
|
||||||
type documentVersionResolver struct{ *Resolver }
|
type documentVersionResolver struct{ *Resolver }
|
||||||
|
|||||||
Reference in New Issue
Block a user