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 "leave approver role" function; clean up sidebar approval controls #588

Merged
merged 34 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a765918
Add doc number logic to editable field
jeffdaley Feb 6, 2024
f1f4408
Rearrange status
jeffdaley Feb 6, 2024
168fd44
Fix tests
jeffdaley Feb 6, 2024
384cbe1
Rename to status
jeffdaley Feb 6, 2024
a3b7b79
Merge branch 'main' into jeffdaley/doc-number
jeffdaley Feb 6, 2024
c4bdb97
Update app.scss
jeffdaley Feb 6, 2024
59f38de
Merge branch 'main' into jeffdaley/doc-number
jeffdaley Feb 6, 2024
6794b2c
Cleanup and add test
jeffdaley Feb 6, 2024
0ac92e8
Merge branch 'main' into jeffdaley/doc-status-dropdown
jeffdaley Feb 6, 2024
436fd5c
Merge branch 'jeffdaley/doc-number' into jeffdaley/doc-status-dropdown
jeffdaley Feb 6, 2024
56f1d72
Add status dropdown
jeffdaley Feb 6, 2024
732e1e7
Merge branch 'main' into jeffdaley/doc-status-dropdown
jeffdaley Feb 6, 2024
47933ac
Add `type` arg to Status
jeffdaley Feb 6, 2024
a837038
Fix broken tests
jeffdaley Feb 6, 2024
c5c20da
Update test, remove unnecessary changes
jeffdaley Feb 7, 2024
ef3702d
Style tweaks and cleanup
jeffdaley Feb 7, 2024
d690ab0
Another test; border tweak
jeffdaley Feb 7, 2024
81af19c
Delete `archive` artifacts; template refactor
jeffdaley Feb 7, 2024
1733250
WIP footer cleanup
jeffdaley Feb 7, 2024
868b4e4
Add WIP dropdown check/test
jeffdaley Feb 7, 2024
b0ac7c5
Fix mirage attrs ("Draft" → "WIP")
jeffdaley Feb 7, 2024
611d104
Merge branch 'jeffdaley/doc-status-dropdown' into jeffdaley/approval-…
jeffdaley Feb 7, 2024
5136afe
WIP try to remove yourself from a doc
jeffdaley Feb 7, 2024
ae677d9
Merge branch 'main' into jeffdaley/approval-buttons
jeffdaley Feb 7, 2024
8fe638d
Hack the approvers list to re-render
jeffdaley Feb 8, 2024
86f29c5
Fix tests, rename methods
jeffdaley Feb 8, 2024
9932bcf
Update sidebar.hbs
jeffdaley Feb 8, 2024
4731241
Add documentation; revert editableField changes
jeffdaley Feb 8, 2024
38e2efd
Update editable-field-test.ts
jeffdaley Feb 8, 2024
1582649
Add more tests and Mirage config
jeffdaley Feb 8, 2024
39c9147
Add and test for tooltips
jeffdaley Feb 8, 2024
a877fb7
Update sidebar.hbs
jeffdaley Feb 8, 2024
6b55946
Fix tooltip bug
jeffdaley Feb 8, 2024
99b20bf
Pass `onClose` to docPublishedModal
jeffdaley Feb 8, 2024
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
210 changes: 142 additions & 68 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,25 @@
</div>
</div>

