Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions ui/src/app/auth/auth-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export enum ButtonAction {
CollectionCreate,
CollectionPublish,
CollectionSkillsUpdate,
LibraryExport
LibraryExport,
ExportDraftCollection
}

export const ActionByRoles = new Map<number, string[]>([
Expand All @@ -22,7 +23,8 @@ export const ActionByRoles = new Map<number, string[]>([
[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
5 changes: 4 additions & 1 deletion ui/src/app/collection/detail/manage-collection.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down