Expose permission field on each core schema node implementation
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -15,22 +15,11 @@
|
||||
"eagerEsModules": true,
|
||||
"noFutureProofEnums": true,
|
||||
"output": "apps/console/src/__generated__/core",
|
||||
"relativizeJsModulePaths": false,
|
||||
"excludesExtensions": ["*.iam.ts"]
|
||||
},
|
||||
"inline-iam": {
|
||||
"base": "core",
|
||||
"schema": "pkg/server/api/connect/v1/schema.graphql",
|
||||
"language": "typescript",
|
||||
"eagerEsModules": true,
|
||||
"noFutureProofEnums": true,
|
||||
"output": "apps/console/src/__generated__/iam",
|
||||
"relativizeJsModulePaths": false,
|
||||
"excludesExtensions": ["*.tsx", "**/hooks/**.ts"]
|
||||
"relativizeJsModulePaths": false
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"apps/console/src/pages/iam": "iam",
|
||||
"apps/console/src": ["core", "inline-iam"]
|
||||
"apps/console/src": "core"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<efdbeab080fabb165a3a169fbedf3d8f>>
|
||||
* @generated SignedSource<<ab516d36b92795ed8d94d69153957f93>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -12,6 +12,7 @@ import { ReaderFragment } from 'relay-runtime';
|
||||
export type SSLStatus = "ACTIVE" | "EXPIRED" | "FAILED" | "PENDING" | "PROVISIONING" | "RENEWING";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type DomainCardFragment$data = {
|
||||
readonly canDelete: boolean;
|
||||
readonly domain: string;
|
||||
readonly sslStatus: SSLStatus;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"DomainDialogFragment">;
|
||||
@@ -42,6 +43,19 @@ const node: ReaderFragment = {
|
||||
"name": "sslStatus",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:custom-domain:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:custom-domain:delete\")"
|
||||
},
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
@@ -52,6 +66,6 @@ const node: ReaderFragment = {
|
||||
"abstractKey": null
|
||||
};
|
||||
|
||||
(node as any).hash = "672098f5351cf031d958263155e180ac";
|
||||
(node as any).hash = "91cc7871d5ac257f2540568a9a10ce0f";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<04a0aa6648637fd8e81b371ffd8ef9fb>>
|
||||
* @generated SignedSource<<ad1c20b90e9f5335bbcd703dc4e19963>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -16,6 +16,7 @@ export type DomainSettingsPageQuery$variables = {
|
||||
export type DomainSettingsPageQuery$data = {
|
||||
readonly organization: {
|
||||
readonly __typename: "Organization";
|
||||
readonly canCreateCustomDomain: boolean;
|
||||
readonly customDomain: {
|
||||
readonly domain: string;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"DomainCardFragment">;
|
||||
@@ -62,6 +63,19 @@ v3 = {
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"alias": "canCreateCustomDomain",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:custom-domain:create"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:custom-domain:create\")"
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
@@ -88,6 +102,7 @@ return {
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -96,7 +111,7 @@ return {
|
||||
"name": "customDomain",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
@@ -135,6 +150,7 @@ return {
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -143,7 +159,7 @@ return {
|
||||
"name": "customDomain",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -151,6 +167,19 @@ return {
|
||||
"name": "sslStatus",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:custom-domain:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:custom-domain:delete\")"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -232,16 +261,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "561dce9d969f951c2c5b0a2a5fecf29a",
|
||||
"cacheID": "36529612fbe4366a7344b405031da1d1",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "DomainSettingsPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query DomainSettingsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n customDomain {\n domain\n ...DomainCardFragment\n id\n }\n }\n id\n }\n}\n\nfragment DomainCardFragment on CustomDomain {\n domain\n sslStatus\n ...DomainDialogFragment\n}\n\nfragment DomainDialogFragment on CustomDomain {\n sslStatus\n domain\n dnsRecords {\n type\n name\n value\n ttl\n purpose\n }\n createdAt\n updatedAt\n sslExpiresAt\n}\n"
|
||||
"text": "query DomainSettingsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n canCreateCustomDomain: permission(action: \"core:custom-domain:create\")\n customDomain {\n domain\n ...DomainCardFragment\n id\n }\n }\n id\n }\n}\n\nfragment DomainCardFragment on CustomDomain {\n domain\n sslStatus\n canDelete: permission(action: \"core:custom-domain:delete\")\n ...DomainDialogFragment\n}\n\nfragment DomainDialogFragment on CustomDomain {\n sslStatus\n domain\n dnsRecords {\n type\n name\n value\n ttl\n purpose\n }\n createdAt\n updatedAt\n sslExpiresAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "6b7bab65eca55ec2f132cd5944fe874e";
|
||||
(node as any).hash = "75275e2fc7e7156cdf3059b8f0d4f60d";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
/**
|
||||
* @generated SignedSource<<2c18e7bff6b76551479def8a10cce183>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type domainSettingsPage_permissionsQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type domainSettingsPage_permissionsQuery$data = {
|
||||
readonly viewer: {
|
||||
readonly canCreateCustomDomain: boolean;
|
||||
readonly canDeleteCustomDomain: boolean;
|
||||
};
|
||||
};
|
||||
export type domainSettingsPage_permissionsQuery = {
|
||||
response: domainSettingsPage_permissionsQuery$data;
|
||||
variables: domainSettingsPage_permissionsQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "organizationId"
|
||||
}
|
||||
],
|
||||
v1 = {
|
||||
"kind": "Variable",
|
||||
"name": "id",
|
||||
"variableName": "organizationId"
|
||||
},
|
||||
v2 = {
|
||||
"alias": "canCreateCustomDomain",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:custom-domain:create"
|
||||
},
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": "canDeleteCustomDomain",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:custom-domain:delete"
|
||||
},
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "domainSettingsPage_permissionsQuery",
|
||||
"selections": [
|
||||
{
|
||||
"kind": "RequiredField",
|
||||
"field": {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Identity",
|
||||
"kind": "LinkedField",
|
||||
"name": "viewer",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
"action": "THROW"
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "domainSettingsPage_permissionsQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Identity",
|
||||
"kind": "LinkedField",
|
||||
"name": "viewer",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "bb016bc1f53b609efc4ac93a93653d08",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "domainSettingsPage_permissionsQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query domainSettingsPage_permissionsQuery(\n $organizationId: ID!\n) {\n viewer {\n canCreateCustomDomain: permission(action: \"core:custom-domain:create\", id: $organizationId)\n canDeleteCustomDomain: permission(action: \"core:custom-domain:delete\", id: $organizationId)\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "f09bdc9336bf1ad1339bb3b60987f53f";
|
||||
|
||||
export default node;
|
||||
@@ -5,8 +5,6 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { DomainCard } from "./_components/DomainCard";
|
||||
import { NewDomainDialog } from "./_components/NewDomainDialog";
|
||||
import { Button, Card, IconPlusLarge } from "@probo/ui";
|
||||
import { PermissionsContext } from "/providers/NewPermissionsContext";
|
||||
import { use } from "react";
|
||||
|
||||
export const domainSettingsPageQuery = graphql`
|
||||
query DomainSettingsPageQuery($organizationId: ID!) {
|
||||
@@ -14,6 +12,7 @@ export const domainSettingsPageQuery = graphql`
|
||||
__typename
|
||||
... on Organization {
|
||||
id
|
||||
canCreateCustomDomain: permission(action: "core:custom-domain:create")
|
||||
customDomain {
|
||||
domain
|
||||
...DomainCardFragment
|
||||
@@ -29,7 +28,6 @@ export function DomainSettingsPage(props: {
|
||||
const { queryRef } = props;
|
||||
|
||||
const { __ } = useTranslate();
|
||||
const { canCreateCustomDomain } = use(PermissionsContext);
|
||||
|
||||
const { organization } = usePreloadedQuery<DomainSettingsPageQuery>(
|
||||
domainSettingsPageQuery,
|
||||
@@ -56,7 +54,7 @@ export function DomainSettingsPage(props: {
|
||||
)}
|
||||
</p>
|
||||
<div className="flex justify-center">
|
||||
{canCreateCustomDomain && (
|
||||
{organization.canCreateCustomDomain && (
|
||||
<NewDomainDialog>
|
||||
<Button icon={IconPlusLarge}>{__("Add Domain")}</Button>
|
||||
</NewDomainDialog>
|
||||
|
||||
@@ -7,10 +7,6 @@ import {
|
||||
import { useQueryLoader } from "react-relay";
|
||||
import { CoreRelayProvider } from "/providers/CoreRelayProvider";
|
||||
import type { DomainSettingsPageQuery } from "/__generated__/core/DomainSettingsPageQuery.graphql";
|
||||
import { PermissionsProviderLoader } from "/providers/NewPermissionsProvider";
|
||||
import { IAMRelayProvider } from "/providers/IAMRelayProvider";
|
||||
import { domainSettingsPagePermissionsQuery } from "./domainSettingsPage.iam";
|
||||
import type { domainSettingsPage_permissionsQuery } from "/__generated__/iam/domainSettingsPage_permissionsQuery.graphql";
|
||||
|
||||
function DomainSettingsPageLoader() {
|
||||
const organizationId = useOrganizationId();
|
||||
@@ -33,16 +29,10 @@ function DomainSettingsPageLoader() {
|
||||
|
||||
export default function () {
|
||||
return (
|
||||
<IAMRelayProvider>
|
||||
<PermissionsProviderLoader<domainSettingsPage_permissionsQuery>
|
||||
query={domainSettingsPagePermissionsQuery}
|
||||
>
|
||||
<CoreRelayProvider>
|
||||
<Suspense>
|
||||
<DomainSettingsPageLoader />
|
||||
</Suspense>
|
||||
</CoreRelayProvider>
|
||||
</PermissionsProviderLoader>
|
||||
</IAMRelayProvider>
|
||||
<CoreRelayProvider>
|
||||
<Suspense>
|
||||
<DomainSettingsPageLoader />
|
||||
</Suspense>
|
||||
</CoreRelayProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@ import { graphql } from "relay-runtime";
|
||||
import { useFragment } from "react-relay";
|
||||
import type { DomainCardFragment$key } from "/__generated__/core/DomainCardFragment.graphql";
|
||||
import { DeleteDomainDialog } from "./DeleteDomainDialog";
|
||||
import { use } from "react";
|
||||
import { PermissionsContext } from "/providers/NewPermissionsContext";
|
||||
|
||||
const fragment = graphql`
|
||||
fragment DomainCardFragment on CustomDomain {
|
||||
domain
|
||||
sslStatus
|
||||
canDelete: permission(action: "core:custom-domain:delete")
|
||||
...DomainDialogFragment
|
||||
}
|
||||
`;
|
||||
@@ -24,7 +23,6 @@ export function DomainCard(props: { fKey: DomainCardFragment$key }) {
|
||||
const { fKey } = props;
|
||||
|
||||
const { __ } = useTranslate();
|
||||
const { canDeleteCustomDomain } = use(PermissionsContext);
|
||||
|
||||
const domain = useFragment<DomainCardFragment$key>(fragment, fKey);
|
||||
|
||||
@@ -53,7 +51,7 @@ export function DomainCard(props: { fKey: DomainCardFragment$key }) {
|
||||
<Button variant="secondary">{__("View Details")}</Button>
|
||||
</DomainDialog>
|
||||
|
||||
{canDeleteCustomDomain && (
|
||||
{domain.canDelete && (
|
||||
<DeleteDomainDialog domain={domain.domain}>
|
||||
<Button variant="danger">{__("Delete")}</Button>
|
||||
</DeleteDomainDialog>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { graphql } from "relay-runtime";
|
||||
|
||||
export const domainSettingsPagePermissionsQuery = graphql`
|
||||
query domainSettingsPage_permissionsQuery($organizationId: ID!) {
|
||||
viewer @required(action: THROW) {
|
||||
canCreateCustomDomain: permission(
|
||||
action: "core:custom-domain:create"
|
||||
id: $organizationId
|
||||
)
|
||||
canDeleteCustomDomain: permission(
|
||||
action: "core:custom-domain:delete"
|
||||
id: $organizationId
|
||||
)
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -7,7 +7,7 @@ import { fileURLToPath, URL } from "node:url";
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react({
|
||||
exclude: ["src/pages/iam/**/*", "src/pages/**/*.iam.ts"],
|
||||
exclude: ["src/pages/iam/**/*"],
|
||||
babel: {
|
||||
plugins: [
|
||||
[
|
||||
@@ -21,7 +21,7 @@ export default defineConfig({
|
||||
},
|
||||
}),
|
||||
react({
|
||||
include: ["src/pages/iam/**/*", "src/pages/**/*.iam.ts"],
|
||||
include: ["src/pages/iam/**/*"],
|
||||
babel: {
|
||||
plugins: [
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user