From 8dd4e5617669881a440c40f0d70d5b1b3fe5c61a Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Tue, 5 Mar 2024 13:13:40 -0500 Subject: [PATCH] Resolve "failed to load related resources" message on non-app-created docs (#623) Adds related resource logic for non-app-created docs --- web/app/components/document/sidebar.hbs | 1 + .../components/document/sidebar/related-resources.hbs | 2 ++ web/app/components/document/sidebar/related-resources.ts | 6 ++++-- web/tests/acceptance/authenticated/document-test.ts | 9 ++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/web/app/components/document/sidebar.hbs b/web/app/components/document/sidebar.hbs index 71e93ea54..2e952e837 100644 --- a/web/app/components/document/sidebar.hbs +++ b/web/app/components/document/sidebar.hbs @@ -292,6 +292,7 @@ {{! Related resources }}
diff --git a/web/app/components/document/sidebar/related-resources.ts b/web/app/components/document/sidebar/related-resources.ts index d8d513d79..09646cfac 100644 --- a/web/app/components/document/sidebar/related-resources.ts +++ b/web/app/components/document/sidebar/related-resources.ts @@ -5,10 +5,9 @@ import { inject as service } from "@ember/service"; import FetchService from "hermes/services/fetch"; import ConfigService from "hermes/services/config"; import AlgoliaService from "hermes/services/algolia"; -import { restartableTask, task, timeout } from "ember-concurrency"; +import { restartableTask, task } from "ember-concurrency"; import { next, schedule } from "@ember/runloop"; import htmlElement from "hermes/utils/html-element"; -import Ember from "ember"; import { RelatedExternalLink, RelatedHermesDocument, @@ -32,6 +31,7 @@ export interface DocumentSidebarRelatedResourcesComponentArgs { itemLimit?: number; modalInputPlaceholder: string; documentIsDraft?: boolean; + docWasCreatedOffApp?: boolean; editingIsDisabled?: boolean; scrollContainer: HTMLElement; } @@ -208,6 +208,8 @@ export default class DocumentSidebarRelatedResourcesComponent extends Component< * On error, triggers the "retry" design. */ protected loadRelatedResources = task(async () => { + if (this.args.docWasCreatedOffApp) return; + try { const resources = await this.fetchSvc .fetch( diff --git a/web/tests/acceptance/authenticated/document-test.ts b/web/tests/acceptance/authenticated/document-test.ts index 57f881e74..6324306c5 100644 --- a/web/tests/acceptance/authenticated/document-test.ts +++ b/web/tests/acceptance/authenticated/document-test.ts @@ -101,7 +101,8 @@ const PEOPLE_SELECT_REMOVE_BUTTON_SELECTOR = ".ember-power-select-multiple-remove-btn"; const PROJECT_LINK = "[data-test-project-link]"; -const ADD_TO_PROJECT_BUTTON = "[data-test-projects-section-header] button"; +const ADD_TO_PROJECT_BUTTON = + "[data-test-section-header-button-for='Projects']"; const ADD_TO_PROJECT_MODAL = "[data-test-add-to-or-create-project-modal]"; const PROJECT_OPTION = "[data-test-project-option]"; @@ -1121,10 +1122,12 @@ module("Acceptance | authenticated/document", function (hooks) { assert .dom(`${APPROVERS_SELECTOR} ${EDITABLE_FIELD_READ_VALUE}`) .exists("read-only approvers list"); + assert - .dom(ADD_RELATED_DOCUMENT_OPTION_SELECTOR) - .doesNotExist("no add related resource option"); + .dom(ADD_RELATED_RESOURCE_BUTTON_SELECTOR) + .hasAttribute("aria-disabled"); + assert.dom(ADD_TO_PROJECT_BUTTON).hasAttribute("aria-disabled"); assert.dom(PRODUCT_SELECT_SELECTOR).doesNotExist("no product select"); assert.dom(DRAFT_VISIBILITY_TOGGLE_SELECTOR).isDisabled();