From b6d07022083344b5bc22a7a1ead3204a2ee121ca Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Thu, 21 Dec 2023 09:15:22 -0500 Subject: [PATCH] Add `isReadOnly` argument to project resources (#522) * Set `isReadOnly` conditions * Add isReadOnly conditions to project resources * Add tests --- web/app/components/project/index.hbs | 2 + web/app/components/project/resource.hbs | 4 +- web/app/components/project/resource.ts | 1 + .../authenticated/projects/project-test.ts | 42 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/web/app/components/project/index.hbs b/web/app/components/project/index.hbs index 2baca9379..859c9baa1 100644 --- a/web/app/components/project/index.hbs +++ b/web/app/components/project/index.hbs @@ -156,6 +156,7 @@ {{#each this.hermesDocuments as |document|}}
  • + {{#unless @isReadOnly}} + + {{/unless}} diff --git a/web/app/components/project/resource.ts b/web/app/components/project/resource.ts index 1f8fbdf48..82cc7e1c7 100644 --- a/web/app/components/project/resource.ts +++ b/web/app/components/project/resource.ts @@ -5,6 +5,7 @@ interface ProjectResourceComponentSignature { Element: HTMLDivElement; Args: { overflowMenuItems: Record; + isReadOnly?: boolean; }; Blocks: { default: []; diff --git a/web/tests/acceptance/authenticated/projects/project-test.ts b/web/tests/acceptance/authenticated/projects/project-test.ts index 354e4fa42..08c54c89f 100644 --- a/web/tests/acceptance/authenticated/projects/project-test.ts +++ b/web/tests/acceptance/authenticated/projects/project-test.ts @@ -424,6 +424,25 @@ module("Acceptance | authenticated/projects/project", function (hooks) { assert.equal(projectDocuments.length, 0); }); + test("documents can only be removed if the project is active", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) { + await visit("/projects/1"); + + assert.dom(DOCUMENT_LIST_ITEM).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).exists(); + + await click(STATUS_TOGGLE); + await click(COMPLETED_STATUS_ACTION); + + assert.dom(DOCUMENT_LIST_ITEM).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).doesNotExist(); + + await click(STATUS_TOGGLE); + await click(ARCHIVED_STATUS_ACTION); + + assert.dom(DOCUMENT_LIST_ITEM).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).doesNotExist(); + }); + test("you can add external links to a project", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) { const project = this.server.schema.projects.first(); @@ -537,6 +556,29 @@ module("Acceptance | authenticated/projects/project", function (hooks) { assert.equal(projectLinks.length, 0); }); + test("external links can only be edited if the project is active", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) { + this.server.schema.projects.first().update({ + externalLinks: [this.server.create("related-external-link").attrs], + }); + + await visit("/projects/1"); + + assert.dom(EXTERNAL_LINK).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).exists(); + + await click(STATUS_TOGGLE); + await click(COMPLETED_STATUS_ACTION); + + assert.dom(EXTERNAL_LINK).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).doesNotExist(); + + await click(STATUS_TOGGLE); + await click(ARCHIVED_STATUS_ACTION); + + assert.dom(EXTERNAL_LINK).exists(); + assert.dom(OVERFLOW_MENU_BUTTON).doesNotExist(); + }); + test("you can't save an empty project title", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) { await visit("/projects/1");