fix permissions
This commit is contained in:
@@ -20,7 +20,7 @@ import { useNotification } from '../contexts/NotificationContext';
|
||||
import { usePermissionContext } from '../contexts/PermissionContext';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { issuesApi } from '../services/issues';
|
||||
import type { Issue, IssueComment, IssueTyp, CreateIssuePayload, UpdateIssuePayload, IssueFilters, AssignableMember, IssueStatusmeldung, IssueStatusDef, IssuePriorityDef } from '../types/issue.types';
|
||||
import type { Issue, IssueComment, IssueTyp, CreateIssuePayload, UpdateIssuePayload, IssueFilters, AssignableMember, IssueStatusDef, IssuePriorityDef } from '../types/issue.types';
|
||||
|
||||
// ── Helpers ──
|
||||
|
||||
@@ -755,12 +755,6 @@ function IssueSettings() {
|
||||
const queryClient = useQueryClient();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
|
||||
// ── Statusmeldungen state ──
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [createData, setCreateData] = useState<{ titel: string; inhalt: string; schwere: 'info' | 'warnung' | 'fehler' }>({ titel: '', inhalt: '', schwere: 'info' });
|
||||
const [editId, setEditId] = useState<number | null>(null);
|
||||
const [editData, setEditData] = useState<Partial<IssueStatusmeldung>>({});
|
||||
|
||||
// ── Status state ──
|
||||
const [statusCreateOpen, setStatusCreateOpen] = useState(false);
|
||||
const [statusCreateData, setStatusCreateData] = useState<Partial<IssueStatusDef>>({ schluessel: '', bezeichnung: '', farbe: 'default', ist_abschluss: false, ist_initial: false, benoetigt_typ_freigabe: false, sort_order: 0 });
|
||||
@@ -773,11 +767,6 @@ function IssueSettings() {
|
||||
const [prioEditId, setPrioEditId] = useState<number | null>(null);
|
||||
const [prioEditData, setPrioEditData] = useState<Partial<IssuePriorityDef>>({});
|
||||
|
||||
const { data: statusmeldungen = [], isLoading: smLoading } = useQuery({
|
||||
queryKey: ['issue-statusmeldungen'],
|
||||
queryFn: issuesApi.getStatusmeldungen,
|
||||
});
|
||||
|
||||
const { data: issueStatuses = [], isLoading: statusLoading } = useQuery({
|
||||
queryKey: ['issue-statuses'],
|
||||
queryFn: issuesApi.getStatuses,
|
||||
@@ -788,40 +777,6 @@ function IssueSettings() {
|
||||
queryFn: issuesApi.getPriorities,
|
||||
});
|
||||
|
||||
// Statusmeldungen mutations
|
||||
const createSmMut = useMutation({
|
||||
mutationFn: (data: { titel: string; inhalt?: string; schwere?: string }) => issuesApi.createStatusmeldung(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['issue-statusmeldungen'] });
|
||||
showSuccess('Statusmeldung erstellt');
|
||||
setCreateOpen(false);
|
||||
setCreateData({ titel: '', inhalt: '', schwere: 'info' });
|
||||
},
|
||||
onError: () => showError('Fehler beim Erstellen'),
|
||||
});
|
||||
|
||||
const updateSmMut = useMutation({
|
||||
mutationFn: ({ id, data }: { id: number; data: Partial<IssueStatusmeldung> }) => issuesApi.updateStatusmeldung(id, data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['issue-statusmeldungen'] });
|
||||
showSuccess('Statusmeldung aktualisiert');
|
||||
setEditId(null);
|
||||
},
|
||||
onError: () => showError('Fehler beim Aktualisieren'),
|
||||
});
|
||||
|
||||
const deleteSmMut = useMutation({
|
||||
mutationFn: (id: number) => issuesApi.deleteStatusmeldung(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['issue-statusmeldungen'] });
|
||||
showSuccess('Statusmeldung gelöscht');
|
||||
},
|
||||
onError: () => showError('Fehler beim Löschen'),
|
||||
});
|
||||
|
||||
const schwereColors: Record<string, 'info' | 'warning' | 'error'> = { info: 'info', warnung: 'warning', fehler: 'error' };
|
||||
const schwereLabels: Record<string, string> = { info: 'Info', warnung: 'Warnung', fehler: 'Fehler' };
|
||||
|
||||
// Status mutations
|
||||
const createStatusMut = useMutation({
|
||||
mutationFn: (data: Partial<IssueStatusDef>) => issuesApi.createStatus(data),
|
||||
@@ -988,76 +943,7 @@ function IssueSettings() {
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Section 3: Statusmeldungen */}
|
||||
<Box>
|
||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
|
||||
<Typography variant="h6">Statusmeldungen</Typography>
|
||||
<Button startIcon={<AddIcon />} variant="contained" size="small" onClick={() => setCreateOpen(true)}>
|
||||
Neue Meldung
|
||||
</Button>
|
||||
</Box>
|
||||
{smLoading ? <CircularProgress /> : (
|
||||
<TableContainer component={Paper} variant="outlined">
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Titel</TableCell>
|
||||
<TableCell>Schwere</TableCell>
|
||||
<TableCell>Aktiv</TableCell>
|
||||
<TableCell>Aktionen</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{statusmeldungen.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} sx={{ textAlign: 'center', color: 'text.secondary' }}>
|
||||
Keine Statusmeldungen
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : statusmeldungen.map((sm) => (
|
||||
<TableRow key={sm.id}>
|
||||
{editId === sm.id ? (
|
||||
<>
|
||||
<TableCell>
|
||||
<TextField size="small" value={editData.titel ?? sm.titel} onChange={(e) => setEditData({ ...editData, titel: e.target.value })} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Select size="small" value={editData.schwere ?? sm.schwere} onChange={(e) => setEditData({ ...editData, schwere: e.target.value as 'info' | 'warnung' | 'fehler' })}>
|
||||
<MenuItem value="info">Info</MenuItem>
|
||||
<MenuItem value="warnung">Warnung</MenuItem>
|
||||
<MenuItem value="fehler">Fehler</MenuItem>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Switch checked={editData.aktiv ?? sm.aktiv} onChange={(e) => setEditData({ ...editData, aktiv: e.target.checked })} size="small" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<IconButton size="small" onClick={() => updateSmMut.mutate({ id: sm.id, data: editData })}><CheckIcon /></IconButton>
|
||||
<IconButton size="small" onClick={() => setEditId(null)}><CloseIcon /></IconButton>
|
||||
</TableCell>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<TableCell>{sm.titel}</TableCell>
|
||||
<TableCell><Chip label={schwereLabels[sm.schwere]} color={schwereColors[sm.schwere]} size="small" /></TableCell>
|
||||
<TableCell>
|
||||
<Switch checked={sm.aktiv} onChange={(e) => updateSmMut.mutate({ id: sm.id, data: { aktiv: e.target.checked } })} size="small" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<IconButton size="small" onClick={() => { setEditId(sm.id); setEditData({ titel: sm.titel, schwere: sm.schwere, aktiv: sm.aktiv, inhalt: sm.inhalt ?? '' }); }}><EditIcon /></IconButton>
|
||||
<IconButton size="small" onClick={() => deleteSmMut.mutate(sm.id)}><DeleteIcon /></IconButton>
|
||||
</TableCell>
|
||||
</>
|
||||
)}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Section 4: Kategorien */}
|
||||
{/* Section 3: Kategorien */}
|
||||
<Box>
|
||||
<IssueTypeAdmin />
|
||||
</Box>
|
||||
@@ -1100,28 +986,6 @@ function IssueSettings() {
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
{/* Create Statusmeldung Dialog */}
|
||||
<Dialog open={createOpen} onClose={() => setCreateOpen(false)} maxWidth="sm" fullWidth>
|
||||
<DialogTitle>Neue Statusmeldung</DialogTitle>
|
||||
<DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2, pt: '20px !important' }}>
|
||||
<TextField label="Titel" required fullWidth value={createData.titel} onChange={(e) => setCreateData({ ...createData, titel: e.target.value })} autoFocus />
|
||||
<TextField label="Inhalt" fullWidth multiline rows={3} value={createData.inhalt} onChange={(e) => setCreateData({ ...createData, inhalt: e.target.value })} />
|
||||
<FormControl fullWidth size="small">
|
||||
<InputLabel>Schwere</InputLabel>
|
||||
<Select label="Schwere" value={createData.schwere} onChange={(e) => setCreateData({ ...createData, schwere: e.target.value as 'info' | 'warnung' | 'fehler' })}>
|
||||
<MenuItem value="info">Info</MenuItem>
|
||||
<MenuItem value="warnung">Warnung</MenuItem>
|
||||
<MenuItem value="fehler">Fehler</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setCreateOpen(false)}>Abbrechen</Button>
|
||||
<Button variant="contained" onClick={() => createSmMut.mutate(createData)} disabled={!createData.titel.trim() || createSmMut.isPending}>
|
||||
Erstellen
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user