Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

feat: add a calendar feed for shared saved views (#706)

Karthik Kulkarniffb74a493dbc
diff --git a/apps/api/src/modules/share/__tests__/integration/calendar.test.ts b/apps/api/src/modules/share/__tests__/integration/calendar.test.ts
new file mode 100644
index 00000000..ee727843
--- /dev/null
+++ b/apps/api/src/modules/share/__tests__/integration/calendar.test.ts
@@ -0,0 +1,151 @@
+import { describe, it, expect, beforeEach } from 'bun:test';
+import { app, authedApi, createProject } from '#tests/helpers/app';
+import { signUpTestUser } from '#tests/helpers/auth';
+import { resetDb } from '#tests/helpers/db';
+
+// The public calendar feed of a shared view. It reuses the view's share token and
+// its filters, and turns each dated issue into an all-day event.
+
+async function setup() {
+ const owner = await signUpTestUser();
+ const asOwner = authedApi(owner.cookie);
+ await createProject(asOwner, { key: 'MKT', name: 'Marketing' });
+ const board = await asOwner.projects({ projectKey: 'MKT' }).get();
+ const columnId = board.data!.columns[0].id;
+ const issue = await asOwner
+ .projects({ projectKey: 'MKT' })
+ .issues.post({ columnId, title: 'Shared thing' });
+ return { asOwner, columnId, issueId: issue.data!.id, board: board.data! };
+}
+
+// The dotted last segment is outside the Eden client's route map, so call the app.
+async function getFeed(token: string) {
+ const res = await app.handle(new Request(`http://localhost/share/view/${token}/calendar.ics`));
+ return {
+ status: res.status,
+ contentType: res.headers.get('content-type'),
+ body: await res.text(),
+ };
+}
+
+function shareView(asOwner: ReturnType<typeof authedApi>, viewId: number, extended?: boolean) {
+ return extended === undefined
+ ? asOwner.views({ viewId }).share.post()
+ : asOwner.views({ viewId }).share.post({ extended });
+}
+
+describe('shared view calendar feed', () => {
+ beforeEach(async () => {
+ await resetDb();
+ });
+
+ it('serves an all-day event for each dated issue', async () => {
+ const { asOwner, columnId, issueId } = await setup();
+ await asOwner.issues({ issueId }).patch({ dueDate: '2026-11-03' });
+ const undated = await asOwner
+ .projects({ projectKey: 'MKT' })
+ .issues.post({ columnId, title: 'No date' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({ name: 'Board' });
+ const token = (await shareView(asOwner, view.data!.id)).data!.token;
+
+ const feed = await getFeed(token);
+ expect(feed.status).toBe(200);
+ expect(feed.contentType).toContain('text/calendar');
+ expect(feed.body).toContain('BEGIN:VCALENDAR');
+ expect(feed.body).toContain('X-WR-CALNAME:Board');
+ expect(feed.body).toContain(`UID:issue-${issueId}@itsaplan`);
+ expect(feed.body).toContain('DTSTART;VALUE=DATE:20261103');
+ expect(feed.body).toContain('DTEND;VALUE=DATE:20261104');
+ expect(feed.body).toContain('SUMMARY:MKT-1 Shared thing');
+ expect(feed.body).not.toContain(`issue-${undated.data!.id}@itsaplan`);
+ expect(feed.body.endsWith('\r\n')).toBe(true);
+ });
+
+ it('uses the start date the view places issues by', async () => {
+ const { asOwner, issueId } = await setup();
+ const patched = await asOwner.issues({ issueId }).patch({ startDate: '2026-12-01' });
+ expect(patched.status).toBe(200);
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({
+ name: 'Calendar',
+ display: { calendarDateField: 'startDate' },
+ });
+ const token = (await shareView(asOwner, view.data!.id)).data!.token;
+
+ const feed = await getFeed(token);
+ expect(feed.body).toContain('DTSTART;VALUE=DATE:20261201');
+ });
+
+ it('uses a custom date field only when the link exposes it', async () => {
+ const { asOwner, issueId } = await setup();
+ await asOwner.issues({ issueId }).patch({ dueDate: '2026-11-03' });
+ const field = await asOwner
+ .projects({ projectKey: 'MKT' })
+ ['custom-fields'].post({ name: 'Ship on', fieldType: 'date' });
+ await asOwner
+ .issues({ issueId })
+ .fields({ fieldId: field.data!.id })
+ .put({ value: '2026-12-15' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({
+ name: 'Calendar',
+ display: { calendarDateField: `cf:${field.data!.id}` },
+ });
+ const viewId = view.data!.id;
+
+ const token = (await shareView(asOwner, viewId, true)).data!.token;
+ expect((await getFeed(token)).body).toContain('DTSTART;VALUE=DATE:20261215');
+
+ // The same view without full issue details hides the custom field value, so the
+ // feed falls back to the due date.
+ await shareView(asOwner, viewId, false);
+ expect((await getFeed(token)).body).toContain('DTSTART;VALUE=DATE:20261103');
+ });
+
+ it('keeps the view filters', async () => {
+ const { asOwner, board, columnId, issueId } = await setup();
+ await asOwner.issues({ issueId }).patch({ dueDate: '2026-11-03' });
+ const hiddenColumn = board.columns[1].id;
+ const hidden = await asOwner
+ .projects({ projectKey: 'MKT' })
+ .issues.post({ columnId: hiddenColumn, title: 'Hidden' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({
+ name: 'Filtered',
+ filters: { conditions: [{ id: 'c1', field: 'status', op: 'is', values: [columnId] }] },
+ });
+ const token = (await shareView(asOwner, view.data!.id)).data!.token;
+
+ const feed = await getFeed(token);
+ expect(feed.body).toContain(`issue-${issueId}@itsaplan`);
+ expect(feed.body).not.toContain(`issue-${hidden.data!.id}@itsaplan`);
+ });
+
+ it('escapes the title and folds long lines', async () => {
+ const { asOwner, issueId } = await setup();
+ const title = `Ship, review; today ${'x'.repeat(90)}`;
+ await asOwner.issues({ issueId }).patch({ title, dueDate: '2026-11-03' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({ name: 'Board' });
+ const token = (await shareView(asOwner, view.data!.id)).data!.token;
+
+ const feed = await getFeed(token);
+ const unfolded = feed.body.replace(/\r\n[ ]/g, '');
+ expect(unfolded).toContain(`SUMMARY:MKT-1 Ship\\, review\\; today ${'x'.repeat(90)}`);
+ for (const line of feed.body.split('\r\n')) {
+ expect(new TextEncoder().encode(line).length).toBeLessThanOrEqual(75);
+ }
+ });
+
+ it('revokes the feed when the view link is revoked', async () => {
+ const { asOwner, issueId } = await setup();
+ await asOwner.issues({ issueId }).patch({ dueDate: '2026-11-03' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).views.post({ name: 'Board' });
+ const token = (await shareView(asOwner, view.data!.id)).data!.token;
+ expect((await getFeed(token)).status).toBe(200);
+
+ await asOwner.views({ viewId: view.data!.id }).share.delete();
+ expect((await getFeed(token)).status).toBe(404);
+ });
+
+ it('rejects a malformed token and 404s an unknown one', async () => {
+ expect((await getFeed('not-a-uuid')).status).toBe(400);
+ expect((await getFeed('00000000-0000-0000-0000-000000000000')).status).toBe(404);
+ });
+});
diff --git a/apps/api/src/modules/share/calendar.ts b/apps/api/src/modules/share/calendar.ts
new file mode 100644
index 00000000..dd2fb04c
--- /dev/null
+++ b/apps/api/src/modules/share/calendar.ts
@@ -0,0 +1,139 @@
+import { getSharedView, type SharedViewBundle } from './service';
+
+// A calendar feed for a shared view. Calendar clients poll the link; it carries one
+// all-day event per issue that has the date the view places it by. The share token
+// is the only credential, so revoking the share stops the feed too.
+
+const CUSTOM_DATE_FIELD = /^cf:(\d+)$/;
+
+type SharedIssue = SharedViewBundle['issues'][number];
+
+interface DatedIssue {
+ issue: SharedIssue;
+ day: string;
+}
+
+export async function getSharedViewCalendar(token: string): Promise<string | null> {
+ const bundle = await getSharedView(token);
+ return bundle ? buildCalendar(bundle) : null;
+}
+
+function buildCalendar(bundle: SharedViewBundle): string {
+ const dateField = calendarDateField(bundle.view.display);
+ const events = bundle.issues
+ .map((issue) => ({ issue, day: issueDay(issue, dateField, bundle) }))
+ .filter((event): event is DatedIssue => event.day !== null)
+ .sort((a, b) => a.day.localeCompare(b.day) || a.issue.id - b.issue.id);
+ const lines = [
+ 'BEGIN:VCALENDAR',
+ 'VERSION:2.0',
+ 'PRODID:-//ItsaPlan//Calendar Feed//EN',
+ 'CALSCALE:GREGORIAN',
+ 'METHOD:PUBLISH',
+ `X-WR-CALNAME:${escapeText(bundle.view.name)}`,
+ ...events.flatMap((event) => eventLines(event.issue, event.day)),
+ 'END:VCALENDAR',
+ ];
+ return `${lines.map(foldLine).join('\r\n')}\r\n`;
+}
+
+function calendarDateField(display: unknown): string {
+ const value =
+ display && typeof display === 'object'
+ ? (display as { calendarDateField?: unknown }).calendarDateField
+ : null;
+ if (value === 'startDate' || value === 'dueDate') return value;
+ if (typeof value === 'string' && CUSTOM_DATE_FIELD.test(value)) return value;
+ return 'dueDate';
+}
+
+// A custom date field is only known when the link exposes full issue details, and
+// only placed when its value is exposed too. Otherwise the feed uses the due date,
+// the same fallback the calendar layout takes for a deleted field, so the feed
+// never reveals a value the public page hides.
+function issueDay(issue: SharedIssue, dateField: string, bundle: SharedViewBundle): string | null {
+ if (dateField === 'startDate') return calendarDay(issue.startDate);
+ if (dateField === 'dueDate') return calendarDay(issue.dueDate);
+
+ const match = CUSTOM_DATE_FIELD.exec(dateField);
+ if (!match) return calendarDay(issue.dueDate);
+ const fieldId = Number(match[1]);
+ const field = bundle.project.customFields.find((f) => f.id === fieldId && isCalendarField(f));
+ if (!field) return calendarDay(issue.dueDate);
+
+ const entry = issue.fieldValues.find((value) => value.fieldId === fieldId);
+ const raw = typeof entry?.value === 'string' ? entry.value : null;
+ if (!raw) return null;
+ return calendarDay(field.fieldType === 'date' ? raw : raw.slice(0, 10));
+}
+
+function isCalendarField(field: { fieldType: string }): boolean {
+ return (
+ field.fieldType === 'date' ||
+ field.fieldType === 'datetime' ||
+ field.fieldType === 'datetime_range'
+ );
+}
+
+function calendarDay(value: string | null): string | null {
+ if (!value) return null;
+ return /^\d{4}-\d{2}-\d{2}$/.test(value) ? value : null;
+}
+
+function eventLines(issue: SharedIssue, day: string): string[] {
+ return [
+ 'BEGIN:VEVENT',
+ `UID:issue-${issue.id}@itsaplan`,
+ `DTSTAMP:${icsStamp(issue.updatedAt)}`,
+ `DTSTART;VALUE=DATE:${day.replace(/-/g, '')}`,
+ `DTEND;VALUE=DATE:${addDay(day).replace(/-/g, '')}`,
+ `SUMMARY:${escapeText(`${issue.identifier} ${issue.title}`)}`,
+ 'TRANSP:TRANSPARENT',
+ 'END:VEVENT',
+ ];
+}
+
+function addDay(day: string): string {
+ const date = new Date(`${day}T00:00:00Z`);
+ date.setUTCDate(date.getUTCDate() + 1);
+ return date.toISOString().slice(0, 10);
+}
+
+function icsStamp(value: string): string {
+ return new Date(value)
+ .toISOString()
+ .replace(/[-:]/g, '')
+ .replace(/\.\d{3}/, '');
+}
+
+function escapeText(value: string): string {
+ return value
+ .replace(/\\/g, '\\\\')
+ .replace(/\r\n|\r|\n/g, '\\n')
+ .replace(/;/g, '\\;')
+ .replace(/,/g, '\\,');
+}
+
+// RFC 5545 folds a content line longer than 75 octets. Continuation lines start
+// with one space, which is part of their 75 octets.
+const UTF8 = new TextEncoder();
+
+function foldLine(line: string): string {
+ if (UTF8.encode(line).length <= 75) return line;
+ const parts: string[] = [];
+ let part = '';
+ let bytes = 0;
+ for (const char of line) {
+ const size = UTF8.encode(char).length;
+ if (bytes + size > 75) {
+ parts.push(part);
+ part = ` ${char}`;
+ bytes = 1 + size;
+ } else {
+ part += char;
+ bytes += size;
+ }
+ }
+ parts.push(part);
+ return parts.join('\r\n');
+}
diff --git a/apps/api/src/modules/share/index.ts b/apps/api/src/modules/share/index.ts
index ce0dc18f..d4c7502d 100644
--- a/apps/api/src/modules/share/index.ts
+++ b/apps/api/src/modules/share/index.ts
@@ -15,6 +15,7 @@ import {
shareViewParams,
sharedViewIssueParams,
} from './model';
+import { getSharedViewCalendar } from './calendar';
import {
enableIssueShare,
disableIssueShare,
@@ -135,6 +136,22 @@ export const shareRoutes = new Elysia({ name: 'share', detail: { tags: ['Share']
},
)
+ .get(
+ '/share/view/:token/calendar.ics',
+ async ({ params, set }) => {
+ const feed = await getSharedViewCalendar(params.token);
+ if (!feed) throw new HttpError(404, 'Not found');
+ set.headers['content-type'] = 'text/calendar; charset=utf-8';
+ set.headers['cache-control'] = 'no-store';
+ return feed;
+ },
+ {
+ params: shareTokenParams,
+ response: { 200: t.String(), ...errors(400, 404) },
+ detail: { summary: 'Get a shared view calendar feed' },
+ },
+ )
+
.get(
'/share/view/:token/issues/:issueId',
async ({ params }) => {
diff --git a/apps/web/messages/ar/common.json b/apps/web/messages/ar/common.json
index 7242d41d..71fa9278 100644
--- a/apps/web/messages/ar/common.json
+++ b/apps/web/messages/ar/common.json
@@ -134,7 +134,9 @@
"stopSharing": "إيقاف المشاركة",
"createLink": "إنشاء رابط",
"copy": "نسخ",
- "copied": "تم النسخ"
+ "copied": "تم النسخ",
+ "calendarFeed": "خلاصة التقويم",
+ "calendarFeedHint": "انسخ الرابط ده في تطبيق التقويم عشان تشترك في العرض ده."
},
"actions": "الإجراءات",
"clearSearch": "مسح البحث",
diff --git a/apps/web/messages/en/common.json b/apps/web/messages/en/common.json
index 4b787480..eb267fbf 100644
--- a/apps/web/messages/en/common.json
+++ b/apps/web/messages/en/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Stop sharing",
"createLink": "Create link",
"copy": "Copy",
- "copied": "Copied"
+ "copied": "Copied",
+ "calendarFeed": "Calendar feed",
+ "calendarFeedHint": "Copy this link into your calendar app to subscribe to this view."
},
"actions": "Actions",
"clearSearch": "Clear search",
diff --git a/apps/web/messages/es-ES/common.json b/apps/web/messages/es-ES/common.json
index 6ce8e294..225948a9 100644
--- a/apps/web/messages/es-ES/common.json
+++ b/apps/web/messages/es-ES/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Dejar de compartir",
"createLink": "Crear enlace",
"copy": "Copiar",
- "copied": "Copiado"
+ "copied": "Copiado",
+ "calendarFeed": "Feed de calendario",
+ "calendarFeedHint": "Copia este enlace en tu aplicación de calendario para suscribirte a esta vista."
},
"actions": "Acciones",
"clearSearch": "Limpiar la búsqueda",
diff --git a/apps/web/messages/fa/common.json b/apps/web/messages/fa/common.json
index 5a4599c3..faaa3250 100644
--- a/apps/web/messages/fa/common.json
+++ b/apps/web/messages/fa/common.json
@@ -134,7 +134,9 @@
"stopSharing": "توقف اشتراک‌گذاری",
"createLink": "ایجاد لینک",
"copy": "کپی",
- "copied": "کپی شد"
+ "copied": "کپی شد",
+ "calendarFeed": "فید تقویم",
+ "calendarFeedHint": "این پیوند را در برنامه تقویم خود کپی کنید تا در این نما مشترک شوید."
},
"actions": "اقدامات",
"clearSearch": "پاک کردن جستجو",
diff --git a/apps/web/messages/fr/common.json b/apps/web/messages/fr/common.json
index b95e55c1..0f4930f3 100644
--- a/apps/web/messages/fr/common.json
+++ b/apps/web/messages/fr/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Arrêter le partage",
"createLink": "Créer un lien",
"copy": "Copier",
- "copied": "Copié"
+ "copied": "Copié",
+ "calendarFeed": "Flux de calendrier",
+ "calendarFeedHint": "Copiez ce lien dans votre application de calendrier pour vous abonner à cette vue."
},
"actions": "Actions",
"clearSearch": "Effacer la recherche",
diff --git a/apps/web/messages/id/common.json b/apps/web/messages/id/common.json
index 2383c1b7..97374a41 100644
--- a/apps/web/messages/id/common.json
+++ b/apps/web/messages/id/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Hentikan pembagian",
"createLink": "Buat tautan",
"copy": "Salin",
- "copied": "Disalin"
+ "copied": "Disalin",
+ "calendarFeed": "Feed kalender",
+ "calendarFeedHint": "Salin tautan ini ke aplikasi kalender Anda untuk berlangganan tampilan ini."
},
"actions": "Tindakan",
"clearSearch": "Bersihkan pencarian",
diff --git a/apps/web/messages/ko/common.json b/apps/web/messages/ko/common.json
index 8c41466b..77d433fe 100644
--- a/apps/web/messages/ko/common.json
+++ b/apps/web/messages/ko/common.json
@@ -134,7 +134,9 @@
"stopSharing": "공유 중지",
"createLink": "링크 생성",
"copy": "복사",
- "copied": "복사됨"
+ "copied": "복사됨",
+ "calendarFeed": "캘린더 피드",
+ "calendarFeedHint": "이 링크를 캘린더 앱에 복사하여 이 보기를 구독하세요."
},
"actions": "작업",
"clearSearch": "검색어 지우기",
diff --git a/apps/web/messages/pt-BR/common.json b/apps/web/messages/pt-BR/common.json
index f8ab6e55..146beb1c 100644
--- a/apps/web/messages/pt-BR/common.json
+++ b/apps/web/messages/pt-BR/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Parar compartilhamento",
"createLink": "Criar link",
"copy": "Copiar",
- "copied": "Copiado"
+ "copied": "Copiado",
+ "calendarFeed": "Feed de calendário",
+ "calendarFeedHint": "Copie este link no seu aplicativo de calendário para assinar esta visualização."
},
"actions": "Ações",
"clearSearch": "Limpar busca",
diff --git a/apps/web/messages/ru/common.json b/apps/web/messages/ru/common.json
index d82b1b59..b257babc 100644
--- a/apps/web/messages/ru/common.json
+++ b/apps/web/messages/ru/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Закрыть доступ",
"createLink": "Создать ссылку",
"copy": "Скопировать",
- "copied": "Скопировано"
+ "copied": "Скопировано",
+ "calendarFeed": "Лента календаря",
+ "calendarFeedHint": "Скопируйте эту ссылку в приложение календаря, чтобы подписаться на этот вид."
},
"actions": "Действия",
"clearSearch": "Очистить поиск",
diff --git a/apps/web/messages/tr/common.json b/apps/web/messages/tr/common.json
index 257b3453..e704c2ae 100644
--- a/apps/web/messages/tr/common.json
+++ b/apps/web/messages/tr/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Paylaşımı durdur",
"createLink": "Bağlantı oluştur",
"copy": "Kopyala",
- "copied": "Kopyalandı"
+ "copied": "Kopyalandı",
+ "calendarFeed": "Takvim akışı",
+ "calendarFeedHint": "Bu görünüme abone olmak için bu bağlantıyı takvim uygulamanıza kopyalayın."
},
"actions": "İşlemler",
"clearSearch": "Aramayı temizle",
diff --git a/apps/web/messages/uk/common.json b/apps/web/messages/uk/common.json
index a4b467e0..3b9c249a 100644
--- a/apps/web/messages/uk/common.json
+++ b/apps/web/messages/uk/common.json
@@ -134,7 +134,9 @@
"stopSharing": "Закрити доступ",
"createLink": "Створити посилання",
"copy": "Скопіювати",
- "copied": "Скопійовано"
+ "copied": "Скопійовано",
+ "calendarFeed": "Стрічка календаря",
+ "calendarFeedHint": "Скопіюйте це посилання в додаток календаря, щоб підписатися на цей вигляд."
},
"actions": "Дії",
"clearSearch": "Очистити пошук",
diff --git a/apps/web/messages/zh-CN/common.json b/apps/web/messages/zh-CN/common.json
index 53e88764..eff7abb4 100644
--- a/apps/web/messages/zh-CN/common.json
+++ b/apps/web/messages/zh-CN/common.json
@@ -134,7 +134,9 @@
"stopSharing": "停止共享",
"createLink": "创建链接",
"copy": "复制",
- "copied": "已复制"
+ "copied": "已复制",
+ "calendarFeed": "日历订阅",
+ "calendarFeedHint": "将此链接复制到日历应用,以订阅此视图。"
},
"actions": "操作",
"clearSearch": "清除搜索",
diff --git a/apps/web/messages/zh-TW/common.json b/apps/web/messages/zh-TW/common.json
index 87f6c64c..4df0137b 100644
--- a/apps/web/messages/zh-TW/common.json
+++ b/apps/web/messages/zh-TW/common.json
@@ -134,7 +134,9 @@
"stopSharing": "停止共享",
"createLink": "建立連結",
"copy": "複製",
- "copied": "已複製"
+ "copied": "已複製",
+ "calendarFeed": "行事曆訂閱",
+ "calendarFeedHint": "將此連結複製到行事曆應用程式,以訂閱此檢視。"
},
"actions": "操作",
"clearSearch": "清除搜尋",
diff --git a/apps/web/src/app/share/view/[token]/calendar.ics/route.ts b/apps/web/src/app/share/view/[token]/calendar.ics/route.ts
new file mode 100644
index 00000000..a7a4d568
--- /dev/null
+++ b/apps/web/src/app/share/view/[token]/calendar.ics/route.ts
@@ -0,0 +1,28 @@
+import { serverRuntimeEnv } from '@/utils/runtimeEnv';
+
+// The calendar feed for a public shared view. Calendar apps subscribe to the web
+// origin, so the api's public feed is served through here like the share pages.
+// The token is the only credential; no request header is forwarded.
+const SHARE_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+
+// No request data marks the handler dynamic, so state it; otherwise Next tries to
+// render the feed once at build time and the fetch throws.
+export const dynamic = 'force-dynamic';
+
+export async function GET(_request: Request, { params }: { params: Promise<{ token: string }> }) {
+ const { token } = await params;
+ if (!SHARE_TOKEN.test(token)) return new Response(null, { status: 404 });
+
+ const origin = process.env.SERVICE_URL_API || serverRuntimeEnv().apiUrl;
+ const upstream = await fetch(`${origin}/share/view/${token}/calendar.ics`, {
+ cache: 'no-store',
+ redirect: 'error',
+ });
+
+ const headers = new Headers();
+ for (const name of ['content-type', 'cache-control']) {
+ const value = upstream.headers.get(name);
+ if (value) headers.set(name, value);
+ }
+ return new Response(upstream.body, { status: upstream.status, headers });
+}
diff --git a/apps/web/src/components/common/share/ShareDialog.tsx b/apps/web/src/components/common/share/ShareDialog.tsx
index e486cd63..7b42524b 100644
--- a/apps/web/src/components/common/share/ShareDialog.tsx
+++ b/apps/web/src/components/common/share/ShareDialog.tsx
@@ -31,6 +31,7 @@ export default function ShareDialog({
enable,
disable,
pathForToken,
+ calendarPathForToken,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
@@ -42,11 +43,14 @@ export default function ShareDialog({
enable: (extended: boolean) => Promise<string>;
disable: () => Promise<void>;
pathForToken: (token: string) => string;
+ // The calendar feed path, for a shared view. Omitted by an issue share.
+ calendarPathForToken?: (token: string) => string;
}) {
const t = useTranslations('common.share');
const [current, setCurrent] = useState<string | null>(token);
const [busy, setBusy] = useState(false);
const [copied, setCopied] = useState(false);
+ const [copiedCalendar, setCopiedCalendar] = useState(false);
// Seed from the latest token when the dialog opens; the prop can change while it
// is mounted (the issue/view query refetched).
@@ -57,6 +61,8 @@ export default function ShareDialog({
}
const url = current ? shareUrl(pathForToken(current)) : '';
+ const calendarUrl =
+ current && calendarPathForToken ? shareUrl(calendarPathForToken(current)) : '';
async function run(operation: () => Promise<void>, failure: string) {
setBusy(true);
@@ -80,11 +86,11 @@ export default function ShareDialog({
setCurrent(null);
}, t('stopFailed'));
- async function copy() {
+ async function copyText(value: string, mark: (copied: boolean) => void) {
try {
- await navigator.clipboard.writeText(url);
- setCopied(true);
- setTimeout(() => setCopied(false), 1500);
+ await navigator.clipboard.writeText(value);
+ mark(true);
+ setTimeout(() => mark(false), 1500);
} catch {
toast.error(t('copyFailed'));
}
@@ -108,12 +114,44 @@ export default function ShareDialog({
className="h-9 flex-1 bg-muted/40 font-mono text-xs"
onFocus={(e) => e.target.select()}
/>
- <Button type="button" variant="secondary" size="sm" className="h-9" onClick={copy}>
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ className="h-9"
+ onClick={() => copyText(url, setCopied)}
+ >
{copied ? <Check className="size-4" /> : <Copy className="size-4" />}
{copied ? t('copied') : t('copy')}
</Button>
</div>
+ {calendarUrl && (
+ <div className="flex flex-col gap-1.5">
+ <span className="text-sm">{t('calendarFeed')}</span>
+ <div className="flex items-center gap-2">
+ <Input
+ readOnly
+ value={calendarUrl}
+ aria-label={t('calendarFeed')}
+ className="h-9 flex-1 bg-muted/40 font-mono text-xs"
+ onFocus={(e) => e.target.select()}
+ />
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ className="h-9"
+ onClick={() => copyText(calendarUrl, setCopiedCalendar)}
+ >
+ {copiedCalendar ? <Check className="size-4" /> : <Copy className="size-4" />}
+ {copiedCalendar ? t('copied') : t('copy')}
+ </Button>
+ </div>
+ <span className="text-xs text-muted-foreground">{t('calendarFeedHint')}</span>
+ </div>
+ )}
+
<label className="flex items-center justify-between gap-4 rounded-md border px-3 py-2.5">
<span className="min-w-0">
<span className="block text-sm">{t('fullDetails')}</span>
diff --git a/apps/web/src/components/layout/SavedViewTab.tsx b/apps/web/src/components/layout/SavedViewTab.tsx
index f91dcc1d..ea841de5 100644
--- a/apps/web/src/components/layout/SavedViewTab.tsx
+++ b/apps/web/src/components/layout/SavedViewTab.tsx
@@ -9,7 +9,7 @@ import { enableViewShare, disableViewShare } from '@/lib/api/endpoints/share';
import { qk } from '@/services/queryKeys';
import { useSetViewFavorite } from '@/services/views.service';
import { cn } from '@/lib/utils';
-import { shareViewPath } from '@/utils/paths';
+import { shareViewCalendarPath, shareViewPath } from '@/utils/paths';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import ViewTabChrome from '@/components/layout/ViewTabChrome';
import ViewTabLabel from '@/components/layout/ViewTabLabel';
@@ -150,6 +150,7 @@ export default function SavedViewTab({
enable={share}
disable={disableShare}
pathForToken={shareViewPath}
+ calendarPathForToken={shareViewCalendarPath}
/>
</ViewTabChrome>
);
diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.ts
index 17da949f..5ec110c9 100644
--- a/apps/web/src/utils/paths.ts
+++ b/apps/web/src/utils/paths.ts
@@ -27,6 +27,7 @@ export const dashboardsPath = (ref: string) => `${projectPath(ref)}/dashboards`;
// Public read-only share pages (no auth). The token is the unguessable share key.
export const shareIssuePath = (token: string) => `/share/issue/${token}`;
export const shareViewPath = (token: string) => `/share/view/${token}`;
+export const shareViewCalendarPath = (token: string) => `/share/view/${token}/calendar.ics`;
// The absolute share URL to copy, built from the current origin at call time.
export const shareUrl = (path: string) =>