Files
raucao 11f8d3f049 WIP: Add calendar settings and a nested modal stack
Add a 'days with events' preference (default 3, range 1-7) that drives the upcoming events widget, and extend the fetch window to 8 days so the largest window can populate.

Add a Calendar settings pane (moved under Integrations) that lists the connected CalDAV/ICS sources in a two-column grid with add/edit/remove, and remove calendars from Manage Integrations.

Turn the modal service into a stack so add/edit forms open on top of the settings dialog, with one dialog per level, per-entry title ids, and a softened stacked backdrop.

Move CALENDAR_ACTOR into its own config module to break the calendar/caldav/ics import cycle.
2026-11-06 15:48:08 +04:00

104 lines
3.3 KiB
Plaintext

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { on } from '@ember/modifier';
export default class SettingsIntegrationsDiscourseForm extends Component {
@service authorization;
@service sites;
@tracked discourseUrl = '';
@tracked error = null;
@action
updateUrl(event) {
this.discourseUrl = event.target.value;
this.error = null;
}
@action
async handleSubmit(event) {
event.preventDefault();
this.error = null;
try {
const { transport } = await this.authorization.start(
'discourse',
this.discourseUrl
);
// In a browser extension the flow completes in place; a web app navigates
// away to the forum and returns through the callback route instead.
if (transport === 'extension') {
await this.sites.reload();
this.args.close?.();
}
} catch (err) {
if (err?.message === 'Please enter a Discourse URL') {
this.error = 'Please enter a Discourse URL';
return;
}
console.error('Error setting up Discourse integration:', err);
this.error =
err instanceof TypeError
? 'Invalid URL. Please enter a valid Discourse forum URL.'
: (err?.message ?? 'Unable to connect to the forum');
}
}
<template>
<div class="p-6">
<h3
id={{if @titleId @titleId "modal-title"}}
class="text-base font-semibold leading-6 text-gray-900"
>Add Discourse Integration</h3>
<div class="mt-2">
<p class="text-sm text-gray-500">
Enter your Discourse forum URL to connect and receive notifications.
</p>
</div>
<form {{on "submit" this.handleSubmit}} class="mt-5">
<div>
<label
for="discourse-url"
class="block text-sm font-medium leading-6 text-gray-900"
>
Discourse URL
</label>
<div class="mt-2">
<input
type="text"
id="discourse-url"
value={{this.discourseUrl}}
{{on "input" this.updateUrl}}
placeholder="forum.example.com"
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
/>
</div>
{{#if this.error}}
<p class="mt-2 text-sm text-red-600">{{this.error}}</p>
{{/if}}
</div>
<div class="mt-5 sm:mt-6 flex gap-3">
<button
type="submit"
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
Continue
</button>
<button
type="button"
{{on "click" @close}}
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
>
Cancel
</button>
</div>
</form>
</div>
</template>
}