From 8dc460bfc586ae1698cfb49f93fd77d4439c1b47 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 10:47:38 -0400 Subject: [PATCH 1/7] Fix and expand RelatedHermesDocument type --- .../sidebar/related-resources/list-item/resource.ts | 4 ++-- web/app/components/related-resources.ts | 6 +++++- web/app/components/related-resources/add.ts | 13 ++++++++----- web/mirage/factories/related-hermes-document.ts | 5 ++++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/web/app/components/document/sidebar/related-resources/list-item/resource.ts b/web/app/components/document/sidebar/related-resources/list-item/resource.ts index 4a4838881..ab395a135 100644 --- a/web/app/components/document/sidebar/related-resources/list-item/resource.ts +++ b/web/app/components/document/sidebar/related-resources/list-item/resource.ts @@ -26,7 +26,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex */ protected get docType() { this.assertResourceIsDocument(this.args.resource); - return this.args.resource.type; + return this.args.resource.documentType; } /** @@ -73,7 +73,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex * with the correct data model. */ private assertResourceIsDocument( - document: RelatedResource + document: RelatedResource, ): asserts document is RelatedHermesDocument { if (!("googleFileID" in document)) { throw new Error("resource must be a document"); diff --git a/web/app/components/related-resources.ts b/web/app/components/related-resources.ts index e52429699..bdb7b24f4 100644 --- a/web/app/components/related-resources.ts +++ b/web/app/components/related-resources.ts @@ -23,9 +23,13 @@ export interface RelatedHermesDocument { id: number; googleFileID: string; title: string; - type: string; + documentType: string; documentNumber: string; sortOrder: number; + status: string; + owners?: string[]; + ownerPhotos?: string[]; + product?: string; } export enum RelatedResourcesScope { diff --git a/web/app/components/related-resources/add.ts b/web/app/components/related-resources/add.ts index 809421b57..7542e6016 100644 --- a/web/app/components/related-resources/add.ts +++ b/web/app/components/related-resources/add.ts @@ -33,7 +33,7 @@ interface RelatedResourcesAddComponentSignature { dd: XDropdownListAnchorAPI | null, query: string, shouldIgnoreDelay?: boolean, - options?: SearchOptions + options?: SearchOptions, ) => Promise; getObject: (dd: XDropdownListAnchorAPI | null, id: string) => Promise; headerTitle: string; @@ -329,8 +329,11 @@ export default class RelatedResourcesAddComponent extends Component { assert( "full url format expected", - this.firstPartyURLFormat === FirstPartyURLFormat.FullURL + this.firstPartyURLFormat === FirstPartyURLFormat.FullURL, ); this.checkForDuplicate(id, true); diff --git a/web/mirage/factories/related-hermes-document.ts b/web/mirage/factories/related-hermes-document.ts index 6ca3c75a9..06489f652 100644 --- a/web/mirage/factories/related-hermes-document.ts +++ b/web/mirage/factories/related-hermes-document.ts @@ -13,8 +13,11 @@ export default Factory.extend({ title() { return `Related Document ${this.id}`; }, - type: "RFC", + documentType: "RFC", documentNumber() { return `LAB-00${this.id}`; }, + status: "In review", + product: "Labs", + owners: ["testuser@example.com"], }); From 69142652439a30a0cab0f2ab739c70956ef8de9d Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 10:54:39 -0400 Subject: [PATCH 2/7] Update list-item-test.ts --- .../sidebar/related-resources/list-item-test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/tests/integration/components/document/sidebar/related-resources/list-item-test.ts b/web/tests/integration/components/document/sidebar/related-resources/list-item-test.ts index 19648e93c..38b964ae3 100644 --- a/web/tests/integration/components/document/sidebar/related-resources/list-item-test.ts +++ b/web/tests/integration/components/document/sidebar/related-resources/list-item-test.ts @@ -36,7 +36,7 @@ module( setupMirage(hooks); hooks.beforeEach(async function ( - this: DocumentSidebarRelatedResourcesListItemTestContext + this: DocumentSidebarRelatedResourcesListItemTestContext, ) { this.server.create("document"); @@ -44,7 +44,7 @@ module( this.set("document", { googleFileID: documentAttrs.objectID, title: documentAttrs.title, - type: documentAttrs.docType, + documentType: documentAttrs.docType, documentNumber: documentAttrs.docNumber, sortOrder: 1, }); @@ -166,7 +166,7 @@ module( .exists({ count: 2 }, "two buttons are present for external resources"); const editButton = htmlElement( - `${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(1) button` + `${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(1) button`, ); assert.dom(editButton).hasText("Edit", "edit button is present"); @@ -187,7 +187,7 @@ module( await click(OVERFLOW_BUTTON_SELECTOR); const removeButton = htmlElement( - `${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(2) button` + `${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(2) button`, ); assert.dom(removeButton).hasText("Remove", "remove button is present"); @@ -195,5 +195,5 @@ module( assert.equal(count, 2, "remove button was clicked"); }); - } + }, ); From 02a5abcf633d6502a3466cc89341b21ff6e4c3e8 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 11:08:04 -0400 Subject: [PATCH 3/7] Revert out-of-scope changes --- web/app/components/related-resources.ts | 4 ---- web/app/components/related-resources/add.ts | 3 --- web/mirage/factories/related-hermes-document.ts | 3 --- 3 files changed, 10 deletions(-) diff --git a/web/app/components/related-resources.ts b/web/app/components/related-resources.ts index bdb7b24f4..1e88642fa 100644 --- a/web/app/components/related-resources.ts +++ b/web/app/components/related-resources.ts @@ -26,10 +26,6 @@ export interface RelatedHermesDocument { documentType: string; documentNumber: string; sortOrder: number; - status: string; - owners?: string[]; - ownerPhotos?: string[]; - product?: string; } export enum RelatedResourcesScope { diff --git a/web/app/components/related-resources/add.ts b/web/app/components/related-resources/add.ts index 7542e6016..0cecadb95 100644 --- a/web/app/components/related-resources/add.ts +++ b/web/app/components/related-resources/add.ts @@ -331,9 +331,6 @@ export default class RelatedResourcesAddComponent extends Component Date: Wed, 18 Oct 2023 11:14:37 -0400 Subject: [PATCH 4/7] Add more attributes to RelatedHermesDocument --- .../sidebar/related-resources/list-item/resource.ts | 4 ++-- web/app/components/related-resources.ts | 6 +++++- web/app/components/related-resources/add.ts | 13 ++++++++----- web/mirage/factories/related-hermes-document.ts | 8 ++++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/web/app/components/document/sidebar/related-resources/list-item/resource.ts b/web/app/components/document/sidebar/related-resources/list-item/resource.ts index 4a4838881..ab395a135 100644 --- a/web/app/components/document/sidebar/related-resources/list-item/resource.ts +++ b/web/app/components/document/sidebar/related-resources/list-item/resource.ts @@ -26,7 +26,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex */ protected get docType() { this.assertResourceIsDocument(this.args.resource); - return this.args.resource.type; + return this.args.resource.documentType; } /** @@ -73,7 +73,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex * with the correct data model. */ private assertResourceIsDocument( - document: RelatedResource + document: RelatedResource, ): asserts document is RelatedHermesDocument { if (!("googleFileID" in document)) { throw new Error("resource must be a document"); diff --git a/web/app/components/related-resources.ts b/web/app/components/related-resources.ts index e52429699..bdb7b24f4 100644 --- a/web/app/components/related-resources.ts +++ b/web/app/components/related-resources.ts @@ -23,9 +23,13 @@ export interface RelatedHermesDocument { id: number; googleFileID: string; title: string; - type: string; + documentType: string; documentNumber: string; sortOrder: number; + status: string; + owners?: string[]; + ownerPhotos?: string[]; + product?: string; } export enum RelatedResourcesScope { diff --git a/web/app/components/related-resources/add.ts b/web/app/components/related-resources/add.ts index 809421b57..7542e6016 100644 --- a/web/app/components/related-resources/add.ts +++ b/web/app/components/related-resources/add.ts @@ -33,7 +33,7 @@ interface RelatedResourcesAddComponentSignature { dd: XDropdownListAnchorAPI | null, query: string, shouldIgnoreDelay?: boolean, - options?: SearchOptions + options?: SearchOptions, ) => Promise; getObject: (dd: XDropdownListAnchorAPI | null, id: string) => Promise; headerTitle: string; @@ -329,8 +329,11 @@ export default class RelatedResourcesAddComponent extends Component { assert( "full url format expected", - this.firstPartyURLFormat === FirstPartyURLFormat.FullURL + this.firstPartyURLFormat === FirstPartyURLFormat.FullURL, ); this.checkForDuplicate(id, true); diff --git a/web/mirage/factories/related-hermes-document.ts b/web/mirage/factories/related-hermes-document.ts index 6ca3c75a9..241b18990 100644 --- a/web/mirage/factories/related-hermes-document.ts +++ b/web/mirage/factories/related-hermes-document.ts @@ -5,7 +5,7 @@ import { Factory } from "miragejs"; // but that doesn't work when using `createList` in tests. export default Factory.extend({ - id: 0, + id: (i) => i, sortOrder: (i) => i, googleFileID() { return `${this.id}`; @@ -13,8 +13,12 @@ export default Factory.extend({ title() { return `Related Document ${this.id}`; }, - type: "RFC", + documentType: "RFC", documentNumber() { return `LAB-00${this.id}`; }, + status: "In review", + product: "Labs", + owners: ["testuser@example.com"], + ownerPhotos: ["https://placehold.co/100x100"], }); From a6be4f19bcc39c8550d5bead8c1951d41acb4708 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 14:04:53 -0400 Subject: [PATCH 5/7] Add new attrs to Go API --- internal/api/documents_related_resources.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/api/documents_related_resources.go b/internal/api/documents_related_resources.go index 30a63d86b..dab9fdd3c 100644 --- a/internal/api/documents_related_resources.go +++ b/internal/api/documents_related_resources.go @@ -45,6 +45,10 @@ type hermesDocumentRelatedResourceGetResponse struct { DocumentType string `json:"documentType"` DocumentNumber string `json:"documentNumber"` SortOrder int `json:"sortOrder"` + Status string `json:"status"` + Owners []string `json:"owners"` + OwnerPhotos []string `json:"ownerPhotos"` + Product string `json:"product"` } func documentsResourceRelatedResourcesHandler( @@ -153,6 +157,10 @@ func documentsResourceRelatedResourcesHandler( DocumentType: doc.DocType, DocumentNumber: doc.DocNumber, SortOrder: hdrr.RelatedResource.SortOrder, + Status: doc.Status, + Owners: doc.Owners, + OwnerPhotos: doc.OwnerPhotos, + Product: doc.Product, }) } From 78e9a8603f9adf0b12709c4d0d7f8ccfe8c4c4d4 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 14:15:39 -0400 Subject: [PATCH 6/7] Revert out-of-scope change --- web/mirage/factories/related-hermes-document.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/mirage/factories/related-hermes-document.ts b/web/mirage/factories/related-hermes-document.ts index 241b18990..82907af4c 100644 --- a/web/mirage/factories/related-hermes-document.ts +++ b/web/mirage/factories/related-hermes-document.ts @@ -5,7 +5,7 @@ import { Factory } from "miragejs"; // but that doesn't work when using `createList` in tests. export default Factory.extend({ - id: (i) => i, + id: 0, sortOrder: (i) => i, googleFileID() { return `${this.id}`; From 01c50c8cafd344f1d00268686adf1e049ae38177 Mon Sep 17 00:00:00 2001 From: Josh Freda Date: Fri, 20 Oct 2023 10:24:21 -0500 Subject: [PATCH 7/7] go fmt --- internal/api/documents_related_resources.go | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/api/documents_related_resources.go b/internal/api/documents_related_resources.go index dab9fdd3c..a3a9e4223 100644 --- a/internal/api/documents_related_resources.go +++ b/internal/api/documents_related_resources.go @@ -40,15 +40,15 @@ type externalLinkRelatedResourceGetResponse struct { } type hermesDocumentRelatedResourceGetResponse struct { - GoogleFileID string `json:"googleFileID"` - Title string `json:"title"` - DocumentType string `json:"documentType"` - DocumentNumber string `json:"documentNumber"` - SortOrder int `json:"sortOrder"` - Status string `json:"status"` - Owners []string `json:"owners"` - OwnerPhotos []string `json:"ownerPhotos"` - Product string `json:"product"` + GoogleFileID string `json:"googleFileID"` + Title string `json:"title"` + DocumentType string `json:"documentType"` + DocumentNumber string `json:"documentNumber"` + SortOrder int `json:"sortOrder"` + Status string `json:"status"` + Owners []string `json:"owners"` + OwnerPhotos []string `json:"ownerPhotos"` + Product string `json:"product"` } func documentsResourceRelatedResourcesHandler( @@ -157,10 +157,10 @@ func documentsResourceRelatedResourcesHandler( DocumentType: doc.DocType, DocumentNumber: doc.DocNumber, SortOrder: hdrr.RelatedResource.SortOrder, - Status: doc.Status, - Owners: doc.Owners, - OwnerPhotos: doc.OwnerPhotos, - Product: doc.Product, + Status: doc.Status, + Owners: doc.Owners, + OwnerPhotos: doc.OwnerPhotos, + Product: doc.Product, }) }