-
Notifications
You must be signed in to change notification settings - Fork 2
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
1703 4 hard delete attachments #1835
Changes from all commits
423015f
bb785d0
dec1096
f8070c3
e1e4dd3
27f8a44
be0fb2a
5dff0e4
a63612f
68f4258
1b5db6c
22295d3
68b1798
1ab5699
b4a866a
05686ce
177cf38
dc218e8
ff55ff6
8684a93
e87f6c5
024ab2b
aa87933
ea8088d
e22887f
2124969
8a31ac0
3d8196b
3f773f2
51395b3
ed8f5ba
f8d9309
7e009e2
4b6ce7c
683b97c
8fda6ae
9b1a7f7
f5fc5e5
aa109e7
9689b56
a7d7a39
eb31889
3141e11
e6102b9
c27cb1b
ec02b03
e3456e3
ba5422a
b250a32
d9ae1b0
f40c808
d6c4922
c8460cf
71efa3e
39dc671
c8275f2
6aeb5c1
f7d6592
ecea111
19361ef
c1e14a7
5d4dfec
389fed2
d3b0747
6a036c1
08239d2
5c9b5df
9c31619
8861bbc
0d0fccd
65f3051
8bb1432
a981b27
10ea511
8e881ab
353c4cd
46eb659
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ cypress.env.json | |
app/cypress.env.json | ||
dev/db/data | ||
**/.DS_Store | ||
|
||
gha-creds-*.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to have any files locally related to this rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is leftover from experimenting with CI, will remove |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,32 @@ | ||
import { Button } from "@button-inc/bcgov-theme"; | ||
import useDiscardProjectAttachmentFormChange from "mutations/attachment/discardProjectAttachmentFormChange"; | ||
import Link from "next/link"; | ||
import { getAttachmentDownloadRoute } from "routes/pageRoutes"; | ||
import { graphql, useFragment } from "react-relay"; | ||
import useDiscardProjectAttachmentFormChange from "mutations/attachment/discardProjectAttachmentFormChange"; | ||
import { getAttachmentDownloadRoute } from "routes/pageRoutes"; | ||
import { AttachmentTableRow_attachment$key } from "__generated__/AttachmentTableRow_attachment.graphql"; | ||
import hardDeleteAttachment from "./hardDeleteAttachment"; | ||
import { useRouter } from "next/router"; | ||
|
||
interface Props { | ||
attachment: AttachmentTableRow_attachment$key; | ||
connectionId: string; | ||
formChangeRowId: number; | ||
hideDelete?: boolean; | ||
isFirstRevision: boolean; | ||
} | ||
|
||
const AttachmentTableRow: React.FC<Props> = ({ | ||
attachment, | ||
connectionId, | ||
formChangeRowId, | ||
hideDelete, | ||
isFirstRevision, | ||
}) => { | ||
const [ | ||
discardProjectAttachmentFormChange, | ||
isDiscardingProjectAttachmentFormChange, | ||
] = useDiscardProjectAttachmentFormChange(); | ||
const { | ||
id, | ||
fileName, | ||
fileType, | ||
fileSize, | ||
createdAt, | ||
cifUserByCreatedBy: { fullName }, | ||
} = useFragment( | ||
const attachmentRow = useFragment( | ||
graphql` | ||
fragment AttachmentTableRow_attachment on Attachment { | ||
id | ||
|
@@ -45,32 +42,43 @@ const AttachmentTableRow: React.FC<Props> = ({ | |
attachment | ||
); | ||
|
||
const handleArchiveAttachment = () => { | ||
discardProjectAttachmentFormChange({ | ||
variables: { | ||
input: { | ||
formChangeId: formChangeRowId, | ||
const router = useRouter(); | ||
if (!attachmentRow) return null; | ||
const { id, fileName, fileType, fileSize, createdAt, cifUserByCreatedBy } = | ||
attachmentRow; | ||
|
||
const handleArchiveAttachment = (attachmentId) => { | ||
if (isFirstRevision) { | ||
console.log("in if handlearchiveattachment"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leftover! |
||
hardDeleteAttachment(attachmentId, formChangeRowId); | ||
router.replace(router.asPath); | ||
} else { | ||
discardProjectAttachmentFormChange({ | ||
variables: { | ||
input: { | ||
formChangeId: formChangeRowId, | ||
}, | ||
connections: [connectionId], | ||
}, | ||
connections: [connectionId], | ||
}, | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
console.log("connectionid", connectionId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leftover! |
||
return ( | ||
<> | ||
<tr> | ||
<td>{fileName}</td> | ||
<td>{fileType}</td> | ||
<td>{fileSize}</td> | ||
<td>{fullName}</td> | ||
<td>{cifUserByCreatedBy?.fullName}</td> | ||
<td>{createdAt}</td> | ||
<td className="links"> | ||
<Link href={getAttachmentDownloadRoute(id)} passHref> | ||
<Button size="small">Download</Button> | ||
</Link> | ||
{!hideDelete && ( | ||
<Button | ||
onClick={handleArchiveAttachment} | ||
onClick={() => handleArchiveAttachment(id)} | ||
disabled={isDiscardingProjectAttachmentFormChange} | ||
size="small" | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { getAttachmentDeleteRoute } from "routes/pageRoutes"; | ||
|
||
const hardDeleteAttachment = (attachmentId, formChangeRowId) => { | ||
fetch(getAttachmentDeleteRoute(attachmentId).pathname, { | ||
method: "DELETE", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ | ||
variables: { | ||
input: { | ||
formChangeId: formChangeRowId, | ||
}, | ||
}, | ||
}), | ||
}); | ||
}; | ||
|
||
export default hardDeleteAttachment; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,9 +167,16 @@ describe("when creating a project, the project page", () => { | |
cy.findByText(/Submit Annual Reports/i).click(); | ||
|
||
// Add attachments | ||
cy.findByText(/Project Attachments/i).click(); | ||
cy.findByText(/Add Project Attachments/i).click(); | ||
cy.url().should("include", "/form/8"); | ||
cy.findByText(/Submit project attachments/i).click(); | ||
|
||
cy.fixture("e2e/mock.pdf").as("mockFile"); | ||
cy.get("input[type=file]").selectFile("@mockFile"); | ||
cy.wait(30000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure you have tested this but just as a sanity check, have you tried using any other assertions rather than using |
||
cy.happoAndAxe("Project attachments", "filled", "main", true); | ||
|
||
cy.findByText(/Submit project attachments/i).click(); | ||
//review and submit | ||
cy.contains("Review and Submit Project"); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover!