diff --git a/web/app/components/document/sidebar.hbs b/web/app/components/document/sidebar.hbs index 143d8137c..89dde2cb7 100644 --- a/web/app/components/document/sidebar.hbs +++ b/web/app/components/document/sidebar.hbs @@ -129,7 +129,7 @@ @isSaving={{this.saveIsRunning}} @isReadOnly={{not this.isOwner}} @name="summary" - @placeholder="Enter a summary" + @placeholder={{if this.isOwner "Enter a summary"}} /> diff --git a/web/app/components/document/sidebar/related-resources.hbs b/web/app/components/document/sidebar/related-resources.hbs index 5a38c32ca..474a7bcc3 100644 --- a/web/app/components/document/sidebar/related-resources.hbs +++ b/web/app/components/document/sidebar/related-resources.hbs @@ -29,6 +29,7 @@ @items={{rr.items}} @itemLimit={{@itemLimit}} @showModal={{rr.showModal}} + @editingIsDisabled={{@editingIsDisabled}} > <:resource as |r|>
- - - - - - + {{#if @editingIsDisabled}} +
+ +
+ {{else}} + + + + + + + {{/if}}
{{else}} diff --git a/web/app/components/document/sidebar/related-resources/list.ts b/web/app/components/document/sidebar/related-resources/list.ts index c266be028..20b2be86c 100644 --- a/web/app/components/document/sidebar/related-resources/list.ts +++ b/web/app/components/document/sidebar/related-resources/list.ts @@ -16,6 +16,7 @@ interface DocumentSidebarRelatedResourcesListComponentSignature { items: any[]; itemLimit?: number; showModal?: () => void; + editingIsDisabled?: boolean; }; Blocks: { resource: [resource: any]; diff --git a/web/app/components/editable-field.hbs b/web/app/components/editable-field.hbs index 7ee80ac5f..d4468f6ca 100644 --- a/web/app/components/editable-field.hbs +++ b/web/app/components/editable-field.hbs @@ -72,7 +72,7 @@ {{/if}} {{#if (or @isReadOnly @isSaving)}} -
+
; + deleteDraft: (docID: string) => void; + isCollapsed: boolean; + toggleCollapsed: () => void; +} + +module("Integration | Component | document/sidebar", function (hooks) { + setupRenderingTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function (this: DocumentSidebarComponentTestContext) { + await authenticateSession({}); + + const authenticatedUser = this.owner.lookup( + "service:authenticated-user", + ) as AuthenticatedUserService; + + await authenticatedUser.loadInfo.perform(); + + this.set("profile", authenticatedUser.info); + this.server.create("document", { + owners: ["testuser@example.com"], + isDraft: false, + }); + + this.set("document", this.server.schema.document.first().attrs); + this.set("docType", new Promise(() => {})); + this.set("toggleCollapsed", () => {}); + this.set("deleteDraft", (docID: string) => {}); + }); + + test("it shows the correct summary empty state based on if the viewer is the doc owner", async function (this: DocumentSidebarComponentTestContext, assert) { + await render(hbs` + + `); + + // By default the viewer is the doc owner + assert.dom(SUMMARY_EMPTY_STATE).containsText("Enter a summary"); + + // Set the doc owner to someone else + this.set( + "document", + this.server.schema.document.first().update({ + owners: ["foo@bar.com"], + }), + ); + + assert.dom(SUMMARY_EMPTY_STATE).containsText("None"); + }); +}); diff --git a/web/tests/integration/components/document/sidebar/related-resources-test.ts b/web/tests/integration/components/document/sidebar/related-resources-test.ts index eb724c0e6..8b9fe74ce 100644 --- a/web/tests/integration/components/document/sidebar/related-resources-test.ts +++ b/web/tests/integration/components/document/sidebar/related-resources-test.ts @@ -50,6 +50,7 @@ const TOOLTIP_SELECTOR = ".hermes-tooltip"; interface DocumentSidebarRelatedResourcesTestContext extends MirageTestContext { document: HermesDocument; body: HTMLElement; + editingIsDisabled: boolean; } module( @@ -78,12 +79,14 @@ module( this.set("body", bodyDiv); }); - test("the empty state is clickable to add a resource", async function (this: DocumentSidebarRelatedResourcesTestContext, assert) { + test("the empty state is conditionally clickable to add a resource", async function (this: DocumentSidebarRelatedResourcesTestContext, assert) { + this.set("editingIsDisabled", true); + await render(hbs` `); - const emptyStateSelector = - "[data-test-related-resources-list-empty-state]"; + const readOnlyValue = "div.field-toggle.read-only"; + const interactiveEmptyState = "button.field-toggle"; + + assert.dom(readOnlyValue).hasText("None"); + assert.dom(interactiveEmptyState).doesNotExist(); + + // Enable editing + this.set("editingIsDisabled", false); - assert.dom(emptyStateSelector).hasText("None"); + assert.dom(readOnlyValue).doesNotExist(); + assert.dom(interactiveEmptyState).hasText("None"); await click("[data-test-related-resources-list-empty-state]"); diff --git a/web/tests/integration/components/editable-field-test.ts b/web/tests/integration/components/editable-field-test.ts index 050c8f0f8..7a07c9e52 100644 --- a/web/tests/integration/components/editable-field-test.ts +++ b/web/tests/integration/components/editable-field-test.ts @@ -117,7 +117,7 @@ module("Integration | Component | editable-field", function (hooks) { ); assert - .dom("div.field-toggle") + .dom("div.field-toggle.read-only") .exists("the element is rendered as a div when editing is disabled"); });