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

Submission Summary V2 with FetchContract #2350

Merged
merged 58 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f8fc4e2
initial commit of resolvers working
macrael Apr 1, 2024
b355084
submitContract can only be called by state user
mojotalantikite Apr 1, 2024
ce369d7
create submissionsummaryv2
pearl-truss Apr 2, 2024
3e45343
create and use v2 version of contract details summary section component
pearl-truss Apr 2, 2024
5836518
temp comment out reviewsubmitv2 for testing
pearl-truss Apr 2, 2024
e2dd1b0
get submitContract working
macrael Apr 2, 2024
a36eb52
add test helpers for contracts, test single linked rate
macrael Apr 3, 2024
0cd849c
fix after linting
macrael Apr 3, 2024
a42ea4b
fix some bugs
macrael Apr 4, 2024
1686aa9
get setup of scenario working
macrael Apr 4, 2024
8201ea0
Wip with handling submit
pearl-truss Apr 4, 2024
0696cae
fix some of the api test
pearl-truss Apr 4, 2024
aa2e7c9
Remove console logs
pearl-truss Apr 4, 2024
ec4cd34
unlock child rates
macrael Apr 4, 2024
609af02
fix linting to deploy review app
pearl-truss Apr 5, 2024
ff4d5b9
add 90% of jason's diagram to test
mojotalantikite Apr 5, 2024
24f8970
get parentContractID into rate and check it
macrael Apr 6, 2024
1b05f8d
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
macrael Apr 6, 2024
c66526b
Create graphql for submitContract and new fetchSubmittedContract
pearl-truss Apr 8, 2024
8dd9b62
remove changes to submitContract postgres func
pearl-truss Apr 8, 2024
c5a1653
remove unneeded changes for this pr
pearl-truss Apr 8, 2024
8a5ca31
remove submitContract graphql from this pr
pearl-truss Apr 8, 2024
9cd0a58
remove submitContract.graphql
pearl-truss Apr 8, 2024
ec9bbc0
fix unlockRate
mojotalantikite Apr 8, 2024
c6ef2c9
assert length
mojotalantikite Apr 8, 2024
cc74d8c
cleaning up tests, adds asserts
mojotalantikite Apr 8, 2024
c342a11
remove fetchSubmittedContract
pearl-truss Apr 9, 2024
5aee09a
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 9, 2024
c6516bf
add loading and error states
pearl-truss Apr 9, 2024
b37f87f
Merge branch 'main' into wml-db-history
macrael Apr 10, 2024
5b28925
migrate to new draftRates
macrael Apr 10, 2024
8d26735
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 15, 2024
7ebbba6
wow everything passes
macrael Apr 15, 2024
f589287
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 15, 2024
4fe6252
code clean up
pearl-truss Apr 15, 2024
dc11a52
fix import
macrael Apr 15, 2024
af49041
comments and fix a hidden build issue
macrael Apr 15, 2024
745da54
skip unmigrated rates
mojotalantikite Apr 16, 2024
23eb6ff
reimplmeent submit
macrael Apr 18, 2024
9f83988
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
macrael Apr 18, 2024
acc5249
rate data mocks
macrael Apr 18, 2024
1d96a2d
add mccrsID to fetchContract query
pearl-truss Apr 18, 2024
78dc953
update v2 unlocksubmit modal to work with unlock contract
pearl-truss Apr 18, 2024
c82d4dc
create changeHistory V2 to use fetchContract, resolve errors
pearl-truss Apr 18, 2024
18043fc
Merge branch 'main' of https://github.com/Enterprise-CMCS/managed-car…
pearl-truss Apr 18, 2024
c456132
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 18, 2024
3b6ac15
get submit working on ReviewSubmit page
pearl-truss Apr 18, 2024
57e2b4a
update contractPackageDataMock
pearl-truss Apr 18, 2024
37c9b04
remove references to packages in unlockSubmitModalV2
pearl-truss Apr 18, 2024
2252971
remove access optioinal chanining
pearl-truss Apr 18, 2024
e3ae827
update changehistoryv2 language and logic
pearl-truss Apr 18, 2024
7ee8429
add submissionsummartV2 for cmsRoutes
pearl-truss Apr 18, 2024
8b09893
fix reviewsubmit test
pearl-truss Apr 18, 2024
7784374
Merge branch 'main' of https://github.com/Enterprise-CMCS/managed-car…
pearl-truss Apr 18, 2024
f555a3b
pr updates
pearl-truss Apr 18, 2024
11d0268
restrict change history to contract actions for now
pearl-truss Apr 18, 2024
5bc2584
fix resubmit
pearl-truss Apr 18, 2024
d9c1df9
add reverse
pearl-truss Apr 18, 2024
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
5 changes: 3 additions & 2 deletions services/app-graphql/src/queries/fetchContract.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
query fetchContract($input: FetchContractInput!) {
fetchContract(input: $input) {
contract {
...contractFields
...contractFieldsFetchContract

draftRevision {
...contractRevisionFragment
Expand All @@ -26,13 +26,14 @@ query fetchContract($input: FetchContractInput!) {
}
}

fragment contractFields on Contract {
fragment contractFieldsFetchContract on Contract {
id
status
createdAt
updatedAt
initiallySubmittedAt
stateCode
mccrsID
state {
code
name
Expand Down
1 change: 1 addition & 0 deletions services/app-graphql/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ type Contract {
This value is used to generate the contractName
"""
stateNumber: Int!
mccrsID: String

"draftRevision is the currently modifiable revision if the rate is DRAFT or UNLOCKED"
draftRevision: ContractRevision
Expand Down
135 changes: 135 additions & 0 deletions services/app-web/src/components/ChangeHistory/ChangeHistoryV2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import React from 'react'
import { dayjs } from '../../common-code/dateHelpers/dayjs'
import { SectionHeader } from '../SectionHeader'
import { Accordion, Link } from '@trussworks/react-uswds'
import type { AccordionItemProps } from '@trussworks/react-uswds/lib/components/Accordion/Accordion'
import { UpdateInformation, Contract } from '../../gen/gqlClient'
import styles from './ChangeHistory.module.scss'
type ChangeHistoryProps = {
contract: Contract
}

type flatRevisions = UpdateInformation & {
kind: 'submit' | 'unlock'
revisionVersion: string | undefined
}

export const ChangeHistoryV2 = ({
contract,
}: ChangeHistoryProps): React.ReactElement => {
const flattenedRevisions = (): flatRevisions[] => {
const result: flatRevisions[] = []
//Reverse revisions to order from earliest to latest revision. This is to correctly set version for each
// contract & recontract.
const reversedRevisions = [...contract.packageSubmissions].reverse()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to put package submissions in time order? I was matching revisions b/c calling contract.packageSubmissions[0] feels like a nice way to always get the most recent submission but could be convinced otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@macrael I think we do if we want to keep the order the same as what currently appears (unless I'm missing something?)
Screenshot 2024-04-18 at 2 50 16 PM

Copy link
Contributor

@haworku haworku Apr 18, 2024

Choose a reason for hiding this comment

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

I don't think so. Multiple pages use that contract.packageSubmissions[0] logic already and its working well. This is edge case - I think it's literally just for that integer in the previous submission urls why we reverse in this order on this one page - everywhere else fine to keep current backend ordering and assume latest first.

Copy link
Contributor

@haworku haworku Apr 18, 2024

Choose a reason for hiding this comment

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

🔍 Is this code working properly with linked rates?

I am under the impression that we would only want contract related package submissions in our change right now. I think at this point we only seek parity with current ChangeHistory display (e.g. even if there are linked rates we are not yet adding in linked rates to change history). The problem I see is right now we are mapping over all the packageSubmissions, won't there be extra fields then in the Change history currently?

I would think we need to filter only contract changes from packageSubmission array into the reversedRevisions array.

Change history work with the full package submissions list is entirely different epic I believe

@macrael can you weigh in?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that if you filtered out all packages that dont have reason: "CONTRACT_SUBMISSION" then you will have the same number of entries as before. That will also give us the correct unlock reasons, we should only ever show unlocks from CONTRACT_SUBMISSION, not from RATE* updates

I definitely want this code to be using packageSubmissions and get off of the old revisions code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@haworku that makes sense to me

Copy link
Contributor

Choose a reason for hiding this comment

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

@pearl-truss sounds like @macrael agrees, we should be filtering only the contract_submission packages here - can you make that change and ignore rate stuff? Otherwise looks good.

reversedRevisions.forEach((r, index) => {
if (r.contractRevision.unlockInfo) {
const newUnlock: flatRevisions = {} as flatRevisions
newUnlock.updatedAt = r.contractRevision.unlockInfo.updatedAt
newUnlock.updatedBy = r.contractRevision.unlockInfo.updatedBy
newUnlock.updatedReason =
r.contractRevision.unlockInfo.updatedReason
newUnlock.kind = 'unlock'
//Use unshift to push the latest revision unlock info to the beginning of the array
result.unshift(newUnlock)
}
if (r.contractRevision.submitInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is necessary b/c it is optional in the types, but just to reiterate every revision in packageSubmissions must have this set.

const newSubmit: flatRevisions = {} as flatRevisions

// Only set revisionVersion if not the latest revision and if not unlocked. This is not the same
// as the order of change history. The version correlates with each submitted revision.
const revisionVersion =
index !== reversedRevisions.length - 1
? String(index + 1) //Offset version, we want to start at 1
: undefined

newSubmit.updatedAt = r.contractRevision.submitInfo.updatedAt
newSubmit.updatedBy = r.contractRevision.submitInfo.updatedBy
newSubmit.updatedReason =
r.contractRevision.submitInfo.updatedReason
newSubmit.kind = 'submit'
newSubmit.revisionVersion = revisionVersion
//Use unshift to push the latest revision submit info to the beginning of the array
result.unshift(newSubmit)
}
})
return result
}

const revisionHistory = flattenedRevisions()

const revisedItems: AccordionItemProps[] = revisionHistory.map(
(r, index) => {
const isInitialSubmission = r.updatedReason === 'Initial contract'
const isSubsequentSubmission = r.kind === 'submit'
// We want to know if this contract has multiple submissions. To have multiple submissions, there must be minimum
// more than the initial contract revision.
const hasSubsequentSubmissions = revisionHistory.length > 1
Copy link
Contributor Author

@pearl-truss pearl-truss Apr 18, 2024

Choose a reason for hiding this comment

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

Previously this was set to >=3:

// We want to know if this package has multiple submissions. 
// To have multiple submissions, there must be minimum
            
// 3 revisions in revisionHistory the initial submission revision, 
// unlock revision and resubmission revision.
            
const hasSubsequentSubmissions = revisionHistory.length >= 3

I thought it might make sense to change it to > 1 because each packageSubmission has an array of revs but the multiple submissions part might not be relevant anymore?

Copy link
Contributor

@haworku haworku Apr 18, 2024

Choose a reason for hiding this comment

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

The code change you made looks good to me. I would delete the comment totally- I agree that it doesn't make sense for the new world where related rate changes can result in entries in that same package submission array

return {
title: (
<div>
{dayjs
.utc(r.updatedAt)
.tz('America/New_York')
.format('MM/DD/YY h:mma')}{' '}
ET - {isSubsequentSubmission ? 'Submission' : 'Unlock'}
</div>
),
// Display this code if this is the initial contract. We only want to display the link of the initial contract
// only if there has been subsequent contracts. We do not want to display a link if the package initial
// contract was unlocked, but has not been resubmitted yet.
headingLevel: 'h4',
content: isInitialSubmission ? (
<div data-testid={`change-history-record`}>
<span className={styles.tag}>Submitted by:</span>
<span> {r.updatedBy}</span>
<br />
{r.revisionVersion && hasSubsequentSubmissions && (
<Link
href={`/contracts/${contract.id}/revisions/${r.revisionVersion}`}
data-testid={`revision-link-${r.revisionVersion}`}
>
View past contract version
</Link>
)}
</div>
) : (
<div data-testid={`change-history-record`}>
<div>
<span className={styles.tag}>
{isSubsequentSubmission
? 'Submitted by: '
: 'Unlocked by: '}{' '}
</span>
<span>{r.updatedBy}</span>
</div>
<div>
<span className={styles.tag}>
{isSubsequentSubmission
? 'Changes made: '
: 'Reason for unlock: '}
</span>
<span>{r.updatedReason}</span>
</div>
{isSubsequentSubmission && r.revisionVersion && (
<Link
href={`/contracts/${contract.id}/revisions/${r.revisionVersion}`}
data-testid={`revision-link-${r.revisionVersion}`}
>
View past contract version
</Link>
)}
</div>
),
expanded: false,
id: r.updatedAt.toString(),
}
}
)
return (
<section id="changeHistory" className={styles.summarySection}>
<SectionHeader header="Change history" hideBorder />
<Accordion items={revisedItems} multiselectable />
</section>
)
}
Loading
Loading