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
26 changes: 12 additions & 14 deletions ui/src/app/richskill/list/skills-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,32 +388,30 @@ describe("SkillsListComponent", () => {
expect(action3.callback?.(action3, skill3)).toBeFalsy() // Always false
expect(action3.visible?.(skill3)).toBeFalsy() // != Archived

const actionExportSelected = tableActions[4]
expect(actionExportSelected.label).toEqual("Export Selected")

component.selectedSkills = [
createMockSkillSummary("id1", PublishStatus.Draft),
]
component.showAddToCollection = true
tableActions = component.tableActions()
let skill5 = createMockSkillSummary("id4", PublishStatus.Archived)
let action5 = tableActions[5]
expect(action5.label).toEqual("Add to Collection")
expect(action5 && action5.callback).toBeTruthy()
expect(action5.callback?.(action5, skill5)).toBeFalsy() // Always false
expect(action5.visible?.(skill5)).toBeTruthy() // There are selected skills
let skill4 = createMockSkillSummary("id4", PublishStatus.Archived)
let action4 = tableActions[4]
expect(action4.label).toEqual("Add to Collection")
expect(action4 && action4.callback).toBeTruthy()
expect(action4.callback?.(action4, skill4)).toBeFalsy() // Always false
expect(action4.visible?.(skill4)).toBeTruthy() // There are selected skills

component.selectedSkills = [
createMockSkillSummary("id1", PublishStatus.Draft),
]
component.showAddToCollection = false
tableActions = component.tableActions()
skill5 = createMockSkillSummary("id4", PublishStatus.Archived)
action5 = tableActions[5]
expect(action5.label).toEqual("Remove from Collection")
expect(action5 && action5.callback).toBeTruthy()
expect(action5.callback?.(action5, skill5)).toBeFalsy() // Always false
expect(action5.visible?.(skill5)).toBeTruthy() // There are selected skills
skill4 = createMockSkillSummary("id4", PublishStatus.Archived)
action4 = tableActions[4]
expect(action4.label).toEqual("Remove from Collection")
expect(action4 && action4.callback).toBeTruthy()
expect(action4.callback?.(action4, skill4)).toBeFalsy() // Always false
expect(action4.visible?.(skill4)).toBeTruthy() // There are selected skills
})

it("getSelectedSkills should be correct", () => {
Expand Down
12 changes: 8 additions & 4 deletions ui/src/app/richskill/list/skills-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class SkillsListComponent extends QuickLinksHelper {
showLibraryEmptyMessage = false

showAddToCollection = true
showExportSelected = false

constructor(protected router: Router,
protected richSkillService: RichSkillService,
Expand Down Expand Up @@ -231,14 +232,17 @@ export class SkillsListComponent extends QuickLinksHelper {
icon: "unarchive",
callback: (action: TableActionDefinition, skill?: ApiSkillSummary) => this.handleClickUnarchive(action, skill),
visible: (skill?: ApiSkillSummary) => this.unarchiveVisible(skill)
}),
new TableActionDefinition({
})
]

if (this.showExportSelected) {
actions.push(new TableActionDefinition({
label: "Export Selected",
icon: "download",
callback: (action: TableActionDefinition, kill?: ApiSkillSummary) => this.handleClickExportSearch(),
visible: () => this.exportSearchVisible()
})
]
}))
}

if (this.showAddToCollection) {
actions.push(new TableActionDefinition({
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/search/rich-skill-search-results.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ describe("RichSkillSearchResultsComponent", () => {
expect(component).toBeTruthy()
})

it("table actions should be correct", () => {
const tableActions = component.tableActions()
const actionExportSelected = tableActions[4]
expect(actionExportSelected.label).toEqual("Export Selected")
expect(tableActions.length).toEqual(6)
})

it("should handle empty search query", () => {
// Arrange
const query = "some query"
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/search/rich-skill-search-results.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class RichSkillSearchResultsComponent extends SkillsListComponent impleme

selectAllChecked = false
showSearchEmptyMessage = true
showExportSelected = true
private multiplePagesSelected: boolean = false

constructor(protected router: Router,
Expand Down