Enhancement: handle Vikunja v1rc4 breaking changes (#6234)

This commit is contained in:
shamoon 2026-01-26 10:27:36 -08:00 committed by GitHub
parent 6c945d6573
commit 1aec61811f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 10 deletions

View File

@ -9,10 +9,16 @@ Allowed fields: `["projects", "tasks7d", "tasksOverdue", "tasksInProgress"]`.
A list of the next 5 tasks ordered by due date is disabled by default, but can be enabled with the `enableTaskList` option.
| Vikunja Version | Homepage Widget Version |
| --------------- | ----------------------- |
| < v1.0.0-rc4 | 1 (default) |
| >= v1.0.0-rc4 | 2 |
```yaml
widget:
type: vikunja
url: http[s]://vikunja.host.or.ip[:port]
key: vikunjaapikey
enableTaskList: true # optional, defaults to false
version: 2 # optional, defaults to 1
```

View File

@ -569,6 +569,7 @@ export function cleanServiceGroups(groups) {
"wgeasy",
"grafana",
"gluetun",
"vikunja",
].includes(type)
) {
if (version) widget.version = parseInt(version, 10);

View File

@ -8,11 +8,15 @@ export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const version = widget.version ?? 1;
const { data: projectsData, error: projectsError } = useWidgetAPI(widget, "projects");
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "tasks");
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, version === 2 ? "tasks_v2" : "tasks");
if (projectsError || tasksError) {
return <Container service={service} error={projectsError ?? tasksError} />;
} else if (projectsData?.message || tasksData?.message) {
return <Container service={service} error={projectsData?.message ?? tasksData?.message} />;
}
if (!projectsData || !tasksData) {

View File

@ -1,6 +1,15 @@
import { asJson } from "utils/proxy/api-helpers";
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const map = asJson(data).map((task) => ({
id: task.id,
title: task.title,
priority: task.priority,
dueDate: task.due_date,
dueDateIsDefault: task.due_date === "0001-01-01T00:00:00Z",
inProgress: task.percent_done > 0 && task.percent_done < 1,
}));
const widget = {
api: `{url}/api/v1/{endpoint}`,
proxyHandler: credentialedProxyHandler,
@ -11,15 +20,11 @@ const widget = {
},
tasks: {
endpoint: "tasks/all?filter=done%3Dfalse&sort_by=due_date",
map: (data) =>
asJson(data).map((task) => ({
id: task.id,
title: task.title,
priority: task.priority,
dueDate: task.due_date,
dueDateIsDefault: task.due_date === "0001-01-01T00:00:00Z",
inProgress: task.percent_done > 0 && task.percent_done < 1,
})),
map: map,
},
tasks_v2: {
endpoint: "tasks?filter=done%3Dfalse&sort_by=due_date",
map: map,
},
},
};