{{! Approvers }}
<div>
<Document::Sidebar::SectionHeader @title="Approvers" />
<div class="editable-field-container mt-[3px]">
<EditableField
data-test-document-approvers
data-test-editable={{this.isOwner}}
@value={{this.approvers}}
@onChange={{this.updateApprovers}}
@onSave={{perform this.save "approvers"}}
@isSaving={{this.saveIsRunning}}
@isReadOnly={{this.editingIsDisabled}}
{{! Provide the document to the `has-approved-doc` helper }}
@document={{@document}}
/>
{{#if this.approversAreShown}}
{{! Approvers }}
<div>
<Document::Sidebar::SectionHeader @title="Approvers" />
<div class="editable-field-container mt-[3px]">
<EditableField
data-test-document-approvers
data-test-editable={{this.isOwner}}
@value={{this.approvers}}
@onChange={{this.updateApprovers}}
@onSave={{perform this.save "approvers"}}
@isSaving={{this.saveIsRunning}}
@isReadOnly={{this.editingIsDisabled}}
{{! Provide the document to the `has-approved-doc` helper }}
@document={{@document}}
/>
</div>
</div>
</div>
{{/if}}

{{! Related resources }}
<div>
Expand Down Expand Up @@ -373,8 +375,12 @@
</div>

{{#if this.footerIsShown}}
<div class="sidebar-footer {{if this.editingIsDisabled 'locked'}}">
<div
data-test-sidebar-footer
class="sidebar-footer {{if this.editingIsDisabled 'locked'}}"
>
{{#if this.footerControlsAreDisabled}}
{{! Disabled controls }}
<div class="-mb-1 px-3">
<div class="w-full border-t border-color-border-primary pt-3.5">
<div class="text-body-200 text-color-foreground-faint">
Expand Down Expand Up @@ -412,62 +418,125 @@
</div>
</div>
{{else}}
{{#if this.isDraft}}
{{#if this.isOwner}}
<div class="flex items-start gap-2 px-3">
<Hds::Button
data-test-sidebar-publish-for-review-button
@text="Publish for review..."
@size="medium"
@color="primary"
class="w-full"
{{on "click" (set this "requestReviewModalIsShown" true)}}
/>
<Hds::Button
@text="Delete"
@size="medium"
@color="critical"
@icon="trash"
@isIconOnly={{true}}
class="basis-0"
{{on "click" (fn (set this "deleteModalIsShown" true))}}
/>
</div>
{{/if}}
{{else}}
{{#if this.isApprover}}
<div class="gap-2 px-3">
<Hds::Button
@text={{this.approveButtonText}}
@size="medium"
@color="primary"
class="w-full"
@icon={{if this.approve.isRunning "loading"}}
disabled={{(or
this.approve.isRunning
this.requestChanges.isRunning
this.hasApproved
)}}
{{on "click" (perform this.approve)}}
/>
{{#if (eq @document.docType "FRD")}}
{{#let (and this.isDraft this.isOwner) as |canPublish|}}
{{#if (or canPublish this.isApprover)}}
<div class="flex gap-2 px-3">

{{#if canPublish}}
{{! Publish for review... }}
<Hds::Button
@text={{this.requestChangesButtonText}}
@size="medium"
@color="secondary"
data-test-sidebar-publish-for-review-button
@text="Publish for review..."
class="w-full"
@icon={{if this.requestChanges.isRunning "loading"}}
disabled={{(or
this.approve.isRunning
this.requestChanges.isRunning
this.hasRequestedChanges
)}}
{{on "click" (perform this.requestChanges)}}
{{on "click" (set this "requestReviewModalIsShown" true)}}
/>
{{! Delete... }}
<Hds::Button
data-test-delete-draft-button
@text="Delete..."
@icon="trash"
@color="secondary"
@isIconOnly={{true}}
class="basis-0"
{{tooltip "Delete..."}}
{{on "click" (fn (set this "deleteModalIsShown" true))}}
/>
{{else}}
{{! isApprover }}

{{! Read-only / isRunning state }}
{{#if
(or
this.hasApproved
this.hasRejectedFRD
this.approve.isRunning
this.rejectFRD.isRunning
this.leaveApproverRole.isRunning
)
}}
<div
data-test-sidebar-footer-primary-button-read-only
class="hds-button mock-disabled hds-button--primary hds-button--size-medium w-full leading-none"
>
{{if
this.rejectFRD.isRunning
"Saving..."
(if
this.approve.isRunning
"Approving..."
(if
this.leaveApproverRole.isRunning
"Leaving..."
(if
this.hasApproved
"Approved"
(if this.rejectFRD "Rejected")
)
)
)
}}
</div>
{{else}}
{{! Approve }}
<Hds::Button
data-test-approve-button
@text="Approve"
class="w-full"
{{on "click" (perform this.approve)}}
/>
{{#if (eq @document.docType "FRD")}}
{{! Reject FRD }}
<Hds::Button
data-test-reject-frd-button
@text="Reject"
@color="critical"
@icon="thumbs-down"
@isIconOnly={{true}}
{{tooltip "Reject"}}
{{on "click" (perform this.rejectFRD)}}
/>
{{/if}}
{{! Overflow menu (Leave approver role) }}
<X::DropdownList
data-test-sidebar-footer-overflow-menu
@placement="top-start"
@items={{array
(hash
icon="user-minus"
label="Leave approver role"
action=(perform this.leaveApproverRole)
)
}}
>
<:anchor as |dd|>
<dd.ToggleAction>
<Hds::Button
data-test-sidebar-footer-secondary-dropdown-button
@text="More actions"
@icon="more-horizontal"
@color="secondary"
@isIconOnly={{true}}
/>
</dd.ToggleAction>
</:anchor>
<:item as |dd|>
<dd.Action
class="flex gap-2.5"
{{on "click" dd.attrs.action}}
>
<FlightIcon
@name={{dd.attrs.icon}}
class="opacity-60"
/>
{{dd.attrs.label}}
</dd.Action>
</:item>
</X::DropdownList>
{{/if}}
{{/if}}
</div>
{{/if}}
{{/if}}
{{/let}}
{{/if}}
</div>
{{/if}}
Expand All @@ -486,6 +555,7 @@

{{#if this.deleteModalIsShown}}
<Document::Modal
data-test-delete-draft-modal
@color="critical"
@headerText="Delete draft?"
@bodyText="Are you sure you want to delete this draft?"
Expand Down Expand Up @@ -625,7 +695,11 @@
{{/if}}

{{#if this.docPublishedModalIsShown}}
<Hds::Modal data-test-doc-published-modal as |M|>
<Hds::Modal
@onClose={{this.closeRequestReviewSuccessModal}}
data-test-doc-published-modal
as |M|
>
<M.Header>
<div class="flex items-center">
<FlightIcon
Expand Down
Loading
Loading