diff --git a/src/panels/calendar/ha-panel-calendar.ts b/src/panels/calendar/ha-panel-calendar.ts index f775d8b02e..c182d3484c 100644 --- a/src/panels/calendar/ha-panel-calendar.ts +++ b/src/panels/calendar/ha-panel-calendar.ts @@ -1,7 +1,7 @@ import { ResizeController } from "@lit-labs/observers/resize-controller"; import "@material/mwc-list"; import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item"; -import { mdiChevronDown, mdiRefresh } from "@mdi/js"; +import { mdiChevronDown, mdiPlus, mdiRefresh } from "@mdi/js"; import { CSSResultGroup, LitElement, @@ -32,6 +32,8 @@ import { fetchCalendarEvents, getCalendars, } from "../../data/calendar"; +import { fetchIntegrationManifest } from "../../data/integration"; +import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-config-flow"; import { haStyle } from "../../resources/styles"; import type { CalendarViewChanged, HomeAssistant } from "../../types"; import "./ha-full-calendar"; @@ -119,7 +121,7 @@ class PanelCalendar extends LitElement { ); const showPane = this._showPaneController.value ?? !this.narrow; return html` - + ${calendarItems} +
  • + + + ${this.hass.localize("ui.components.calendar.create_calendar")} + ` : html`
    ${this.hass.localize("ui.components.calendar.my_calendars")} @@ -157,7 +164,15 @@ class PanelCalendar extends LitElement { @click=${this._handleRefresh} > ${showPane - ? html`${calendarItems}` + ? html`${calendarItems} + + + ${this.hass.localize("ui.components.calendar.create_calendar")} + ` : nothing} { + showConfigFlowDialog(this, { + startFlowHandler: "local_calendar", + showAdvanced: this.hass.userData?.showAdvanced, + manifest: await fetchIntegrationManifest(this.hass, "local_calendar"), + dialogClosedCallback: ({ flowFinished }) => { + if (flowFinished) { + this._calendars = getCalendars(this.hass); + } + }, + }); + } + private async _handleViewChanged( ev: HASSDomEvent ): Promise { diff --git a/src/translations/en.json b/src/translations/en.json index 7bc526ff71..e527941fef 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -671,6 +671,7 @@ "calendar": { "label": "Calendar", "my_calendars": "My calendars", + "create_calendar": "Create calendar", "today": "Today", "event_retrieval_error": "Could not retrieve events for calendars:", "event": {