Skip to content
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

Add isReadOnly argument to project resources #522

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/app/components/project/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
{{#each this.hermesDocuments as |document|}}
<li class="group relative" data-test-document-list-item>
<Project::Resource
@isReadOnly={{not this.projectIsActive}}
@overflowMenuItems={{hash
delete=(hash
label="Remove"
Expand Down Expand Up @@ -187,6 +188,7 @@
{{#each this.externalLinks as |link i|}}
<li class="group" data-test-document-list-item>
<Project::Resource
@isReadOnly={{not this.projectIsActive}}
@overflowMenuItems={{hash
edit=(hash
label="Edit"
Expand Down
4 changes: 3 additions & 1 deletion web/app/components/project/resource.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

{{yield}}

<OverflowMenu @items={{@overflowMenuItems}} />
{{#unless @isReadOnly}}
<OverflowMenu @items={{@overflowMenuItems}} />
{{/unless}}
</div>
1 change: 1 addition & 0 deletions web/app/components/project/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface ProjectResourceComponentSignature {
Element: HTMLDivElement;
Args: {
overflowMenuItems: Record<string, OverflowItem>;
isReadOnly?: boolean;
};
Blocks: {
default: [];
Expand Down
42 changes: 42 additions & 0 deletions web/tests/acceptance/authenticated/projects/project-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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");

Expand Down