From fc7d39c67636f83797ebfaa4549576093d625dd8 Mon Sep 17 00:00:00 2001 From: manuel-delvillar <68391066+manuel-delvillar@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:11:05 -0600 Subject: [PATCH 1/3] Download draft collection - Download draft collection is only available for admin. - Download published collection is available for all roles. --- .../collection/detail/manage-collection.component.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/app/collection/detail/manage-collection.component.ts b/ui/src/app/collection/detail/manage-collection.component.ts index 552cbe93c..b43d36b8a 100644 --- a/ui/src/app/collection/detail/manage-collection.component.ts +++ b/ui/src/app/collection/detail/manage-collection.component.ts @@ -13,9 +13,9 @@ import {determineFilters, PublishStatus} from "../../PublishStatus" import {ApiSkillSummary} from "../../richskill/ApiSkillSummary" import {Observable, of, Subject, throwError} from "rxjs" import {TableActionBarComponent} from "../../table/skills-library-table/table-action-bar.component" -import {Title} from "@angular/platform-browser"; -import {AuthService} from "../../auth/auth-service"; -import {ButtonAction} from "../../auth/auth-roles"; +import {Title} from "@angular/platform-browser" +import {AuthService} from "../../auth/auth-service" +import {ButtonAction} from "../../auth/auth-roles" import {formatDate} from "@angular/common" import * as FileSaver from "file-saver" import {ITaskResult} from "../../task/ApiTaskResult" @@ -226,7 +226,10 @@ export class ManageCollectionComponent extends SkillsListComponent implements On ) } - if ((this.collection?.status === PublishStatus.Draft || this.collection?.status === PublishStatus.Published) && this.authService.isEnabledByRoles(ButtonAction.LibraryExport)) { + const isPublished = this.collection?.status === PublishStatus.Published + const isDraftAndUserIsAdmin = this.collection?.status === PublishStatus.Draft + && this.authService.isEnabledByRoles(ButtonAction.ExportDraftCollection) + if (isPublished || isDraftAndUserIsAdmin) { actions.push(new TableActionDefinition({ label: "Download CSV", icon: this.downloadIcon, From faf5aab5319c8db9ccd024b28786e53d10cc6f7b Mon Sep 17 00:00:00 2001 From: manuel-delvillar <68391066+manuel-delvillar@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:19:22 -0600 Subject: [PATCH 2/3] Revert changes in import --- ui/src/app/collection/detail/manage-collection.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/app/collection/detail/manage-collection.component.ts b/ui/src/app/collection/detail/manage-collection.component.ts index b43d36b8a..d5466e958 100644 --- a/ui/src/app/collection/detail/manage-collection.component.ts +++ b/ui/src/app/collection/detail/manage-collection.component.ts @@ -13,9 +13,9 @@ import {determineFilters, PublishStatus} from "../../PublishStatus" import {ApiSkillSummary} from "../../richskill/ApiSkillSummary" import {Observable, of, Subject, throwError} from "rxjs" import {TableActionBarComponent} from "../../table/skills-library-table/table-action-bar.component" -import {Title} from "@angular/platform-browser" -import {AuthService} from "../../auth/auth-service" -import {ButtonAction} from "../../auth/auth-roles" +import {Title} from "@angular/platform-browser"; +import {AuthService} from "../../auth/auth-service"; +import {ButtonAction} from "../../auth/auth-roles"; import {formatDate} from "@angular/common" import * as FileSaver from "file-saver" import {ITaskResult} from "../../task/ApiTaskResult" From f000e97efe26d0a4b1dc894ff5abbfa5f3e783ff Mon Sep 17 00:00:00 2001 From: manuel-delvillar <68391066+manuel-delvillar@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:24:58 -0600 Subject: [PATCH 3/3] Update auth-roles --- ui/src/app/auth/auth-roles.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/src/app/auth/auth-roles.ts b/ui/src/app/auth/auth-roles.ts index b8f5e1aca..83bdd355a 100644 --- a/ui/src/app/auth/auth-roles.ts +++ b/ui/src/app/auth/auth-roles.ts @@ -11,7 +11,8 @@ export enum ButtonAction { CollectionCreate, CollectionPublish, CollectionSkillsUpdate, - LibraryExport + LibraryExport, + ExportDraftCollection } export const ActionByRoles = new Map([ @@ -22,7 +23,8 @@ export const ActionByRoles = new Map([ [ButtonAction.CollectionCreate, [OSMT_ADMIN, OSMT_CURATOR]], [ButtonAction.CollectionPublish, [OSMT_ADMIN]], [ButtonAction.CollectionSkillsUpdate, [OSMT_ADMIN]], - [ButtonAction.LibraryExport, [OSMT_ADMIN]] + [ButtonAction.LibraryExport, [OSMT_ADMIN]], + [ButtonAction.ExportDraftCollection, [OSMT_ADMIN]] ]) //TODO migrate AuthServiceWgu & AuthService.hasRole & isEnabledByRoles into a singleton here. HDN Sept 15, 2022