Skip to content

Commit

Permalink
Make approver groups conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Apr 12, 2024
1 parent 3b447b0 commit 2fa655b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
@onSave={{perform this.saveApprovers}}
@isSaving={{this.saveIsRunning}}
@isReadOnly={{this.editingIsDisabled}}
@includeGroupsInPeopleSelect={{true}}
@includeGroupsInPeopleSelect={{this.configSvc.config.group_approvals}}
{{! Provide the document to the `has-approved-doc` helper }}
@document={{@document}}
/>
Expand Down Expand Up @@ -767,7 +767,7 @@
<Hds::Form::Field @layout="vertical" as |F|>
<F.Control>
<Inputs::PeopleSelect
@includeGroups={{true}}
@includeGroups={{this.configSvc.config.group_approvals}}
@renderInPlace={{true}}
@selected={{this.allApprovers}}
@onChange={{this.updateApprovers}}
Expand Down
24 changes: 13 additions & 11 deletions web/app/routes/authenticated/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,19 @@ export default class AuthenticatedDocumentRoute extends Route {

// Check if the user is a group approver.

const resp = await this.fetchSvc
.fetch(
`/api/${this.configSvc.config.api_version}/approvals/${params.document_id}`,
{ method: "OPTIONS" },
)
.then((r) => r);

const allowed = resp?.headers.get("allowed");

if (allowed?.includes("POST")) {
viewerIsGroupApprover = true;
if (this.configSvc.config.group_approvals) {
const resp = await this.fetchSvc
.fetch(
`/api/${this.configSvc.config.api_version}/approvals/${params.document_id}`,
{ method: "OPTIONS" },
)
.then((r) => r);

const allowed = resp?.headers.get("allowed");

if (allowed?.includes("POST")) {
viewerIsGroupApprover = true;
}
}

const typedDoc = doc as HermesDocument;
Expand Down
1 change: 1 addition & 0 deletions web/mirage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const TEST_WEB_CONFIG = {
google_doc_folders: "",
short_link_base_url: TEST_SHORT_LINK_BASE_URL,
skip_google_auth: false,
group_approvals: true,
google_analytics_tag_id: undefined,
support_link_url: TEST_SUPPORT_URL,
version: "1.2.3",
Expand Down

0 comments on commit 2fa655b

Please sign in to comment.