Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/layout/layout_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { DashboardLayout } from './default';
import { ArticleLayout } from './article';
import { SlidesLayout } from './slides';

// 'default' was renamed to 'dashboard', this is for backwards compatibility
function legacyName(name: string): string {
return name === 'default' ? 'dashboard' : name;
}

export class SpectaLayoutRegistry implements ISpectaLayoutRegistry {
constructor() {
const dashboardLayout = new DashboardLayout();
Expand Down Expand Up @@ -32,14 +37,15 @@ export class SpectaLayoutRegistry implements ISpectaLayoutRegistry {
return this._selectedLayoutChanged;
}
get(name: string): ISpectaLayout | undefined {
return this._registry.get(name);
return this._registry.get(legacyName(name));
}

getDefaultLayout(): ISpectaLayout {
return this._registry.get('article')!;
}

async setSelectedLayout(name: string): Promise<void> {
name = legacyName(name);
if (!this._registry.has(name)) {
throw new Error(`Layout with name ${name} does not exist`);
}
Expand Down
Loading