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,6 +23,33 @@ const ScheduledTasksTable = Loadable(
|
|||||||
lazy(() => import('../../../../tables/settings/ScheduledTasksTable'))
|
lazy(() => import('../../../../tables/settings/ScheduledTasksTable'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function BackgroundWorkerStatus({
|
||||||
|
isRunning
|
||||||
|
}: {
|
||||||
|
isRunning?: boolean;
|
||||||
|
}) {
|
||||||
|
if (isRunning === null || isRunning === undefined) {
|
||||||
|
return <Skeleton animate />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !!isRunning ? (
|
||||||
|
<Alert
|
||||||
|
title={t`Background worker running`}
|
||||||
|
color='green'
|
||||||
|
icon={<IconCircleCheck />}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Alert
|
||||||
|
title={t`Background worker not running`}
|
||||||
|
color='red'
|
||||||
|
icon={<IconExclamationCircle />}
|
||||||
|
>
|
||||||
|
<Text>{t`The background task manager service is not running. Contact your system administrator.`}</Text>
|
||||||
|
{errorCodeLink('INVE-W5')}
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function TaskManagementPanel() {
|
export default function TaskManagementPanel() {
|
||||||
const { instance: taskInfo, refreshInstance: refreshTaskInfo } = useInstance({
|
const { instance: taskInfo, refreshInstance: refreshTaskInfo } = useInstance({
|
||||||
endpoint: ApiEndpoints.task_overview,
|
endpoint: ApiEndpoints.task_overview,
|
||||||
@@ -27,22 +61,7 @@ export default function TaskManagementPanel() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{taskInfo?.is_running ? (
|
<BackgroundWorkerStatus isRunning={taskInfo?.is_running} />
|
||||||
<Alert
|
|
||||||
title={t`Background worker running`}
|
|
||||||
color='green'
|
|
||||||
icon={<IconCircleCheck />}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Alert
|
|
||||||
title={t`Background worker not running`}
|
|
||||||
color='red'
|
|
||||||
icon={<IconExclamationCircle />}
|
|
||||||
>
|
|
||||||
<Text>{t`The background task manager service is not running. Contact your system administrator.`}</Text>
|
|
||||||
{errorCodeLink('INVE-W5')}
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
<FactCollection
|
<FactCollection
|
||||||
items={[
|
items={[
|
||||||
|
|||||||
Reference in New Issue
Block a user