From 3d1c8a6c5466f1c626f247f9906c817cfee400a5 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Mon, 24 Jul 2023 11:11:25 -0400 Subject: [PATCH] Remove archived versions from version selector --- domain/document/endpoint.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/domain/document/endpoint.go b/domain/document/endpoint.go index dc960550..170f1625 100644 --- a/domain/document/endpoint.go +++ b/domain/document/endpoint.go @@ -667,23 +667,22 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) { // Get version information for this document. v := []doc.Version{} if len(document.GroupID) > 0 { - // Get versions. + // Get versions vt, err := h.Store.Document.GetVersions(ctx, document.GroupID) if err != nil { response.WriteServerError(w, method, err) h.Runtime.Log.Error(method, err) return } - // What about draft document versions? - if record.DocumentLifecycle { - // We can see and manage document lifecycle so take all versions. - v = vt - } else { - // Only send back LIVE content because user cannot drafts. - for i := range vt { - if vt[i].Lifecycle == workflow.LifecycleLive { - v = append(v, vt[i]) - } + // Determine which document versions user can see. + for i := range vt { + // Everyone can see live documents + if vt[i].Lifecycle == workflow.LifecycleLive { + v = append(v, vt[i]) + } + // Only lifecycle admins can see draft documents + if vt[i].Lifecycle == workflow.LifecycleDraft && record.DocumentLifecycle { + v = append(v, vt[i]) } } }