From 0466260734e1130a22b9490d89ca8cbc6c052c16 Mon Sep 17 00:00:00 2001 From: soujash-mandal <2002soujash@gmail.com> Date: Sat, 22 Jul 2023 16:51:22 +0530 Subject: [PATCH 1/5] navbar changes --- web/app/components/header/nav.hbs | 15 +++++++++------ web/app/styles/components/nav.scss | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/web/app/components/header/nav.hbs b/web/app/components/header/nav.hbs index 0470b7c86..03a8d2857 100644 --- a/web/app/components/header/nav.hbs +++ b/web/app/components/header/nav.hbs @@ -38,16 +38,19 @@
diff --git a/web/app/styles/components/nav.scss b/web/app/styles/components/nav.scss index e2521b05d..afd458570 100644 --- a/web/app/styles/components/nav.scss +++ b/web/app/styles/components/nav.scss @@ -33,6 +33,9 @@ .user-buttons { @apply flex items-center justify-end space-x-1.5 sm:ml-6 md:ml-8 order-4; + .navbar-button{ + white-space: nowrap; + } } .user-avatar { From 1a7f7021ba25d75935f7224035a03510028d2ec7 Mon Sep 17 00:00:00 2001 From: soujash-mandal <2002soujash@gmail.com> Date: Sun, 23 Jul 2023 01:08:14 +0530 Subject: [PATCH 2/5] Due Date set due date can see due date in badge format of three colours 1. critical if due date is passed 2. warning if today is the due date 3. success in more than one days left one table column of due date is attached in the tables of drafts, all docs and my docs --- internal/api/documents.go | 11 +- internal/api/drafts.go | 5 +- pkg/hashicorpdocs/basedoc.go | 7 + pkg/models/document.go | 2 + .../components/dashboard/latest-updates.hbs | 1 + web/app/components/doc/row.hbs | 7 + web/app/components/doc/tile.hbs | 16 +- web/app/components/doc/tile.ts | 32 ++ web/app/components/document/sidebar.hbs | 41 ++ web/app/components/document/sidebar.ts | 9 +- web/app/components/row-results.hbs | 2 + web/app/helpers/dateformat.ts | 29 ++ web/app/templates/authenticated/dashboard.hbs | 396 ++++++++++-------- web/app/types/document.d.ts | 1 + 14 files changed, 365 insertions(+), 194 deletions(-) create mode 100644 web/app/helpers/dateformat.ts diff --git a/internal/api/documents.go b/internal/api/documents.go index e9cbf4a56..8a8c746e1 100644 --- a/internal/api/documents.go +++ b/internal/api/documents.go @@ -23,6 +23,7 @@ import ( // to be updated with a PATCH request. type DocumentPatchRequest struct { Reviewers []string `json:"reviewers,omitempty"` + DueDate string `json:"dueDate,omitempty"` Contributors []string `json:"contributors,omitempty"` Status string `json:"status,omitempty"` Summary string `json:"summary,omitempty"` @@ -212,17 +213,17 @@ func DocumentHandler( ) case "PATCH": - canPatchDocument:=true + canPatchDocument := true // Authorize request (only the owner can PATCH the doc). userEmail := r.Context().Value("userEmail").(string) for _, reviewer := range docObj.GetReviewers() { - if reviewer==userEmail { - canPatchDocument=false + if reviewer == userEmail { + canPatchDocument = false break } } - if userEmail==docObj.GetOwners()[0] { - canPatchDocument=false + if userEmail == docObj.GetOwners()[0] { + canPatchDocument = false } if canPatchDocument { diff --git a/internal/api/drafts.go b/internal/api/drafts.go index 255589761..0561b1a77 100644 --- a/internal/api/drafts.go +++ b/internal/api/drafts.go @@ -26,7 +26,8 @@ import ( ) type DraftsRequest struct { - Reviewers []string `json:"approvers,omitempty"` + Reviewers []string `json:"reviewers,omitempty"` + DueDate string `json:"dueDate,omitempty"` Contributors []string `json:"contributors,omitempty"` DocType string `json:"docType,omitempty"` Product string `json:"product,omitempty"` @@ -40,6 +41,7 @@ type DraftsRequest struct { // be updated with a PATCH request. type DraftsPatchRequest struct { Reviewers []string `json:"reviewers,omitempty"` + DueDate string `json:"dueDate,omitempty"` Contributors []string `json:"contributors,omitempty"` Product string `json:"product,omitempty"` Team string `json:"team,omitempty"` @@ -278,6 +280,7 @@ func DraftsHandler( d := models.Document{ GoogleFileID: f.Id, Reviewers: reviewers, + DueDate: req.DueDate, Contributors: contributors, DocumentCreatedAt: createdTime, DocumentModifiedAt: createdTime, diff --git a/pkg/hashicorpdocs/basedoc.go b/pkg/hashicorpdocs/basedoc.go index 6f0009acf..10b2eabd3 100644 --- a/pkg/hashicorpdocs/basedoc.go +++ b/pkg/hashicorpdocs/basedoc.go @@ -29,6 +29,9 @@ type BaseDoc struct { // are requested for the document. Reviewers []string `json:"reviewers,omitempty"` + // last date to review a doc for a reviewer + DueDate string `json:"dueDate,omitempty"` + // ChangesRequestedBy is a slice of email address strings for users that have // requested changes for the document. ChangesRequestedBy []string `json:"changesRequestedBy,omitempty"` @@ -108,6 +111,10 @@ func (d BaseDoc) GetReviewers() []string { return d.Reviewers } +func (d BaseDoc) GetDueDate() string { + return d.DueDate +} + func (d BaseDoc) GetChangesRequestedBy() []string { return d.ChangesRequestedBy } diff --git a/pkg/models/document.go b/pkg/models/document.go index ba0d1237c..266a0b273 100644 --- a/pkg/models/document.go +++ b/pkg/models/document.go @@ -23,6 +23,8 @@ type Document struct { // document. Reviewers []*User `gorm:"many2many:document_reviews;"` + // last date to review a doc for a reviewer + DueDate string // Contributors are users who have contributed to the document. Contributors []*User `gorm:"many2many:document_contributors;"` diff --git a/web/app/components/dashboard/latest-updates.hbs b/web/app/components/dashboard/latest-updates.hbs index 054ff87b4..aced9a167 100644 --- a/web/app/components/dashboard/latest-updates.hbs +++ b/web/app/components/dashboard/latest-updates.hbs @@ -45,6 +45,7 @@ @status={{lowercase doc.status}} @thumbnail={{doc.googleMetadata.thumbnailLink}} @title={{doc.title}} + @dueDate={{doc.dueDate}} /> {{/each}}
diff --git a/web/app/components/doc/row.hbs b/web/app/components/doc/row.hbs index 57ee3912d..f42448ad8 100644 --- a/web/app/components/doc/row.hbs +++ b/web/app/components/doc/row.hbs @@ -37,4 +37,11 @@ {{@createdDate}} + + {{#if (not (is-empty @dueDate))}} + {{dateformat @dueDate}} + {{else}} + No Due Date + {{/if}} + diff --git a/web/app/components/doc/tile.hbs b/web/app/components/doc/tile.hbs index 37c7a6f45..b9b07b05f 100644 --- a/web/app/components/doc/tile.hbs +++ b/web/app/components/doc/tile.hbs @@ -33,8 +33,22 @@ @text={{this.productAreaName}} @icon={{or (get-product-id this.this.args.productArea) "folder"}} /> + {{#if (not (is-empty @dueDate))}} + {{#if this.isDueDateOverdue}} + + {{else if this.isDueDateToday}} + + {{else}} + + {{/if}} + {{else}} + + {{/if}} {{#if (and @isResult @snippet)}} {{/if}} - + \ No newline at end of file diff --git a/web/app/components/doc/tile.ts b/web/app/components/doc/tile.ts index c9e75a7b9..77f7cccae 100644 --- a/web/app/components/doc/tile.ts +++ b/web/app/components/doc/tile.ts @@ -1,4 +1,5 @@ import Component from "@glimmer/component"; +import parseDate from "hermes/utils/parse-date"; interface DocTileComponentSignature { Args: { @@ -14,6 +15,7 @@ interface DocTileComponentSignature { status?: string; thumbnail?: string; title?: string; + dueDate?:string; }; } @@ -28,6 +30,36 @@ export default class DocTileComponent extends Componentdate) { + return true; + } + return false; + } + get isDueDateToday() : boolean { + if (this.currentDate==this.args.dueDate) { + return true; + } + return false; + } + + } declare module "@glint/environment-ember-loose/registry" { diff --git a/web/app/components/document/sidebar.hbs b/web/app/components/document/sidebar.hbs index 174534080..ad60d172f 100644 --- a/web/app/components/document/sidebar.hbs +++ b/web/app/components/document/sidebar.hbs @@ -279,6 +279,47 @@ {{/if}} +
+ Due Date + {{#if this.editingIsDisabled}} +

{{dateformat @document.dueDate}}

+ {{else}} + + <:default> + {{#unless (is-empty @document.dueDate)}} +

+ {{dateformat @document.dueDate}}

+ {{else}} +

+ Enter due date here

+ {{/unless}} + + <:editing as |F|> + + +
+ {{/if}} +
+
Created diff --git a/web/app/components/document/sidebar.ts b/web/app/components/document/sidebar.ts index 242724276..2b36e2b55 100644 --- a/web/app/components/document/sidebar.ts +++ b/web/app/components/document/sidebar.ts @@ -61,6 +61,7 @@ export default class DocumentSidebarComponent extends Component { + this.dueDate = date; + await this.save.perform("dueDate", this.dueDate); + // productAbbreviation is computed by the back end + }); + isAllReviewersReviewed( reviewedReviewers: string[], allReviewers: string[] diff --git a/web/app/components/row-results.hbs b/web/app/components/row-results.hbs index b6ed0e2e5..3618f6d02 100644 --- a/web/app/components/row-results.hbs +++ b/web/app/components/row-results.hbs @@ -22,6 +22,7 @@ Product/Area Owner Created + Due Date <:body> @@ -37,6 +38,7 @@ @status="{{lowercase doc.status}}" @title="{{doc.title}}" @isDraft={{@isDraft}} + @dueDate="{{doc.dueDate}}" /> {{/each}} diff --git a/web/app/helpers/dateformat.ts b/web/app/helpers/dateformat.ts new file mode 100644 index 000000000..c44c011cb --- /dev/null +++ b/web/app/helpers/dateformat.ts @@ -0,0 +1,29 @@ +// app/helpers/format-date.ts +import { helper } from '@ember/component/helper'; +const monthNames = [ + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' + ]; +export function dateformat([date]: [string]): string { + let res="",year="",month="",day=""; + let n=date.length; + if (n===0) { + return year; + } + for (let index = 0; index <=3; index++) { + let element = date[index]; + year+=element; + } + for (let index = 5; index <=6; index++) { + let element = date[index]; + month+=element; + } + for (let index = 8; index <=9; index++) { + let element = date[index]; + day+=element; + } + res=`${monthNames[parseInt(month) - 1]} ${day}, ${year}` + return res; +} + +export default helper(dateformat); diff --git a/web/app/templates/authenticated/dashboard.hbs b/web/app/templates/authenticated/dashboard.hbs index e3ea77cce..1c101f8e2 100644 --- a/web/app/templates/authenticated/dashboard.hbs +++ b/web/app/templates/authenticated/dashboard.hbs @@ -1,236 +1,258 @@ {{page-title "Dashboard"}} -
-
+
+
-

Welcome back, {{this.authenticatedUser.info.given_name}} +

Welcome back, + {{this.authenticatedUser.info.given_name}} {{#if (eq this.authenticatedUser.info.role "Admin")}} - + {{/if}}

- - {{#if (eq this.authenticatedUser.info.role "Admin")}} -
- - + + + {{on "click" (fn this.toggleModal1)}} + /> - + {{on "click" (fn this.toggleModal2)}} + /> - + {{on "click" (fn this.toggleModal3)}} + /> + + +
+ {{/if}} -
-
- {{/if}} -

Here’s all the latest updates across the organization.

- {{#if this.showModal1}} - {{#modal-dialog - onClose=(action (action (mut this.showModal1) false)) - targetAttachment="center" - translucentOverlay=true - }} -
+
\ No newline at end of file diff --git a/web/app/types/document.d.ts b/web/app/types/document.d.ts index 62ef3f542..84f304a1e 100644 --- a/web/app/types/document.d.ts +++ b/web/app/types/document.d.ts @@ -20,6 +20,7 @@ export interface HermesDocument { appCreated?: boolean; contributors?: HermesUser[]; reviewers: HermesUser[]; + dueDate: string; changesRequestedBy?: string[]; reviewedBy: string[]; summary?: string; From 3846dd5304e7dbcfcefc3b07b18e7bc5d0a6d997 Mon Sep 17 00:00:00 2001 From: soujash-mandal <2002soujash@gmail.com> Date: Sun, 23 Jul 2023 02:12:51 +0530 Subject: [PATCH 3/5] sort according to due date --- web/app/routes/authenticated/dashboard.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/app/routes/authenticated/dashboard.js b/web/app/routes/authenticated/dashboard.js index 25fb3abeb..c82f61815 100644 --- a/web/app/routes/authenticated/dashboard.js +++ b/web/app/routes/authenticated/dashboard.js @@ -2,7 +2,7 @@ import Route from "@ember/routing/route"; import RSVP from "rsvp"; import { inject as service } from "@ember/service"; import timeAgo from "hermes/utils/time-ago"; -import {action} from "@ember/object"; +import { action } from "@ember/object"; export default class DashboardRoute extends Route { @service algolia; @@ -44,7 +44,7 @@ export default class DashboardRoute extends Route { ` AND NOT reviewedBy:'${userInfo.email}'` + " AND appCreated:true" + " AND status:In-Review", - hitsPerPage: 4, + hitsPerPage: 1000, }) .then((result) => { // Add modifiedAgo for each doc. @@ -79,7 +79,9 @@ export default class DashboardRoute extends Route { this.recentDocs.all = null; } } - + docsWaitingForReview._result = docsWaitingForReview._result.sort((a, b) => + a.dueDate.localeCompare(b.dueDate) + ); return RSVP.hash({ docsWaitingForReview: docsWaitingForReview, }); @@ -104,5 +106,4 @@ export default class DashboardRoute extends Route { } return parentsQuery; } - } From e07dbf35d7ff93ef79aa33c0437a68228b90ec16 Mon Sep 17 00:00:00 2001 From: soujash-mandal <2002soujash@gmail.com> Date: Sun, 23 Jul 2023 05:43:08 +0530 Subject: [PATCH 4/5] date formatted to MMM DD, YYYY --- web/app/components/row-results.hbs | 3 ++- web/app/routes/authenticated/document.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/web/app/components/row-results.hbs b/web/app/components/row-results.hbs index 3618f6d02..3560f0b04 100644 --- a/web/app/components/row-results.hbs +++ b/web/app/components/row-results.hbs @@ -29,7 +29,8 @@ {{#each @docs as |doc index|}} Date: Sun, 23 Jul 2023 16:52:26 +0530 Subject: [PATCH 5/5] Colours for badge only allowed for docs waiting for me to review --- .../components/dashboard/latest-updates.hbs | 1 + web/app/components/doc/tile.hbs | 26 +++++++++++++------ web/app/components/doc/tile.ts | 1 + web/app/templates/authenticated/dashboard.hbs | 2 ++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/web/app/components/dashboard/latest-updates.hbs b/web/app/components/dashboard/latest-updates.hbs index aced9a167..92fd01e76 100644 --- a/web/app/components/dashboard/latest-updates.hbs +++ b/web/app/components/dashboard/latest-updates.hbs @@ -46,6 +46,7 @@ @thumbnail={{doc.googleMetadata.thumbnailLink}} @title={{doc.title}} @dueDate={{doc.dueDate}} + @showColorBadge={{false}} /> {{/each}}
diff --git a/web/app/components/doc/tile.hbs b/web/app/components/doc/tile.hbs index b9b07b05f..c799d1197 100644 --- a/web/app/components/doc/tile.hbs +++ b/web/app/components/doc/tile.hbs @@ -34,15 +34,25 @@ @icon={{or (get-product-id this.this.args.productArea) "folder"}} /> {{#if (not (is-empty @dueDate))}} - {{#if this.isDueDateOverdue}} - - {{else if this.isDueDateToday}} - + {{#if @showColorBadge}} + {{#if this.isDueDateOverdue}} + + {{else if this.isDueDateToday}} + + {{else}} + + {{/if}} {{else}} - + {{/if}} {{else}} diff --git a/web/app/components/doc/tile.ts b/web/app/components/doc/tile.ts index 77f7cccae..5361e5d9e 100644 --- a/web/app/components/doc/tile.ts +++ b/web/app/components/doc/tile.ts @@ -16,6 +16,7 @@ interface DocTileComponentSignature { thumbnail?: string; title?: string; dueDate?:string; + showColorBadge:boolean; }; } diff --git a/web/app/templates/authenticated/dashboard.hbs b/web/app/templates/authenticated/dashboard.hbs index 1c101f8e2..e4313acc2 100644 --- a/web/app/templates/authenticated/dashboard.hbs +++ b/web/app/templates/authenticated/dashboard.hbs @@ -278,6 +278,7 @@ @status="{{lowercase doc.status}}" @title="{{doc.title}}" @dueDate="{{doc.dueDate}}" + @showColorBadge={{true}} /> {{/if}} {{/each}} @@ -308,6 +309,7 @@ @status={{lowercase r.doc.status}} @title={{r.doc.title}} @dueDate={{r.doc.dueDate}} + @showColorBadge={{false}} /> {{/each}}