Aktualisiere Versionsnummer auf 3.2.1 in README.md, package.json, package-lock.json und package-solution.json. Füge Unterstützung für Root-Web-UserCustomActions in PortalSettingsDataService hinzu und aktualisiere Tests entsprechend.
This commit is contained in:
@@ -32,13 +32,16 @@ export class PortalSettingsDataService {
|
||||
}
|
||||
|
||||
public load(providers: Array<ISettingsProvider<any>>): Promise<ILoadedSettingsProvider[]> {
|
||||
return Promise.all([this.getSiteActions(), this.getRootProperties()])
|
||||
return Promise.all([this.getSiteActions(), this.getRootWebActions(), this.getRootProperties()])
|
||||
.then((values: any[]): ILoadedSettingsProvider[] => {
|
||||
const actions: IUserCustomActionInfo[] = values[0];
|
||||
const properties: any = values[1];
|
||||
const siteActions: IUserCustomActionInfo[] = values[0];
|
||||
const registrationActions: IUserCustomActionInfo[] = siteActions.concat(values[1]);
|
||||
const properties: any = values[2];
|
||||
const loaded: ILoadedSettingsProvider[] = [];
|
||||
for (let i: number = 0; i < providers.length; i++) {
|
||||
const result: ILoadedSettingsProvider = this.loadProvider(providers[i], actions, properties);
|
||||
const result: ILoadedSettingsProvider = this.loadProvider(
|
||||
providers[i], siteActions, registrationActions, properties
|
||||
);
|
||||
if (result) { loaded.push(result); }
|
||||
}
|
||||
return loaded;
|
||||
@@ -178,13 +181,14 @@ export class PortalSettingsDataService {
|
||||
|
||||
private loadProvider(
|
||||
provider: ISettingsProvider<any>,
|
||||
actions: IUserCustomActionInfo[],
|
||||
siteActions: IUserCustomActionInfo[],
|
||||
registrationActions: IUserCustomActionInfo[],
|
||||
properties: any
|
||||
): ILoadedSettingsProvider | undefined {
|
||||
let raw: any;
|
||||
const context: IProviderLoadContext = {};
|
||||
if (provider.storage.kind === 'siteUserCustomAction') {
|
||||
const action: IUserCustomActionInfo = this.findAction(provider, actions);
|
||||
const action: IUserCustomActionInfo = this.findAction(provider, siteActions);
|
||||
if (!action && !provider.storage.action) { return undefined; }
|
||||
if (action) {
|
||||
context.action = action;
|
||||
@@ -197,7 +201,7 @@ export class PortalSettingsDataService {
|
||||
const stored: any = this.getProperty(properties, propertyKey);
|
||||
const descriptor: any = this.getProperty(properties, DescriptorProperty);
|
||||
const bindingsValue: any = this.getProperty(properties, BindingsProperty);
|
||||
const registration: IUserCustomActionInfo = this.findAnyAction(provider, actions);
|
||||
const registration: IUserCustomActionInfo = this.findAnyAction(provider, registrationActions);
|
||||
if (!stored && !descriptor && !bindingsValue && !registration) { return undefined; }
|
||||
if (registration) { context.action = registration; }
|
||||
raw = this.parseJson(stored, provider.createDefault());
|
||||
@@ -218,8 +222,18 @@ export class PortalSettingsDataService {
|
||||
private getSiteActions(): Promise<IUserCustomActionInfo[]> {
|
||||
const url: string = this.siteUrl + '/_api/site/UserCustomActions' +
|
||||
'?$select=Id,Title,Name,Location,ClientSideComponentId,ClientSideComponentProperties';
|
||||
return this.getActions(url, 'Site-Collection-UserCustomActions konnten nicht gelesen werden.');
|
||||
}
|
||||
|
||||
private getRootWebActions(): Promise<IUserCustomActionInfo[]> {
|
||||
const url: string = this.siteUrl + '/_api/site/rootweb/UserCustomActions' +
|
||||
'?$select=Id,Title,Name,Location,ClientSideComponentId,ClientSideComponentProperties';
|
||||
return this.getActions(url, 'Root-Web-UserCustomActions konnten nicht gelesen werden.');
|
||||
}
|
||||
|
||||
private getActions(url: string, errorMessage: string): Promise<IUserCustomActionInfo[]> {
|
||||
return this.context.spHttpClient.get(url, SPHttpClient.configurations.v1, { headers: this.readHeaders() })
|
||||
.then((response: SPHttpClientResponse): Promise<any> => this.ensureJson(response, 'UserCustomActions konnten nicht gelesen werden.'))
|
||||
.then((response: SPHttpClientResponse): Promise<any> => this.ensureJson(response, errorMessage))
|
||||
.then((payload: any): IUserCustomActionInfo[] => this.results(payload).map((source: any): IUserCustomActionInfo => ({
|
||||
id: this.normalizeGuid(source.Id),
|
||||
title: source.Title || '',
|
||||
|
||||
Reference in New Issue
Block a user