fix(calendar): EWS uses NTLM auth + edit form stays open after save
- Replace ews-javascript-api (Basic Auth only) with httpntlm for EWS connections - testEwsConnection uses GetFolder SOAP via NTLM - fetchViaEws uses FindItem CalendarView SOAP via NTLM - Edit form no longer auto-closes on save — shows "Erfolgreich gespeichert" instead - Test button in edit mode uses saved credentials via /sources/:id/test endpoint - Add saveSuccess i18n key (de/en) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,7 @@ export function CalendarSettingsPanel() {
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [saveError, setSaveError] = useState<string | null>(null);
|
||||
const [editSaveError, setEditSaveError] = useState<string | null>(null);
|
||||
const [editSaveSuccess, setEditSaveSuccess] = useState(false);
|
||||
const [testResults, setTestResults] = useState<Record<string, 'success' | 'error' | 'testing'>>({});
|
||||
|
||||
// Load sources on mount
|
||||
@@ -234,9 +235,11 @@ export function CalendarSettingsPanel() {
|
||||
<button
|
||||
type="button"
|
||||
className="text-muted-foreground hover:text-foreground transition-colors"
|
||||
onClick={() =>
|
||||
setEditingId(editingId === source.id ? null : source.id)
|
||||
}
|
||||
onClick={() => {
|
||||
setEditingId(editingId === source.id ? null : source.id);
|
||||
setEditSaveSuccess(false);
|
||||
setEditSaveError(null);
|
||||
}}
|
||||
aria-label={`Edit ${source.name}`}
|
||||
>
|
||||
<svg
|
||||
@@ -288,6 +291,9 @@ export function CalendarSettingsPanel() {
|
||||
{editSaveError && (
|
||||
<p className="mb-3 text-sm text-destructive">{editSaveError}</p>
|
||||
)}
|
||||
{editSaveSuccess && (
|
||||
<p className="mb-3 text-sm text-green-600 dark:text-green-400">{t('calendar.saveSuccess') || 'Gespeichert'}</p>
|
||||
)}
|
||||
<h3 className="mb-3 text-sm font-semibold text-foreground">
|
||||
Edit Source
|
||||
</h3>
|
||||
@@ -310,12 +316,13 @@ export function CalendarSettingsPanel() {
|
||||
onSave={async (payload) => {
|
||||
setIsSaving(true);
|
||||
setEditSaveError(null);
|
||||
setEditSaveSuccess(false);
|
||||
try {
|
||||
const updated = await updateSource(editingId, payload);
|
||||
setSources((prev) =>
|
||||
prev.map((s) => (s.id === editingId ? updated : s)),
|
||||
);
|
||||
setEditingId(null);
|
||||
setEditSaveSuccess(true);
|
||||
} catch {
|
||||
setEditSaveError(t('calendar.saveError') || 'Fehler beim Speichern');
|
||||
} finally {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import type { CreateSourcePayload } from '@/lib/calendar-api';
|
||||
import { testSourceConfig } from '@/lib/calendar-api';
|
||||
import { testSourceConfig, testSource } from '@/lib/calendar-api';
|
||||
|
||||
/**
|
||||
* 8-color palette for calendar sources (UI-SPEC).
|
||||
@@ -110,6 +110,12 @@ export function CalendarSourceForm({
|
||||
if (!validateUrl(url)) return;
|
||||
setTestStatus('loading');
|
||||
try {
|
||||
// In edit mode with no new password entered, use saved credentials via the source endpoint
|
||||
if (initialValues?.id && !password) {
|
||||
const result = await testSource(initialValues.id);
|
||||
setTestStatus(result.success ? 'success' : 'error');
|
||||
return;
|
||||
}
|
||||
const result = await testSourceConfig({
|
||||
type,
|
||||
url: url.trim(),
|
||||
@@ -122,7 +128,7 @@ export function CalendarSourceForm({
|
||||
} catch {
|
||||
setTestStatus('error');
|
||||
}
|
||||
}, [type, url, username, password, exchangeMode, domain, isExchange, validateUrl]);
|
||||
}, [initialValues?.id, type, url, username, password, exchangeMode, domain, isExchange, validateUrl]);
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
async (e: React.FormEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user