Skip to content

Commit

Permalink
feat(tinacms): an alerts map can be provided to TinaCMS constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ncphillips committed Sep 14, 2020
1 parent b96e8b9 commit fcee016
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/tinacms/src/tina-cms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
ListOptions,
MediaList,
} from '@tinacms/media'
import { Alerts } from '@tinacms/alerts'
import { Alerts, EventsToAlerts } from '@tinacms/alerts'
import { SidebarState, SidebarStateOptions } from '@tinacms/react-sidebar'
import { ToolbarStateOptions, ToolbarState } from '@tinacms/react-toolbar'
import {
Expand Down Expand Up @@ -75,19 +75,27 @@ export interface TinaCMSConfig extends CMSConfig {
media?: {
store: MediaStore
}
alerts?: EventsToAlerts
}

export class TinaCMS extends CMS {
sidebar?: SidebarState
toolbar?: ToolbarState
media: MediaManager
alerts = new Alerts(this.events)

constructor({ sidebar, media, toolbar, ...config }: TinaCMSConfig = {}) {
alerts: Alerts

constructor({
sidebar,
media,
toolbar,
alerts,
...config
}: TinaCMSConfig = {}) {
super(config)

const mediaStore = media?.store || new DummyMediaStore()
this.media = new MediaManager(mediaStore)
this.alerts = new Alerts(this.events, alerts)

if (sidebar) {
const sidebarConfig = typeof sidebar === 'object' ? sidebar : undefined
Expand Down

0 comments on commit fcee016

Please sign in to comment.