Skip to content

Commit

Permalink
Merge branch 'users-gql' into users-gql-refactor-hamburger-conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus authored May 30, 2024
2 parents 758cb36 + 8b8c39c commit 3bb1775
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 173 deletions.
306 changes: 213 additions & 93 deletions catalog/app/containers/Admin/Users/Users.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type UserSelectionFragment = { readonly __typename: 'User' } & Pick<
>)
| ({ readonly __typename: 'ManagedRole' } & Pick<Types.ManagedRole, 'id' | 'name'>)
>
readonly roles: ReadonlyArray<
readonly extraRoles: ReadonlyArray<
| ({ readonly __typename: 'UnmanagedRole' } & Pick<
Types.UnmanagedRole,
'id' | 'name'
Expand Down Expand Up @@ -88,7 +88,7 @@ export const UserSelectionFragmentDoc = {
},
{
kind: 'Field',
name: { kind: 'Name', value: 'roles' },
name: { kind: 'Name', value: 'extraRoles' },
selectionSet: {
kind: 'SelectionSet',
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fragment UserSelection on User {
name
}
}
roles {
extraRoles {
__typename
... on ManagedRole {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import {
UserResultSelectionFragmentDoc,
} from './UserResultSelection.generated'

export type containers_Admin_Users_gql_UserSetRolesMutationVariables = Types.Exact<{
export type containers_Admin_Users_gql_UserSetRoleMutationVariables = Types.Exact<{
name: Types.Scalars['String']
roleNames: ReadonlyArray<Types.Scalars['String']>
activeRoleName: Types.Scalars['String']
role: Types.Scalars['String']
extraRoles: ReadonlyArray<Types.Scalars['String']>
}>

export type containers_Admin_Users_gql_UserSetRolesMutation = {
export type containers_Admin_Users_gql_UserSetRoleMutation = {
readonly __typename: 'Mutation'
} & {
readonly admin: { readonly __typename: 'AdminMutations' } & {
readonly user: { readonly __typename: 'UserAdminMutations' } & {
readonly mutate: Types.Maybe<
{ readonly __typename: 'MutateUserAdminMutations' } & {
readonly setRoles:
readonly setRole:
| ({ readonly __typename: 'User' } & UserResultSelection_User_Fragment)
| ({
readonly __typename: 'InvalidInput'
Expand All @@ -36,13 +36,13 @@ export type containers_Admin_Users_gql_UserSetRolesMutation = {
}
}

export const containers_Admin_Users_gql_UserSetRolesDocument = {
export const containers_Admin_Users_gql_UserSetRoleDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'containers_Admin_Users_gql_UserSetRoles' },
name: { kind: 'Name', value: 'containers_Admin_Users_gql_UserSetRole' },
variableDefinitions: [
{
kind: 'VariableDefinition',
Expand All @@ -54,7 +54,15 @@ export const containers_Admin_Users_gql_UserSetRolesDocument = {
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'roleNames' } },
variable: { kind: 'Variable', name: { kind: 'Name', value: 'role' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'extraRoles' } },
type: {
kind: 'NonNullType',
type: {
Expand All @@ -66,14 +74,6 @@ export const containers_Admin_Users_gql_UserSetRolesDocument = {
},
},
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'activeRoleName' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
Expand Down Expand Up @@ -108,22 +108,22 @@ export const containers_Admin_Users_gql_UserSetRolesDocument = {
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'setRoles' },
name: { kind: 'Name', value: 'setRole' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'roleNames' },
name: { kind: 'Name', value: 'role' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'roleNames' },
name: { kind: 'Name', value: 'role' },
},
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'activeRoleName' },
name: { kind: 'Name', value: 'extraRoles' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'activeRoleName' },
name: { kind: 'Name', value: 'extraRoles' },
},
},
],
Expand Down Expand Up @@ -152,8 +152,8 @@ export const containers_Admin_Users_gql_UserSetRolesDocument = {
...UserResultSelectionFragmentDoc.definitions,
],
} as unknown as DocumentNode<
containers_Admin_Users_gql_UserSetRolesMutation,
containers_Admin_Users_gql_UserSetRolesMutationVariables
containers_Admin_Users_gql_UserSetRoleMutation,
containers_Admin_Users_gql_UserSetRoleMutationVariables
>

export { containers_Admin_Users_gql_UserSetRolesDocument as default }
export { containers_Admin_Users_gql_UserSetRoleDocument as default }
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# import UserResultSelection from "./UserResultSelection.graphql"

mutation ($name: String!, $roleNames: [String!]!, $activeRoleName: String!) {
mutation ($name: String!, $role: String!, $extraRoles: [String!]!) {
admin {
user {
mutate(name: $name) {
setRoles(roleNames: $roleNames, activeRoleName: $activeRoleName) {
setRole(role: $role, extraRoles: $extraRoles) {
...UserResultSelection
}
}
Expand Down
50 changes: 13 additions & 37 deletions catalog/app/model/graphql/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1474,51 +1474,27 @@ export default {
},
args: [
{
name: 'roleName',
type: {
kind: 'SCALAR',
name: 'String',
ofType: null,
},
},
],
},
{
name: 'setRoles',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'UNION',
name: 'UserResult',
ofType: null,
},
},
args: [
{
name: 'roleNames',
name: 'role',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'LIST',
ofType: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'String',
ofType: null,
},
},
kind: 'SCALAR',
name: 'String',
ofType: null,
},
},
},
{
name: 'activeRoleName',
name: 'extraRoles',
type: {
kind: 'NON_NULL',
kind: 'LIST',
ofType: {
kind: 'SCALAR',
name: 'String',
ofType: null,
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'String',
ofType: null,
},
},
},
},
Expand Down Expand Up @@ -5249,7 +5225,7 @@ export default {
args: [],
},
{
name: 'roles',
name: 'extraRoles',
type: {
kind: 'NON_NULL',
ofType: {
Expand Down
14 changes: 5 additions & 9 deletions catalog/app/model/graphql/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export interface MutateUserAdminMutations {
readonly delete: OperationResult
readonly setEmail: UserResult
readonly setRole: UserResult
readonly setRoles: UserResult
readonly setAdmin: UserResult
readonly setActive: UserResult
readonly resetPassword: OperationResult
Expand All @@ -344,12 +343,8 @@ export interface MutateUserAdminMutationssetEmailArgs {
}

export interface MutateUserAdminMutationssetRoleArgs {
roleName: Maybe<Scalars['String']>
}

export interface MutateUserAdminMutationssetRolesArgs {
roleNames: ReadonlyArray<Scalars['String']>
activeRoleName: Scalars['String']
role: Scalars['String']
extraRoles: Maybe<ReadonlyArray<Scalars['String']>>
}

export interface MutateUserAdminMutationssetAdminArgs {
Expand Down Expand Up @@ -1139,7 +1134,7 @@ export interface User {
readonly isSsoOnly: Scalars['Boolean']
readonly isService: Scalars['Boolean']
readonly role: Maybe<Role>
readonly roles: ReadonlyArray<Role>
readonly extraRoles: ReadonlyArray<Role>
}

export interface UserAdminMutations {
Expand Down Expand Up @@ -1169,7 +1164,8 @@ export interface UserAdminQueriesgetArgs {
export interface UserInput {
readonly name: Scalars['String']
readonly email: Scalars['String']
readonly roleName: Maybe<Scalars['String']>
readonly role: Scalars['String']
readonly extraRoles: Maybe<ReadonlyArray<Scalars['String']>>
}

export type UserResult = User | InvalidInput | OperationError
10 changes: 5 additions & 5 deletions shared/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ type User {
isAdmin: Boolean!
isSsoOnly: Boolean!
isService: Boolean!
role: Role # XXX: activeRole?
roles: [Role!]! # XXX: better name
role: Role
extraRoles: [Role!]!
}

type AccessCountForDate {
Expand Down Expand Up @@ -838,16 +838,16 @@ union BrowsingSessionDisposeResult = Ok | OperationError
input UserInput {
name: String!
email: String!
roleName: String
role: String!
extraRoles: [String!]
}

union UserResult = User | InvalidInput | OperationError

type MutateUserAdminMutations {
delete: OperationResult!
setEmail(email: String!): UserResult!
setRole(roleName: String): UserResult!
setRoles(roleNames: [String!]!, activeRoleName: String!): UserResult!
setRole(role: String!, extraRoles: [String!]): UserResult!
setAdmin(admin: Boolean!): UserResult!
setActive(active: Boolean!): UserResult!
resetPassword: OperationResult!
Expand Down

0 comments on commit 3bb1775

Please sign in to comment.