Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(User roles) Fix merge issues #7881

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9243,6 +9243,39 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "confirmRegistration",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createBirthRegistration",
"description": null,
Expand Down
13 changes: 12 additions & 1 deletion packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ export type Mutation = {
changeEmail?: Maybe<Scalars['String']>
changePassword?: Maybe<Scalars['String']>
changePhone?: Maybe<Scalars['String']>
confirmRegistration: Scalars['ID']
createBirthRegistration: CreatedIds
createBirthRegistrationCorrection: Scalars['ID']
createDeathRegistration: CreatedIds
Expand Down Expand Up @@ -1190,6 +1191,10 @@ export type MutationChangePhoneArgs = {
verifyCode: Scalars['String']
}

export type MutationConfirmRegistrationArgs = {
id: Scalars['ID']
}

export type MutationCreateBirthRegistrationArgs = {
details: BirthRegistrationInput
}
Expand Down Expand Up @@ -3080,7 +3085,13 @@ export type GetUserQuery = {
} | null
role: {
__typename?: 'UserRole'
_id: string
id: string
label: {
__typename?: 'I18nMessage'
id: string
defaultMessage: string
description: string
}
}
primaryOffice: {
__typename?: 'Location'
Expand Down
13 changes: 6 additions & 7 deletions packages/client/src/views/RecordAudit/ActionMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
SUBMISSION_STATUS
} from '@client/declarations'
import { ActionMenu } from './ActionMenu'
import { Scope } from '@sentry/react'
import { Event } from '@client/utils/gateway'
import { Event, Scope } from '@client/utils/gateway'
import { vi } from 'vitest'

const defaultDeclaration = {
Expand Down Expand Up @@ -75,10 +74,10 @@ const draftDeathNotDownloaded = {
} as unknown as IDeclaration

const SCOPES = {
FA: ['declare'] as any as Scope,
RA: ['validate'] as any as Scope,
REGISTRAR: ['register'] as any as Scope,
NONE: [] as any as Scope
FA: ['declare'] as Scope[],
RA: ['validate'] as Scope[],
REGISTRAR: ['register'] as Scope[],
NONE: [] as Scope[]
}

enum ACTION_STATUS {
Expand Down Expand Up @@ -1077,7 +1076,7 @@ describe('Update action', () => {
})

describe('Archive action', () => {
const ARCHIVE_SCOPES = ['validate', 'register'] as any as Scope
const ARCHIVE_SCOPES = ['validate', 'register'] as Scope[]
it('Draft', async () => {
const { store, history } = createStore()
const component = await createTestComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { waitForElement } from '@client/tests/wait-for-element'
import { ActionPageLight } from '@opencrvs/components/lib/ActionPageLight'
import { History } from 'history'
import { vi, Mock, describe, expect } from 'vitest'
import { GetUserQuery } from '@client/utils/gateway'
import { GetUserQuery, Status } from '@client/utils/gateway'

const mockUsers = {
data: {
Expand Down Expand Up @@ -383,9 +383,15 @@ describe('edit user tests', () => {
username: 'shakib1',
mobile: '+8801662132163',
email: 'jeff@gmail.com',
systemRole: 'NATIONAL_REGISTRAR',
role: { _id: '63ef9466f708ea080777c27a' },
status: 'active',
role: {
id: 'NATIONAL_REGISTRAR',
label: {
id: 'userRoles.nationalRegistrar',
defaultMessage: 'National Registrar',
description: ''
}
},
Comment on lines +386 to +393
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this role supposed to be just the string NATIONAL_REGISTRAR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I regenerated the gateway types and it came back with the label. So Typescript won't compile without it. Possibly need to discuss how we're using that file.

status: Status.Active,
underInvestigation: false,
practitionerId: '94429795-0a09-4de8-8e1e-27dab01877d2',
primaryOffice: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ export const resolvers: GQLResolver = {
return taskEntry.resource.id
},
async confirmRegistration(_, { id }, { headers: authHeader }) {
if (!inScope(authHeader, ['record.confirm-registration'])) {
if (!inScope(authHeader, ['record.register'])) {
throw new Error(
'User does not have a "record.confirm-registration" scope'
)
Expand Down
2 changes: 2 additions & 0 deletions packages/gateway/src/features/user/root-resolvers.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tumbledwyer These were removed as part of this PR: #7697

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
GQLHumanNameInput,
GQLResolver,
GQLSearchFieldAgentResponse,
GQLUserIdentifierInput,
GQLUserInput
} from '@gateway/graphql/schema'
import { checkVerificationCode } from '@gateway/routes/verifyCode/handler'
Expand Down Expand Up @@ -649,6 +650,7 @@ function createOrUpdateUserPayload(
role: user.role as string,
...(user.password && { password: user.password }),
...(user.status && { status: user.status }),
identifiers: (user.identifier as GQLUserIdentifierInput[]) || [],
primaryOfficeId: user.primaryOffice as string,
email: '',
...(user.email && { emailForNotification: user.email }), //instead of saving data in email, we want to store it in emailForNotification property
Expand Down
Loading