Aktualisiere Versionsnummer auf 3.1.0 in README.md, package.json, package-lock.json und package-solution.json. Füge CurrentNavigationSettingsProvider hinzu und integriere zugehörige Tests.
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
import { ISettingsProvider } from '../core/ProviderContracts';
|
||||
|
||||
export interface ICurrentNavigationSettings {
|
||||
schemaVersion: number;
|
||||
portalSettings: {
|
||||
providerKey: string;
|
||||
contractVersion: number;
|
||||
minimumPortalSettingsVersion: string;
|
||||
};
|
||||
termSetId: string;
|
||||
termSetName: string;
|
||||
cacheMinutes: number;
|
||||
cacheVersion: string;
|
||||
maxDepth: number;
|
||||
showRoot: boolean;
|
||||
debug: boolean;
|
||||
[key: string]: any; // tslint:disable-line:no-any
|
||||
}
|
||||
|
||||
export const CurrentNavigationSettingsProvider: ISettingsProvider<ICurrentNavigationSettings> = {
|
||||
key: 'currentnavigation',
|
||||
displayName: 'Current Navigation',
|
||||
description: 'Navigation für das jeweils aktuelle Root Web oder Subweb.',
|
||||
iconName: 'BulletedTreeList',
|
||||
schemaVersion: 1,
|
||||
minimumPortalSettingsVersion: '3.1.0',
|
||||
componentIds: ['e37b828f-4315-461a-b1b0-fcf991deda3d'],
|
||||
storage: {
|
||||
kind: 'siteUserCustomAction',
|
||||
action: {
|
||||
name: 'CurrentNavigation',
|
||||
title: 'Current Navigation Application Customizer',
|
||||
description: 'MSFT-Custom-Solution:CurrentNavigation',
|
||||
location: 'ClientSideExtension.ApplicationCustomizer',
|
||||
sequence: 110
|
||||
}
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
key: 'navigation', title: 'Navigation', iconName: 'BranchFork', layout: 'twoColumns',
|
||||
description: 'Termset und Darstellung der Navigation für die aktuelle Website.',
|
||||
elements: [
|
||||
{
|
||||
type: 'termSet', key: 'termSetId', path: 'termSetId', companionNamePath: 'termSetName',
|
||||
label: 'Navigations-Termset', description: 'Das Termset enthält die Root- und Navigationsterms.',
|
||||
required: true, columnSpan: 12
|
||||
},
|
||||
{
|
||||
type: 'number', key: 'maxDepth', path: 'maxDepth', label: 'Maximale Tiefe',
|
||||
description: 'Anzahl der gerenderten Ebenen ab dem Root-Term.', minimum: 1, maximum: 8,
|
||||
suffix: 'Ebenen', columnSpan: 6
|
||||
},
|
||||
{
|
||||
type: 'boolean', key: 'showRoot', path: 'showRoot', label: 'Root-Term anzeigen',
|
||||
description: 'Zeigt den zugeordneten Root-Term als erste Ebene an.', columnSpan: 6
|
||||
},
|
||||
{
|
||||
type: 'notice', appearance: 'info', title: 'Local Custom Properties', columnSpan: 12,
|
||||
text: 'CurrentNavigation.Root = true ordnet einen Term über seine URL einer Website zu. CurrentNavigation.Hidden = true blendet einen Zweig aus.'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'performance', title: 'Performance und Cache', iconName: 'SpeedHigh', layout: 'twoColumns',
|
||||
elements: [
|
||||
{
|
||||
type: 'number', key: 'cacheMinutes', path: 'cacheMinutes', label: 'Cache-Dauer',
|
||||
description: 'Gültigkeitsdauer des Browser-Caches.', minimum: 1, maximum: 1440,
|
||||
suffix: 'Minuten', columnSpan: 6
|
||||
},
|
||||
{
|
||||
type: 'textField', key: 'cacheVersion', path: 'cacheVersion', label: 'Cache-Version',
|
||||
description: 'Eine Änderung verwirft vorhandene Browser-Caches.', placeholder: '1', columnSpan: 6
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'diagnostics', title: 'Diagnose', iconName: 'Diagnostic', layout: 'singleColumn',
|
||||
collapsible: true, collapsedByDefault: true,
|
||||
elements: [{
|
||||
type: 'boolean', key: 'debug', path: 'debug', label: 'Debug-Ausgaben aktivieren',
|
||||
description: 'Schreibt technische Meldungen in die Browserkonsole.', columnSpan: 12
|
||||
}]
|
||||
},
|
||||
{
|
||||
key: 'preview', title: 'Zusammenfassung', layout: 'singleColumn',
|
||||
elements: [
|
||||
{ type: 'propertySummary', title: 'Aktuelle Werte', columnSpan: 12 },
|
||||
{ type: 'jsonPreview', title: 'ClientSideComponentProperties', collapsedByDefault: true, columnSpan: 12 }
|
||||
]
|
||||
}
|
||||
],
|
||||
createDefault: (): ICurrentNavigationSettings => ({
|
||||
schemaVersion: 1,
|
||||
portalSettings: {
|
||||
providerKey: 'currentnavigation', contractVersion: 1, minimumPortalSettingsVersion: '3.1.0'
|
||||
},
|
||||
termSetId: '', termSetName: '', cacheMinutes: 15, cacheVersion: '1',
|
||||
maxDepth: 3, showRoot: false, debug: false
|
||||
}),
|
||||
normalize: (value: any): ICurrentNavigationSettings => { // tslint:disable-line:no-any
|
||||
const source: any = value && typeof value === 'object' ? value : {}; // tslint:disable-line:no-any
|
||||
const result: any = {}; // tslint:disable-line:no-any
|
||||
Object.keys(source).forEach((key: string): void => { result[key] = source[key]; });
|
||||
const minutes: number = Number(source.cacheMinutes);
|
||||
const depth: number = Number(source.maxDepth);
|
||||
result.schemaVersion = 1;
|
||||
result.portalSettings = {
|
||||
providerKey: 'currentnavigation', contractVersion: 1, minimumPortalSettingsVersion: '3.1.0'
|
||||
};
|
||||
result.termSetId = typeof source.termSetId === 'string' ? source.termSetId.trim() : '';
|
||||
result.termSetName = typeof source.termSetName === 'string' ? source.termSetName.trim() : '';
|
||||
result.cacheMinutes = isFinite(minutes) ? Math.min(Math.max(Math.floor(minutes), 1), 1440) : 15;
|
||||
result.cacheVersion = typeof source.cacheVersion === 'string' && source.cacheVersion.trim()
|
||||
? source.cacheVersion.trim() : '1';
|
||||
result.maxDepth = isFinite(depth) ? Math.min(Math.max(Math.floor(depth), 1), 8) : 3;
|
||||
result.showRoot = source.showRoot === true;
|
||||
result.debug = source.debug === true;
|
||||
return result as ICurrentNavigationSettings;
|
||||
},
|
||||
validate: (value: ICurrentNavigationSettings): string[] => {
|
||||
const errors: string[] = [];
|
||||
if (!value.termSetId) { errors.push('Bitte ein Navigations-Termset auswählen.'); }
|
||||
if (value.termSetId && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value.termSetId)) {
|
||||
errors.push('Die Termset-ID ist keine gültige GUID.');
|
||||
}
|
||||
if (value.cacheMinutes < 1 || value.cacheMinutes > 1440) {
|
||||
errors.push('Die Cache-Dauer muss zwischen 1 und 1440 liegen.');
|
||||
}
|
||||
if (value.maxDepth < 1 || value.maxDepth > 8) {
|
||||
errors.push('Die maximale Tiefe muss zwischen 1 und 8 liegen.');
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
};
|
||||
@@ -1,10 +1,12 @@
|
||||
import { ISettingsProvider } from '../core/ProviderContracts';
|
||||
import { CustomBrandingSettingsProvider } from './CustomBrandingSettingsProvider';
|
||||
import { CurrentNavigationSettingsProvider } from './CurrentNavigationSettingsProvider';
|
||||
import { ExpiryIndicatorSettingsProvider } from './ExpiryIndicatorSettingsProvider';
|
||||
import { MegaMenuSettingsProvider } from './MegaMenuSettingsProvider';
|
||||
|
||||
const Providers: Array<ISettingsProvider<any>> = [ // tslint:disable-line:no-any
|
||||
MegaMenuSettingsProvider,
|
||||
CurrentNavigationSettingsProvider,
|
||||
CustomBrandingSettingsProvider,
|
||||
ExpiryIndicatorSettingsProvider
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user