Components/Cockpit: add a not ready component

Add a component to display when the osbuild-composer socket
is not running. We could potentially try start the socket
in the future when clicking the button, rather than re-directing
to the cockpit services plugin.
This commit is contained in:
Gianluca Zuccarelli 2025-02-04 12:42:07 +00:00 committed by Sanne Raymaekers
parent 9e4cd302b5
commit abca3ac760

View file

@ -0,0 +1,47 @@
import React from 'react';
import {
Button,
EmptyState,
EmptyStateActions,
EmptyStateBody,
EmptyStateFooter,
EmptyStateIcon,
EmptyStateVariant,
Title,
} from '@patternfly/react-core';
import { CubesIcon } from '@patternfly/react-icons';
import cockpit from 'cockpit';
export const NotReady = ({ enabled }: { enabled: boolean }) => {
return (
<EmptyState variant={EmptyStateVariant.xl}>
<EmptyStateIcon icon={CubesIcon} />
<Title headingLevel="h4" size="lg">
OSBuild Composer is not {enabled ? 'started' : 'enabled'}
</Title>
<EmptyStateBody />
<EmptyStateFooter>
<EmptyStateActions>
<Button
variant="primary"
onClick={(event) => {
event.preventDefault();
cockpit
.spawn(
['systemctl', 'enable', '--now', 'osbuild-composer.socket'],
{
superuser: 'require',
err: 'message',
}
)
.then(() => window.location.reload());
}}
>
Start socket
</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
);
};