mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-27 14:16:02 +00:00
[UI] Fix Background Tasks panel (#12899)
- Prevent visual flicker of "background worker not running"
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { Accordion, Alert, Divider, Stack, Text } from '@mantine/core';
|
import {
|
||||||
|
Accordion,
|
||||||
|
Alert,
|
||||||
|
Divider,
|
||||||
|
Skeleton,
|
||||||
|
Stack,
|
||||||
|
Text
|
||||||
|
} from '@mantine/core';
|
||||||
import { lazy } from 'react';
|
import { lazy } from 'react';
|
||||||
|
|
||||||
import { StylishText } from '@lib/components/StylishText';
|
import { StylishText } from '@lib/components/StylishText';
|
||||||
@@ -16,18 +23,16 @@ const ScheduledTasksTable = Loadable(
|
|||||||
lazy(() => import('../../../../tables/settings/ScheduledTasksTable'))
|
lazy(() => import('../../../../tables/settings/ScheduledTasksTable'))
|
||||||
);
|
);
|
||||||
|
|
||||||
export default function TaskManagementPanel() {
|
function BackgroundWorkerStatus({
|
||||||
const { instance: taskInfo, refreshInstance: refreshTaskInfo } = useInstance({
|
isRunning
|
||||||
endpoint: ApiEndpoints.task_overview,
|
}: {
|
||||||
hasPrimaryKey: false,
|
isRunning?: boolean;
|
||||||
refetchOnMount: true,
|
}) {
|
||||||
defaultValue: {},
|
if (isRunning === null || isRunning === undefined) {
|
||||||
updateInterval: 30 * 1000
|
return <Skeleton animate />;
|
||||||
});
|
}
|
||||||
|
|
||||||
return (
|
return !!isRunning ? (
|
||||||
<>
|
|
||||||
{taskInfo?.is_running ? (
|
|
||||||
<Alert
|
<Alert
|
||||||
title={t`Background worker running`}
|
title={t`Background worker running`}
|
||||||
color='green'
|
color='green'
|
||||||
@@ -42,7 +47,21 @@ export default function TaskManagementPanel() {
|
|||||||
<Text>{t`The background task manager service is not running. Contact your system administrator.`}</Text>
|
<Text>{t`The background task manager service is not running. Contact your system administrator.`}</Text>
|
||||||
{errorCodeLink('INVE-W5')}
|
{errorCodeLink('INVE-W5')}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TaskManagementPanel() {
|
||||||
|
const { instance: taskInfo, refreshInstance: refreshTaskInfo } = useInstance({
|
||||||
|
endpoint: ApiEndpoints.task_overview,
|
||||||
|
hasPrimaryKey: false,
|
||||||
|
refetchOnMount: true,
|
||||||
|
defaultValue: {},
|
||||||
|
updateInterval: 30 * 1000
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BackgroundWorkerStatus isRunning={taskInfo?.is_running} />
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
<FactCollection
|
<FactCollection
|
||||||
items={[
|
items={[
|
||||||
|
|||||||
Reference in New Issue
Block a user