@@ -33,12 +33,15 @@ const VendorOverviewPage = lazy(() => import("./pages/VendorOverviewPage"));
|
|||||||
const SettingsPage = lazy(() => import("./pages/SettingsPage"));
|
const SettingsPage = lazy(() => import("./pages/SettingsPage"));
|
||||||
const CreatePeoplePage = lazy(() => import("./pages/CreatePeoplePage"));
|
const CreatePeoplePage = lazy(() => import("./pages/CreatePeoplePage"));
|
||||||
const FrameworkOverviewPage = lazy(
|
const FrameworkOverviewPage = lazy(
|
||||||
() => import("./pages/FrameworkOverviewPage"),
|
() => import("./pages/FrameworkOverviewPage")
|
||||||
);
|
);
|
||||||
const ControlOverviewPage = lazy(() => import("./pages/ControlOverviewPage"));
|
const ControlOverviewPage = lazy(() => import("./pages/ControlOverviewPage"));
|
||||||
const PeopleOverviewPage = lazy(() => import("./pages/PeopleOverviewPage"));
|
const PeopleOverviewPage = lazy(() => import("./pages/PeopleOverviewPage"));
|
||||||
const LoginPage = lazy(() => import("./pages/LoginPage"));
|
const LoginPage = lazy(() => import("./pages/LoginPage"));
|
||||||
const RegisterPage = lazy(() => import("./pages/RegisterPage"));
|
const RegisterPage = lazy(() => import("./pages/RegisterPage"));
|
||||||
|
const CreateOrganizationPage = lazy(
|
||||||
|
() => import("./pages/CreateOrganizationPage")
|
||||||
|
);
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -202,6 +205,16 @@ function App() {
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="organizations/create"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundaryWithLocation>
|
||||||
|
<CreateOrganizationPage />
|
||||||
|
</ErrorBoundaryWithLocation>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="*"
|
path="*"
|
||||||
element={
|
element={
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useState, useEffect } from "react";
|
|||||||
import { ChevronsUpDown, Plus } from "lucide-react";
|
import { ChevronsUpDown, Plus } from "lucide-react";
|
||||||
import { graphql, useFragment } from "react-relay";
|
import { graphql, useFragment } from "react-relay";
|
||||||
import { useOrganization } from "@/contexts/OrganizationContext";
|
import { useOrganization } from "@/contexts/OrganizationContext";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -27,18 +28,24 @@ import {
|
|||||||
|
|
||||||
export const teamSwitcherFragment = graphql`
|
export const teamSwitcherFragment = graphql`
|
||||||
fragment TeamSwitcher_organizations on User {
|
fragment TeamSwitcher_organizations on User {
|
||||||
organizations {
|
organizations(first: 25) @connection(key: "TeamSwitcher_organizations") {
|
||||||
|
__id
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
logoUrl
|
logoUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Extended type to include plan field until Relay compiler generates the types
|
// Extended type to include plan field until Relay compiler generates the types
|
||||||
type Organization = TeamSwitcher_organizations$data["organizations"][0] & {
|
type Organization =
|
||||||
|
TeamSwitcher_organizations$data["organizations"]["edges"][0]["node"] & {
|
||||||
plan?: string;
|
plan?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TeamSwitcher({
|
export function TeamSwitcher({
|
||||||
organizations,
|
organizations,
|
||||||
@@ -50,13 +57,15 @@ export function TeamSwitcher({
|
|||||||
const { currentOrganization, setCurrentOrganization } = useOrganization();
|
const { currentOrganization, setCurrentOrganization } = useOrganization();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log(data.organizations);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
data.organizations &&
|
data.organizations &&
|
||||||
data.organizations.length > 0 &&
|
data.organizations.edges.length > 0 &&
|
||||||
!currentOrganization
|
!currentOrganization
|
||||||
) {
|
) {
|
||||||
// Type assertion to include plan field
|
// Type assertion to include plan field
|
||||||
setCurrentOrganization(data.organizations[0] as Organization);
|
setCurrentOrganization(data.organizations.edges[0].node);
|
||||||
}
|
}
|
||||||
}, [data.organizations, currentOrganization, setCurrentOrganization]);
|
}, [data.organizations, currentOrganization, setCurrentOrganization]);
|
||||||
|
|
||||||
@@ -109,27 +118,32 @@ export function TeamSwitcher({
|
|||||||
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
||||||
Organizations
|
Organizations
|
||||||
</DropdownMenuLabel>
|
</DropdownMenuLabel>
|
||||||
{data.organizations.map((org: Organization, index: number) => (
|
{data.organizations.edges.map((edge, index) => (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
key={org.id}
|
key={edge.node.id}
|
||||||
onClick={() => setCurrentOrganization(org)}
|
onClick={() => setCurrentOrganization(edge.node)}
|
||||||
className="gap-2 p-2"
|
className="gap-2 p-2"
|
||||||
>
|
>
|
||||||
<div className="flex size-6 items-center justify-center rounded-sm border">
|
<div className="flex size-6 items-center justify-center rounded-sm border">
|
||||||
<LogoComponent org={org} className="size-4 shrink-0" />
|
<LogoComponent org={edge.node} className="size-4 shrink-0" />
|
||||||
</div>
|
</div>
|
||||||
{org.name}
|
{edge.node.name}
|
||||||
<DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
|
<DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
))}
|
))}
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem className="gap-2 p-2">
|
<DropdownMenuItem asChild>
|
||||||
|
<Link
|
||||||
|
to="/organizations/create"
|
||||||
|
className="gap-2 p-2 cursor-pointer"
|
||||||
|
>
|
||||||
<div className="flex size-6 items-center justify-center rounded-md border bg-background">
|
<div className="flex size-6 items-center justify-center rounded-md border bg-background">
|
||||||
<Plus className="size-4" />
|
<Plus className="size-4" />
|
||||||
</div>
|
</div>
|
||||||
<div className="font-medium text-muted-foreground">
|
<div className="font-medium text-muted-foreground">
|
||||||
Add organization
|
Add organization
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<d060c85c907876f442133c643b917eee>>
|
* @generated SignedSource<<a1cc304a7eb154a19a1ec9a68c2cda98>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -29,7 +29,14 @@ var v0 = {
|
|||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
};
|
},
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "first",
|
||||||
|
"value": 25
|
||||||
|
}
|
||||||
|
];
|
||||||
return {
|
return {
|
||||||
"fragment": {
|
"fragment": {
|
||||||
"argumentDefinitions": [],
|
"argumentDefinitions": [],
|
||||||
@@ -78,13 +85,29 @@ return {
|
|||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v0/*: any*/),
|
(v0/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": "OrganizationConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "organizations",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "OrganizationEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "Organization",
|
"concreteType": "Organization",
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "organizations",
|
"name": "node",
|
||||||
"plural": true,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v0/*: any*/),
|
(v0/*: any*/),
|
||||||
{
|
{
|
||||||
@@ -100,10 +123,76 @@ return {
|
|||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "logoUrl",
|
"name": "logoUrl",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"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": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": "organizations(first:25)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"filters": null,
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "TeamSwitcher_organizations",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "organizations"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
@@ -124,12 +213,12 @@ return {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "48137f101a20a5ce116cbf46c2a8cd63",
|
"cacheID": "52b7d912665a4da10a79b82987a7e58a",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "AppSidebarQuery",
|
"name": "AppSidebarQuery",
|
||||||
"operationKind": "query",
|
"operationKind": "query",
|
||||||
"text": "query AppSidebarQuery {\n viewer {\n id\n ...TeamSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment TeamSwitcher_organizations on User {\n organizations {\n id\n name\n logoUrl\n }\n}\n"
|
"text": "query AppSidebarQuery {\n viewer {\n id\n ...TeamSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment TeamSwitcher_organizations on User {\n organizations(first: 25) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<8ecb9304d0a498d483d1a8c251f8c49a>>
|
* @generated SignedSource<<a4a57a018956ccc09931f2b2ce87c933>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -11,11 +11,16 @@
|
|||||||
import { ReaderFragment } from 'relay-runtime';
|
import { ReaderFragment } from 'relay-runtime';
|
||||||
import { FragmentRefs } from "relay-runtime";
|
import { FragmentRefs } from "relay-runtime";
|
||||||
export type TeamSwitcher_organizations$data = {
|
export type TeamSwitcher_organizations$data = {
|
||||||
readonly organizations: ReadonlyArray<{
|
readonly organizations: {
|
||||||
|
readonly __id: string;
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly logoUrl: string;
|
readonly logoUrl: string;
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
|
};
|
||||||
}>;
|
}>;
|
||||||
|
};
|
||||||
readonly " $fragmentType": "TeamSwitcher_organizations";
|
readonly " $fragmentType": "TeamSwitcher_organizations";
|
||||||
};
|
};
|
||||||
export type TeamSwitcher_organizations$key = {
|
export type TeamSwitcher_organizations$key = {
|
||||||
@@ -26,16 +31,43 @@ export type TeamSwitcher_organizations$key = {
|
|||||||
const node: ReaderFragment = {
|
const node: ReaderFragment = {
|
||||||
"argumentDefinitions": [],
|
"argumentDefinitions": [],
|
||||||
"kind": "Fragment",
|
"kind": "Fragment",
|
||||||
"metadata": null,
|
"metadata": {
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"count": null,
|
||||||
|
"cursor": null,
|
||||||
|
"direction": "forward",
|
||||||
|
"path": [
|
||||||
|
"organizations"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"name": "TeamSwitcher_organizations",
|
"name": "TeamSwitcher_organizations",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organizations",
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "OrganizationConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "__TeamSwitcher_organizations_connection",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "OrganizationEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "Organization",
|
"concreteType": "Organization",
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "organizations",
|
"name": "node",
|
||||||
"plural": true,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
@@ -57,6 +89,63 @@ const node: ReaderFragment = {
|
|||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "logoUrl",
|
"name": "logoUrl",
|
||||||
"storageKey": null
|
"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": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
@@ -66,6 +155,6 @@ const node: ReaderFragment = {
|
|||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
};
|
};
|
||||||
|
|
||||||
(node as any).hash = "318f68b82b5b87500ec99ffcdd2929ab";
|
(node as any).hash = "22731866cafda226a19f8c64fda51ba5";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ function BreadcrumbFrameworkOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ frameworkId: frameworkId! },
|
{ frameworkId: frameworkId! },
|
||||||
{ fetchPolicy: "store-or-network" },
|
{ fetchPolicy: "store-or-network" }
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -133,7 +133,7 @@ function BreadcrumbPeopleOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ peopleId: peopleId! },
|
{ peopleId: peopleId! },
|
||||||
{ fetchPolicy: "store-or-network" },
|
{ fetchPolicy: "store-or-network" }
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -177,7 +177,7 @@ function BreadcrumbVendorOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ vendorId: vendorId! },
|
{ vendorId: vendorId! },
|
||||||
{ fetchPolicy: "store-or-network" },
|
{ fetchPolicy: "store-or-network" }
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -215,7 +215,7 @@ function BreadcrumbControlOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ frameworkId: frameworkId!, controlId: controlId! },
|
{ frameworkId: frameworkId!, controlId: controlId! },
|
||||||
{ fetchPolicy: "store-or-network" },
|
{ fetchPolicy: "store-or-network" }
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -243,6 +243,20 @@ function BreadcrumbControlOverview() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function BreadcrumbCreateOrganization() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BreadcrumbSeparator />
|
||||||
|
<BreadcrumbItem>
|
||||||
|
<BreadcrumbLink asChild>
|
||||||
|
<Link to="/organizations/create">Create Organization</Link>
|
||||||
|
</BreadcrumbLink>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
<Outlet />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function ConsoleLayout() {
|
export default function ConsoleLayout() {
|
||||||
return (
|
return (
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
@@ -280,6 +294,10 @@ export default function ConsoleLayout() {
|
|||||||
element={<BreadcrumbVendorOverview />}
|
element={<BreadcrumbVendorOverview />}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route
|
||||||
|
path="/organizations/create"
|
||||||
|
element={<BreadcrumbCreateOrganization />}
|
||||||
|
/>
|
||||||
</Routes>
|
</Routes>
|
||||||
</BreadcrumbHome>
|
</BreadcrumbHome>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
186
apps/console/src/pages/CreateOrganizationPage.tsx
Normal file
186
apps/console/src/pages/CreateOrganizationPage.tsx
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
import {
|
||||||
|
graphql,
|
||||||
|
ConnectionHandler,
|
||||||
|
useMutation,
|
||||||
|
useLazyLoadQuery,
|
||||||
|
} from "react-relay";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { useOrganization } from "@/contexts/OrganizationContext";
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
CardDescription,
|
||||||
|
CardContent,
|
||||||
|
} from "@/components/ui/card";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
import { HelpCircle } from "lucide-react";
|
||||||
|
import { CreateOrganizationPageCreateOrganizationMutation } from "./__generated__/CreateOrganizationPageCreateOrganizationMutation.graphql";
|
||||||
|
import { CreateOrganizationPageViewerQuery } from "./__generated__/CreateOrganizationPageViewerQuery.graphql";
|
||||||
|
|
||||||
|
const createOrganizationMutation = graphql`
|
||||||
|
mutation CreateOrganizationPageCreateOrganizationMutation(
|
||||||
|
$input: CreateOrganizationInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
createOrganization(input: $input) {
|
||||||
|
organizationEdge @appendEdge(connections: $connections) {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
logoUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const viewerQuery = graphql`
|
||||||
|
query CreateOrganizationPageViewerQuery {
|
||||||
|
viewer {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
function EditableField({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
type = "text",
|
||||||
|
helpText,
|
||||||
|
required,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
type?: string;
|
||||||
|
helpText?: string;
|
||||||
|
required?: boolean;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<HelpCircle className="h-4 w-4 text-gray-400" />
|
||||||
|
<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}
|
||||||
|
/>
|
||||||
|
{helpText && <p className="text-sm text-gray-500">{helpText}</p>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CreateOrganizationPage() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { setCurrentOrganization } = useOrganization();
|
||||||
|
const data = useLazyLoadQuery<CreateOrganizationPageViewerQuery>(
|
||||||
|
viewerQuery,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
const [createOrganization] =
|
||||||
|
useMutation<CreateOrganizationPageCreateOrganizationMutation>(
|
||||||
|
createOrganizationMutation
|
||||||
|
);
|
||||||
|
const { toast } = useToast();
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleFieldChange = (field: keyof typeof formData, value: string) => {
|
||||||
|
setFormData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[field]: value,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
createOrganization({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
name: formData.name,
|
||||||
|
},
|
||||||
|
connections: [
|
||||||
|
ConnectionHandler.getConnectionID(
|
||||||
|
data.viewer.id,
|
||||||
|
"TeamSwitcher_organizations"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
onCompleted: (response) => {
|
||||||
|
const newOrg = response.createOrganization.organizationEdge.node;
|
||||||
|
setCurrentOrganization(newOrg);
|
||||||
|
toast({
|
||||||
|
title: "Success",
|
||||||
|
description: "Organization created successfully",
|
||||||
|
variant: "default",
|
||||||
|
});
|
||||||
|
navigate("/");
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast({
|
||||||
|
title: "Error",
|
||||||
|
description: error.message || "Failed to create organization",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>Create Organization - Probo</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
|
<div className="container mx-auto p-6 space-y-6">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-4xl font-medium tracking-tight">
|
||||||
|
Create Organization
|
||||||
|
</h1>
|
||||||
|
<p className="text-lg text-muted-foreground">
|
||||||
|
Create a new organization to manage your compliance and security
|
||||||
|
needs.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Organization Details</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
Enter the basic information about your organization.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-6">
|
||||||
|
<EditableField
|
||||||
|
label="Organization Name"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={(value) => handleFieldChange("name", value)}
|
||||||
|
helpText="The name of your organization as it will appear throughout the platform."
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button type="submit" className="w-full">
|
||||||
|
Create Organization
|
||||||
|
</Button>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,6 +13,8 @@ export const HomePageQuery = graphql`
|
|||||||
viewer {
|
viewer {
|
||||||
id
|
id
|
||||||
organizations {
|
organizations {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
name
|
name
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
@@ -123,6 +125,8 @@ export const HomePageQuery = graphql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ import {
|
|||||||
useQueryLoader,
|
useQueryLoader,
|
||||||
} from "react-relay";
|
} from "react-relay";
|
||||||
import type { SettingsPageQuery as SettingsPageQueryType } from "./__generated__/SettingsPageQuery.graphql";
|
import type { SettingsPageQuery as SettingsPageQueryType } from "./__generated__/SettingsPageQuery.graphql";
|
||||||
|
import { useOrganization } from "@/contexts/OrganizationContext";
|
||||||
|
|
||||||
const settingsPageQuery = graphql`
|
const settingsPageQuery = graphql`
|
||||||
query SettingsPageQuery {
|
query SettingsPageQuery($organizationID: ID!) {
|
||||||
viewer {
|
organization: node(id: $organizationID) {
|
||||||
id
|
id
|
||||||
organizations {
|
... on Organization {
|
||||||
name
|
name
|
||||||
logoUrl
|
logoUrl
|
||||||
}
|
}
|
||||||
@@ -49,7 +50,7 @@ function SettingsPageContent({
|
|||||||
queryRef: PreloadedQuery<SettingsPageQueryType>;
|
queryRef: PreloadedQuery<SettingsPageQueryType>;
|
||||||
}) {
|
}) {
|
||||||
const data = usePreloadedQuery(settingsPageQuery, queryRef);
|
const data = usePreloadedQuery(settingsPageQuery, queryRef);
|
||||||
const organization = data.viewer.organizations[0];
|
const organization = data.organization;
|
||||||
const members: Member[] = [];
|
const members: Member[] = [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -216,9 +217,11 @@ export default function SettingsPage() {
|
|||||||
const [queryRef, loadQuery] =
|
const [queryRef, loadQuery] =
|
||||||
useQueryLoader<SettingsPageQueryType>(settingsPageQuery);
|
useQueryLoader<SettingsPageQueryType>(settingsPageQuery);
|
||||||
|
|
||||||
|
const { currentOrganization } = useOrganization();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadQuery({});
|
loadQuery({ organizationID: currentOrganization!.id });
|
||||||
}, [loadQuery]);
|
}, [loadQuery, currentOrganization]);
|
||||||
|
|
||||||
if (!queryRef) {
|
if (!queryRef) {
|
||||||
return <SettingsPageFallback />;
|
return <SettingsPageFallback />;
|
||||||
|
|||||||
174
apps/console/src/pages/__generated__/CreateOrganizationPageCreateOrganizationMutation.graphql.ts
generated
Normal file
174
apps/console/src/pages/__generated__/CreateOrganizationPageCreateOrganizationMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<75687d4b60d4ae79658fffb99ea6f52b>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type CreateOrganizationInput = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
export type CreateOrganizationPageCreateOrganizationMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
|
input: CreateOrganizationInput;
|
||||||
|
};
|
||||||
|
export type CreateOrganizationPageCreateOrganizationMutation$data = {
|
||||||
|
readonly createOrganization: {
|
||||||
|
readonly organizationEdge: {
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly logoUrl: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type CreateOrganizationPageCreateOrganizationMutation = {
|
||||||
|
response: CreateOrganizationPageCreateOrganizationMutation$data;
|
||||||
|
variables: CreateOrganizationPageCreateOrganizationMutation$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,
|
||||||
|
"concreteType": "OrganizationEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "organizationEdge",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Organization",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "logoUrl",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "CreateOrganizationPageCreateOrganizationMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateOrganizationPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createOrganization",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "CreateOrganizationPageCreateOrganizationMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateOrganizationPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createOrganization",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "appendEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "organizationEdge",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "aa445272c59c25a9a2edc7592c1fd7cc",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "CreateOrganizationPageCreateOrganizationMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation CreateOrganizationPageCreateOrganizationMutation(\n $input: CreateOrganizationInput!\n) {\n createOrganization(input: $input) {\n organizationEdge {\n node {\n id\n name\n logoUrl\n }\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "ec0da70244afe2faa02b05ee418b829e";
|
||||||
|
|
||||||
|
export default node;
|
||||||
74
apps/console/src/pages/__generated__/CreateOrganizationPageViewerQuery.graphql.ts
generated
Normal file
74
apps/console/src/pages/__generated__/CreateOrganizationPageViewerQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<91e1415ad0a7d8ee0ae2a8e212f42f19>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type CreateOrganizationPageViewerQuery$variables = Record<PropertyKey, never>;
|
||||||
|
export type CreateOrganizationPageViewerQuery$data = {
|
||||||
|
readonly viewer: {
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type CreateOrganizationPageViewerQuery = {
|
||||||
|
response: CreateOrganizationPageViewerQuery$data;
|
||||||
|
variables: CreateOrganizationPageViewerQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "User",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "viewer",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "CreateOrganizationPageViewerQuery",
|
||||||
|
"selections": (v0/*: any*/),
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "CreateOrganizationPageViewerQuery",
|
||||||
|
"selections": (v0/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "8bb495e88bada2ffda332ffbc11f3340",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "CreateOrganizationPageViewerQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query CreateOrganizationPageViewerQuery {\n viewer {\n id\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "2341c7947749857243e9f492235dfd61";
|
||||||
|
|
||||||
|
export default node;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<17467071cb25b3e291532a4fb9074d67>>
|
* @generated SignedSource<<f40d67f614a103849ba940fbd14f71af>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -16,7 +16,9 @@ export type HomePageQuery$variables = Record<PropertyKey, never>;
|
|||||||
export type HomePageQuery$data = {
|
export type HomePageQuery$data = {
|
||||||
readonly viewer: {
|
readonly viewer: {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly organizations: ReadonlyArray<{
|
readonly organizations: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
readonly createdAt: any;
|
readonly createdAt: any;
|
||||||
readonly frameworks: {
|
readonly frameworks: {
|
||||||
readonly edges: ReadonlyArray<{
|
readonly edges: ReadonlyArray<{
|
||||||
@@ -124,8 +126,10 @@ export type HomePageQuery$data = {
|
|||||||
};
|
};
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export type HomePageQuery = {
|
export type HomePageQuery = {
|
||||||
response: HomePageQuery$data;
|
response: HomePageQuery$data;
|
||||||
@@ -624,10 +628,26 @@ return {
|
|||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "Organization",
|
"concreteType": "OrganizationConnection",
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "organizations",
|
"name": "organizations",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "OrganizationEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
"plural": true,
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Organization",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v1/*: any*/),
|
(v1/*: any*/),
|
||||||
(v2/*: any*/),
|
(v2/*: any*/),
|
||||||
@@ -642,6 +662,12 @@ return {
|
|||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
"type": "Query",
|
"type": "Query",
|
||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
},
|
},
|
||||||
@@ -663,10 +689,26 @@ return {
|
|||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "Organization",
|
"concreteType": "OrganizationConnection",
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "organizations",
|
"name": "organizations",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "OrganizationEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
"plural": true,
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Organization",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v1/*: any*/),
|
(v1/*: any*/),
|
||||||
(v2/*: any*/),
|
(v2/*: any*/),
|
||||||
@@ -681,19 +723,25 @@ return {
|
|||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "d40cf8a4787ed129284c566abd99fdaf",
|
"cacheID": "5a56fefd066703ca0ebac1ef3e9a7e1f",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "HomePageQuery",
|
"name": "HomePageQuery",
|
||||||
"operationKind": "query",
|
"operationKind": "query",
|
||||||
"text": "query HomePageQuery {\n viewer {\n id\n organizations {\n name\n createdAt\n updatedAt\n vendors {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n }\n }\n }\n peoples {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n createdAt\n updatedAt\n }\n }\n }\n frameworks {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n name\n description\n controls {\n edges {\n node {\n id\n name\n state\n stateTransisions {\n edges {\n node {\n id\n toState\n fromState\n createdAt\n updatedAt\n }\n }\n }\n tasks {\n edges {\n node {\n id\n name\n state\n evidences {\n edges {\n node {\n id\n state\n fileUrl\n stateTransisions {\n edges {\n node {\n id\n fromState\n toState\n reason\n createdAt\n updatedAt\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n stateTransisions {\n edges {\n node {\n id\n toState\n fromState\n reason\n createdAt\n updatedAt\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n }\n }\n }\n }\n }\n }\n id\n }\n }\n}\n"
|
"text": "query HomePageQuery {\n viewer {\n id\n organizations {\n edges {\n node {\n name\n createdAt\n updatedAt\n vendors {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n }\n }\n }\n peoples {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n createdAt\n updatedAt\n }\n }\n }\n frameworks {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n name\n description\n controls {\n edges {\n node {\n id\n name\n state\n stateTransisions {\n edges {\n node {\n id\n toState\n fromState\n createdAt\n updatedAt\n }\n }\n }\n tasks {\n edges {\n node {\n id\n name\n state\n evidences {\n edges {\n node {\n id\n state\n fileUrl\n stateTransisions {\n edges {\n node {\n id\n fromState\n toState\n reason\n createdAt\n updatedAt\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n stateTransisions {\n edges {\n node {\n id\n toState\n fromState\n reason\n createdAt\n updatedAt\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n }\n }\n }\n }\n }\n }\n id\n }\n }\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "e9da69d4e7095f003eb28bf51e7c399d";
|
(node as any).hash = "7a1699535af738f939d954a88c6daa9e";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<f2e46ea14241587a319e9a6af9072bb9>>
|
* @generated SignedSource<<9a5ce377f093c4bbbb2375aacc373fb0>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -9,14 +9,14 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
|
|
||||||
import { ConcreteRequest } from 'relay-runtime';
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
export type SettingsPageQuery$variables = Record<PropertyKey, never>;
|
export type SettingsPageQuery$variables = {
|
||||||
|
organizationID: string;
|
||||||
|
};
|
||||||
export type SettingsPageQuery$data = {
|
export type SettingsPageQuery$data = {
|
||||||
readonly viewer: {
|
readonly organization: {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly organizations: ReadonlyArray<{
|
readonly logoUrl?: string;
|
||||||
readonly logoUrl: string;
|
readonly name?: string;
|
||||||
readonly name: string;
|
|
||||||
}>;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export type SettingsPageQuery = {
|
export type SettingsPageQuery = {
|
||||||
@@ -25,56 +25,65 @@ export type SettingsPageQuery = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const node: ConcreteRequest = (function(){
|
const node: ConcreteRequest = (function(){
|
||||||
var v0 = {
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationID"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationID"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
},
|
},
|
||||||
v1 = {
|
v3 = {
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
},
|
},
|
||||||
v2 = {
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "logoUrl",
|
"name": "logoUrl",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
"fragment": {
|
"fragment": {
|
||||||
"argumentDefinitions": [],
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
"kind": "Fragment",
|
"kind": "Fragment",
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"name": "SettingsPageQuery",
|
"name": "SettingsPageQuery",
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": "organization",
|
||||||
"args": null,
|
"args": (v1/*: any*/),
|
||||||
"concreteType": "User",
|
"concreteType": null,
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "viewer",
|
"name": "node",
|
||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v0/*: any*/),
|
(v2/*: any*/),
|
||||||
{
|
(v3/*: any*/)
|
||||||
"alias": null,
|
|
||||||
"args": null,
|
|
||||||
"concreteType": "Organization",
|
|
||||||
"kind": "LinkedField",
|
|
||||||
"name": "organizations",
|
|
||||||
"plural": true,
|
|
||||||
"selections": [
|
|
||||||
(v1/*: any*/),
|
|
||||||
(v2/*: any*/)
|
|
||||||
],
|
|
||||||
"storageKey": null
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
@@ -84,49 +93,43 @@ return {
|
|||||||
},
|
},
|
||||||
"kind": "Request",
|
"kind": "Request",
|
||||||
"operation": {
|
"operation": {
|
||||||
"argumentDefinitions": [],
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
"kind": "Operation",
|
"kind": "Operation",
|
||||||
"name": "SettingsPageQuery",
|
"name": "SettingsPageQuery",
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": "organization",
|
||||||
"args": null,
|
"args": (v1/*: any*/),
|
||||||
"concreteType": "User",
|
"concreteType": null,
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "viewer",
|
"name": "node",
|
||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v0/*: any*/),
|
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "Organization",
|
"kind": "ScalarField",
|
||||||
"kind": "LinkedField",
|
"name": "__typename",
|
||||||
"name": "organizations",
|
|
||||||
"plural": true,
|
|
||||||
"selections": [
|
|
||||||
(v1/*: any*/),
|
|
||||||
(v2/*: any*/),
|
|
||||||
(v0/*: any*/)
|
|
||||||
],
|
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
},
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "5a3f5c431e1f886a330d220fd33a33f3",
|
"cacheID": "1ff42392cdd403c92101dc9c5fb7ceda",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "SettingsPageQuery",
|
"name": "SettingsPageQuery",
|
||||||
"operationKind": "query",
|
"operationKind": "query",
|
||||||
"text": "query SettingsPageQuery {\n viewer {\n id\n organizations {\n name\n logoUrl\n id\n }\n }\n}\n"
|
"text": "query SettingsPageQuery(\n $organizationID: ID!\n) {\n organization: node(id: $organizationID) {\n __typename\n id\n ... on Organization {\n name\n logoUrl\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "cef332dd829051516fa47315c3a60d1f";
|
(node as any).hash = "60cdb8a35f7e5f58536101243b57e57c";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -85,6 +85,16 @@ type PageInfo {
|
|||||||
endCursor: CursorKey
|
endCursor: CursorKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OrganizationConnection {
|
||||||
|
edges: [OrganizationEdge!]!
|
||||||
|
pageInfo: PageInfo!
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrganizationEdge {
|
||||||
|
cursor: CursorKey!
|
||||||
|
node: Organization!
|
||||||
|
}
|
||||||
|
|
||||||
type Organization implements Node {
|
type Organization implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
@@ -342,13 +352,17 @@ type EvidenceStateTransition {
|
|||||||
updatedAt: Datetime!
|
updatedAt: Datetime!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Authentication types
|
type User implements Node {
|
||||||
type User {
|
|
||||||
id: ID!
|
id: ID!
|
||||||
fullName: String!
|
fullName: String!
|
||||||
email: String!
|
email: String!
|
||||||
|
|
||||||
organizations: [Organization!]! @goField(forceResolver: true)
|
organizations(
|
||||||
|
first: Int
|
||||||
|
after: CursorKey
|
||||||
|
last: Int
|
||||||
|
before: CursorKey
|
||||||
|
): OrganizationConnection! @goField(forceResolver: true)
|
||||||
|
|
||||||
createdAt: Datetime!
|
createdAt: Datetime!
|
||||||
updatedAt: Datetime!
|
updatedAt: Datetime!
|
||||||
@@ -371,6 +385,12 @@ type Mutation {
|
|||||||
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
||||||
updatePeople(input: UpdatePeopleInput!): People!
|
updatePeople(input: UpdatePeopleInput!): People!
|
||||||
deletePeople(input: DeletePeopleInput!): DeletePeoplePayload!
|
deletePeople(input: DeletePeopleInput!): DeletePeoplePayload!
|
||||||
|
createOrganization(
|
||||||
|
input: CreateOrganizationInput!
|
||||||
|
): CreateOrganizationPayload!
|
||||||
|
deleteOrganization(
|
||||||
|
input: DeleteOrganizationInput!
|
||||||
|
): DeleteOrganizationPayload!
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateVendorInput {
|
input CreateVendorInput {
|
||||||
@@ -474,3 +494,19 @@ type DeleteVendorPayload {
|
|||||||
type DeletePeoplePayload {
|
type DeletePeoplePayload {
|
||||||
deletedPeopleId: ID!
|
deletedPeopleId: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input CreateOrganizationInput {
|
||||||
|
name: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
input DeleteOrganizationInput {
|
||||||
|
organizationId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateOrganizationPayload {
|
||||||
|
organizationEdge: OrganizationEdge!
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteOrganizationPayload {
|
||||||
|
deletedOrganizationId: ID!
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -27,3 +27,9 @@ func NewOrganization(o *coredata.Organization) *Organization {
|
|||||||
UpdatedAt: o.UpdatedAt,
|
UpdatedAt: o.UpdatedAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewOrganizationEdge(o *coredata.Organization) *OrganizationEdge {
|
||||||
|
return &OrganizationEdge{
|
||||||
|
Node: NewOrganization(o),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ type ControlStateTransitionEdge struct {
|
|||||||
Node *ControlStateTransition `json:"node"`
|
Node *ControlStateTransition `json:"node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateOrganizationInput struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateOrganizationPayload struct {
|
||||||
|
OrganizationEdge *OrganizationEdge `json:"organizationEdge"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreatePeopleInput struct {
|
type CreatePeopleInput struct {
|
||||||
OrganizationID gid.GID `json:"organizationId"`
|
OrganizationID gid.GID `json:"organizationId"`
|
||||||
FullName string `json:"fullName"`
|
FullName string `json:"fullName"`
|
||||||
@@ -88,6 +96,14 @@ type CreateVendorPayload struct {
|
|||||||
VendorEdge *VendorEdge `json:"vendorEdge"`
|
VendorEdge *VendorEdge `json:"vendorEdge"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteOrganizationInput struct {
|
||||||
|
OrganizationID gid.GID `json:"organizationId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteOrganizationPayload struct {
|
||||||
|
DeletedOrganizationID gid.GID `json:"deletedOrganizationId"`
|
||||||
|
}
|
||||||
|
|
||||||
type DeletePeopleInput struct {
|
type DeletePeopleInput struct {
|
||||||
PeopleID gid.GID `json:"peopleId"`
|
PeopleID gid.GID `json:"peopleId"`
|
||||||
}
|
}
|
||||||
@@ -186,6 +202,16 @@ type Organization struct {
|
|||||||
func (Organization) IsNode() {}
|
func (Organization) IsNode() {}
|
||||||
func (this Organization) GetID() gid.GID { return this.ID }
|
func (this Organization) GetID() gid.GID { return this.ID }
|
||||||
|
|
||||||
|
type OrganizationConnection struct {
|
||||||
|
Edges []*OrganizationEdge `json:"edges"`
|
||||||
|
PageInfo *PageInfo `json:"pageInfo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrganizationEdge struct {
|
||||||
|
Cursor page.CursorKey `json:"cursor"`
|
||||||
|
Node *Organization `json:"node"`
|
||||||
|
}
|
||||||
|
|
||||||
type PageInfo struct {
|
type PageInfo struct {
|
||||||
HasNextPage bool `json:"hasNextPage"`
|
HasNextPage bool `json:"hasNextPage"`
|
||||||
HasPreviousPage bool `json:"hasPreviousPage"`
|
HasPreviousPage bool `json:"hasPreviousPage"`
|
||||||
@@ -295,11 +321,14 @@ type User struct {
|
|||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
FullName string `json:"fullName"`
|
FullName string `json:"fullName"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Organizations []*Organization `json:"organizations"`
|
Organizations *OrganizationConnection `json:"organizations"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (User) IsNode() {}
|
||||||
|
func (this User) GetID() gid.GID { return this.ID }
|
||||||
|
|
||||||
type Vendor struct {
|
type Vendor struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|||||||
@@ -169,6 +169,30 @@ func (r *mutationResolver) DeletePeople(ctx context.Context, input types.DeleteP
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateOrganization is the resolver for the createOrganization field.
|
||||||
|
func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.CreateOrganizationInput) (*types.CreateOrganizationPayload, error) {
|
||||||
|
organization, err := r.proboSvc.CreateOrganization(ctx, probo.CreateOrganizationRequest{
|
||||||
|
Name: input.Name,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot create organization: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = r.usrmgrSvc.AddUserToOrganization(ctx, UserFromContext(ctx).ID, organization.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot add user to organization: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.CreateOrganizationPayload{
|
||||||
|
OrganizationEdge: types.NewOrganizationEdge(organization),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrganization is the resolver for the deleteOrganization field.
|
||||||
|
func (r *mutationResolver) DeleteOrganization(ctx context.Context, input types.DeleteOrganizationInput) (*types.DeleteOrganizationPayload, error) {
|
||||||
|
panic(fmt.Errorf("not implemented: DeleteOrganization - deleteOrganization"))
|
||||||
|
}
|
||||||
|
|
||||||
// Frameworks is the resolver for the frameworks field.
|
// Frameworks is the resolver for the frameworks field.
|
||||||
func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.FrameworkConnection, error) {
|
func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.FrameworkConnection, error) {
|
||||||
cursor := types.NewCursor(first, after, last, before)
|
cursor := types.NewCursor(first, after, last, before)
|
||||||
@@ -300,29 +324,35 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Organizations is the resolver for the organizations field.
|
// Organizations is the resolver for the organizations field.
|
||||||
func (r *userResolver) Organizations(ctx context.Context, obj *types.User) ([]*types.Organization, error) {
|
func (r *userResolver) Organizations(ctx context.Context, obj *types.User, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.OrganizationConnection, error) {
|
||||||
// Get the user's organization IDs
|
// Get the user's organization IDs
|
||||||
organizationIDs, err := r.usrmgrSvc.GetUserOrganizations(ctx, obj.ID)
|
organizationIDs, err := r.usrmgrSvc.GetUserOrganizations(ctx, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get user organizations: %w", err)
|
return nil, fmt.Errorf("failed to get user organizations: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user doesn't have any organizations, return an empty slice
|
// If the user doesn't have any organizations, return an empty connection
|
||||||
if len(organizationIDs) == 0 {
|
if len(organizationIDs) == 0 {
|
||||||
return []*types.Organization{}, nil
|
return &types.OrganizationConnection{
|
||||||
|
Edges: []*types.OrganizationEdge{},
|
||||||
|
PageInfo: &types.PageInfo{},
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the organization details for each organization ID
|
// Get the organization details for each organization ID
|
||||||
var organizations []*types.Organization
|
var edges []*types.OrganizationEdge
|
||||||
for _, organizationID := range organizationIDs {
|
for _, organizationID := range organizationIDs {
|
||||||
organization, err := r.proboSvc.GetOrganization(ctx, organizationID)
|
organization, err := r.proboSvc.GetOrganization(ctx, organizationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get organization details: %w", err)
|
return nil, fmt.Errorf("failed to get organization details: %w", err)
|
||||||
}
|
}
|
||||||
organizations = append(organizations, types.NewOrganization(organization))
|
edges = append(edges, types.NewOrganizationEdge(organization))
|
||||||
}
|
}
|
||||||
|
|
||||||
return organizations, nil
|
return &types.OrganizationConnection{
|
||||||
|
Edges: edges,
|
||||||
|
PageInfo: &types.PageInfo{},
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control returns schema.ControlResolver implementation.
|
// Control returns schema.ControlResolver implementation.
|
||||||
|
|||||||
@@ -82,3 +82,33 @@ LIMIT 1;
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Organization) Insert(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
INSERT INTO organizations (
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
logo_url,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (@id, @name, @logo_url, @created_at, @updated_at)
|
||||||
|
`
|
||||||
|
|
||||||
|
args := pgx.NamedArgs{
|
||||||
|
"id": o.ID,
|
||||||
|
"name": o.Name,
|
||||||
|
"logo_url": o.LogoURL,
|
||||||
|
"created_at": o.CreatedAt,
|
||||||
|
"updated_at": o.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
66
pkg/probo/create_organization.go
Normal file
66
pkg/probo/create_organization.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
// 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 probo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/probo/coredata"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
CreateOrganizationRequest struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s Service) CreateOrganization(
|
||||||
|
ctx context.Context,
|
||||||
|
req CreateOrganizationRequest,
|
||||||
|
) (*coredata.Organization, error) {
|
||||||
|
now := time.Now()
|
||||||
|
organizationID, err := gid.NewGID(coredata.OrganizationEntityType)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot create organization global id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
organization := &coredata.Organization{
|
||||||
|
ID: organizationID,
|
||||||
|
Name: req.Name,
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
if err := organization.Insert(ctx, conn); err != nil {
|
||||||
|
return fmt.Errorf("cannot insert control: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organization, nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user