Skip to content

Commit

Permalink
Fix for #1424
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi749 committed Jan 26, 2024
1 parent 9822793 commit b72b6a0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,61 +67,61 @@ export function useToolbarItems(context: IPortfolioOverviewContext) {
.setStyle({
color: '#10793F'
}),
new ListMenuItem(context.state.currentView?.title, strings.PortfolioViewsListName)
.setIcon(Icons.ContentView)
.setWidth('fit-content')
.setStyle({ minWidth: '145px' })
.setDisabled(context.state.isChangingView)
.setItems(
[
new ListMenuItem(strings.ListViewText)
.setIcon(Icons.AppsList)
.makeCheckable({
name: 'renderMode',
value: 'list'
})
.setOnClick(() => {
context.dispatch(TOGGLE_COMPACT())
}),
new ListMenuItem(strings.CompactViewText)
.setIcon(Icons.TextBulletList)
.makeCheckable({
name: 'renderMode',
value: 'compactList'
})
.setOnClick(() => {
context.dispatch(TOGGLE_COMPACT())
}),
ListMenuItemDivider,
...sharedViews,
ListMenuItemDivider,
ListMenuItemHeader(strings.PersonalViewsHeaderText).makeConditional(
!_.isEmpty(personalViews)
),
...personalViews,
ListMenuItemDivider,
ListMenuItemHeader(strings.ProgramsHeaderText).makeConditional(
!_.isEmpty(programViews)
),
context.props.showProgramViews &&
new ListMenuItem(strings.SelectProgramText)
.setItems(programViews)
.setIcon(Icons.ChevronLeft)
.makeConditional(!_.isEmpty(programViews)),
ListMenuItemDivider.makeConditional(!_.isEmpty(programViews)),
userCanManageViews &&
new ListMenuItem(strings.NewViewText).setIcon(Icons.FormNew).setOnClick(() => {
context.dispatch(SET_VIEW_FORM_PANEL({ isOpen: true }))
}),
userCanManageViews &&
new ListMenuItem(strings.EditViewText).setIcon(Icons.Edit).setOnClick(() => {
context.dispatch(
SET_VIEW_FORM_PANEL({ isOpen: true, view: context.state.currentView })
)
})
],
checkedValues
),
new ListMenuItem(context.state.currentView?.title, strings.PortfolioViewsListName)
.setIcon(Icons.ContentView)
.setWidth('fit-content')
.setStyle({ minWidth: '145px' })
.setDisabled(context.state.isChangingView)
.setItems(
[
new ListMenuItem(strings.ListViewText)
.setIcon(Icons.AppsList)
.makeCheckable({
name: 'renderMode',
value: 'list'
})
.setOnClick(() => {
context.dispatch(TOGGLE_COMPACT())
}),
new ListMenuItem(strings.CompactViewText)
.setIcon(Icons.TextBulletList)
.makeCheckable({
name: 'renderMode',
value: 'compactList'
})
.setOnClick(() => {
context.dispatch(TOGGLE_COMPACT())
}),
ListMenuItemDivider,
...sharedViews,
ListMenuItemDivider,
ListMenuItemHeader(strings.PersonalViewsHeaderText).makeConditional(
!_.isEmpty(personalViews)
),
...personalViews,
ListMenuItemDivider,
ListMenuItemHeader(strings.ProgramsHeaderText).makeConditional(
!_.isEmpty(programViews)
),
context.props.showProgramViews &&
new ListMenuItem(strings.SelectProgramText)
.setItems(programViews)
.setIcon(Icons.ChevronLeft)
.makeConditional(!_.isEmpty(programViews)),
ListMenuItemDivider.makeConditional(!_.isEmpty(programViews)),
userCanManageViews &&
new ListMenuItem(strings.NewViewText).setIcon(Icons.FormNew).setOnClick(() => {
context.dispatch(SET_VIEW_FORM_PANEL({ isOpen: true }))
}),
userCanManageViews &&
new ListMenuItem(strings.EditViewText).setIcon(Icons.Edit).setOnClick(() => {
context.dispatch(
SET_VIEW_FORM_PANEL({ isOpen: true, view: context.state.currentView })
)
})
],
checkedValues
),
context.props.showFilters &&
new ListMenuItem(null, strings.FilterText).setIcon('Filter').setOnClick(() => {
context.dispatch(TOGGLE_FILTER_PANEL())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SitePermissions extends BaseTask {
this._getRoleDefinitions(params.web),
this._getSiteGroups()
])

for (let i = 0; i < permConfig.length; i++) {
const { groupName, permissionLevel } = permConfig[i]
const users = groups[groupName] || []
Expand All @@ -60,18 +61,23 @@ export class SitePermissions extends BaseTask {
}
return params
} catch (error) {
this.logError('Failed to set site permissions from configuration list.')
this.logError(`Failed to set site permissions from configuration list. ${error}`)
return params
}
}

/**
* Get configurations for the selected template from list
* Get configurations for the selected template from list,
* if no template is selected the all configurations are returned.
*
* @returns Permission configurations
*
*/
private async _getPermissionConfiguration(): Promise<IPermissionConfiguration[]> {
const list = SPDataAdapter.portalDataService.web.lists.getByTitle(
strings.PermissionConfigurationList
)

const query: ICamlQuery = {
ViewXml: `<View>
<Query>
Expand All @@ -89,12 +95,13 @@ export class SitePermissions extends BaseTask {
</Query>
</View>`
}

return (await list.getItemsByCAMLQuery(query)).map(
(item: any) =>
({
groupName: item.GtSPGroupName,
permissionLevel: item.GtPermissionLevel
} as IPermissionConfiguration)
({
groupName: item.GtSPGroupName,
permissionLevel: item.GtPermissionLevel
} as IPermissionConfiguration)
)
}

Expand All @@ -121,7 +128,7 @@ export class SitePermissions extends BaseTask {
* @param web Web
*/
private async _getRoleDefinitions(web: any) {
return (await web.roleDefinitions.select('Name', 'Id').get()).reduce(
return (await web.roleDefinitions.select('Name', 'Id')()).reduce(
(rds: { [key: string]: string }, { Name, Id }) => ({
...rds,
[Name]: Id
Expand Down

0 comments on commit b72b6a0

Please sign in to comment.