mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
Fix Policy view for Project and Target (#4435)
This commit is contained in:
parent
3ad479adbd
commit
bba88bdb5e
4 changed files with 28 additions and 13 deletions
|
|
@ -81,6 +81,7 @@ export default gql`
|
|||
|
||||
extend type Project {
|
||||
schemaPolicy: SchemaPolicy
|
||||
parentSchemaPolicy: SchemaPolicy
|
||||
}
|
||||
|
||||
extend type Target {
|
||||
|
|
|
|||
|
|
@ -176,6 +176,15 @@ export class SchemaPolicyProvider {
|
|||
return this.storage.getSchemaPolicyForOrganization(selector.organization);
|
||||
}
|
||||
|
||||
async getOrganizationPolicyForProject(selector: ProjectSelector) {
|
||||
await this.authManager.ensureProjectAccess({
|
||||
...selector,
|
||||
scope: ProjectAccessScope.SETTINGS,
|
||||
});
|
||||
|
||||
return this.storage.getSchemaPolicyForOrganization(selector.organization);
|
||||
}
|
||||
|
||||
async getProjectPolicy(selector: ProjectSelector) {
|
||||
await this.authManager.ensureProjectAccess({
|
||||
...selector,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ export const resolvers: PolicyModule.Resolvers = {
|
|||
project: project.id,
|
||||
organization: project.orgId,
|
||||
}),
|
||||
parentSchemaPolicy: async (project, _, { injector }) =>
|
||||
injector.get(SchemaPolicyProvider).getOrganizationPolicyForProject({
|
||||
project: project.id,
|
||||
organization: project.orgId,
|
||||
}),
|
||||
},
|
||||
Target: {
|
||||
schemaPolicy: async (target, _, { injector }) => {
|
||||
|
|
|
|||
|
|
@ -17,16 +17,6 @@ const ProjectPolicyPageQuery = graphql(`
|
|||
organization(selector: { organization: $organizationId }) {
|
||||
organization {
|
||||
id
|
||||
schemaPolicy {
|
||||
id
|
||||
updatedAt
|
||||
allowOverrides
|
||||
rules {
|
||||
rule {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
me {
|
||||
id
|
||||
...CanAccessProject_MemberFragment
|
||||
|
|
@ -43,6 +33,16 @@ const ProjectPolicyPageQuery = graphql(`
|
|||
updatedAt
|
||||
...PolicySettings_SchemaPolicyFragment
|
||||
}
|
||||
parentSchemaPolicy {
|
||||
id
|
||||
updatedAt
|
||||
allowOverrides
|
||||
rules {
|
||||
rule {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
organizations {
|
||||
...ProjectLayout_OrganizationConnectionFragment
|
||||
|
|
@ -160,11 +160,11 @@ function ProjectPolicyContent() {
|
|||
)}
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{currentOrganization.schemaPolicy === null ||
|
||||
currentOrganization.schemaPolicy?.allowOverrides ? (
|
||||
{currentProject.parentSchemaPolicy === null ||
|
||||
currentProject.parentSchemaPolicy?.allowOverrides ? (
|
||||
<PolicySettings
|
||||
saving={mutation.fetching}
|
||||
rulesInParent={currentOrganization.schemaPolicy?.rules.map(r => r.rule.id)}
|
||||
rulesInParent={currentProject.parentSchemaPolicy?.rules.map(r => r.rule.id)}
|
||||
error={
|
||||
mutation.error?.message ||
|
||||
mutation.data?.updateSchemaPolicyForProject.error?.message
|
||||
|
|
|
|||
Loading…
Reference in a new issue