From b72b6a0b3f05514ec5d1b3b8fac1bd73e5c40413 Mon Sep 17 00:00:00 2001 From: Remi Blom-Ohlsen Date: Fri, 26 Jan 2024 13:49:54 +0100 Subject: [PATCH] Fix for #1424 --- .../ToolbarItems/useToolbarItems.ts | 110 +++++++++--------- .../tasks/SitePermissions/index.ts | 21 ++-- 2 files changed, 69 insertions(+), 62 deletions(-) diff --git a/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/ToolbarItems/useToolbarItems.ts b/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/ToolbarItems/useToolbarItems.ts index 8601da96a..327fdbb9b 100644 --- a/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/ToolbarItems/useToolbarItems.ts +++ b/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/ToolbarItems/useToolbarItems.ts @@ -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()) diff --git a/SharePointFramework/ProjectExtensions/src/projectSetup/tasks/SitePermissions/index.ts b/SharePointFramework/ProjectExtensions/src/projectSetup/tasks/SitePermissions/index.ts index 3ce82be84..64e048b06 100644 --- a/SharePointFramework/ProjectExtensions/src/projectSetup/tasks/SitePermissions/index.ts +++ b/SharePointFramework/ProjectExtensions/src/projectSetup/tasks/SitePermissions/index.ts @@ -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] || [] @@ -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 { const list = SPDataAdapter.portalDataService.web.lists.getByTitle( strings.PermissionConfigurationList ) + const query: ICamlQuery = { ViewXml: ` @@ -89,12 +95,13 @@ export class SitePermissions extends BaseTask { ` } + return (await list.getItemsByCAMLQuery(query)).map( (item: any) => - ({ - groupName: item.GtSPGroupName, - permissionLevel: item.GtPermissionLevel - } as IPermissionConfiguration) + ({ + groupName: item.GtSPGroupName, + permissionLevel: item.GtPermissionLevel + } as IPermissionConfiguration) ) } @@ -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