Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libs/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,11 @@
"Restarts": "Restarts",
"Workload applications": "Workload applications",
"Virtual machines": "Virtual machines",
"The application has restarted {{ restartDelta }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.": "The application has restarted {{ restartDelta }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.",
"The application has restarted {{ restartDelta }} times this session and may be misconfigured. Contact an administrator to stop the application and investigate the issue.": "The application has restarted {{ restartDelta }} times this session and may be misconfigured. Contact an administrator to stop the application and investigate the issue.",
"Stop application": "Stop application",
"Restart loop detected": "Restart loop detected",
"This application has restarted {{ count }} times this session. Stop the application to prevent further restarts and investigate the issue._one": "This application has restarted {{ count }} times this session. Stop the application to prevent further restarts and investigate the issue.",
"This application has restarted {{ count }} times this session. Stop the application to prevent further restarts and investigate the issue._other": "This application has restarted {{ count }} times this session. Stop the application to prevent further restarts and investigate the issue.",
"This application is restarting repeatedly": "This application is restarting repeatedly",
"The application has restarted {{ count }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue._one": "The application has restarted {{ count }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.",
"The application has restarted {{ count }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue._other": "The application has restarted {{ count }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.",
"No applications found": "No applications found",
"Applications": "Applications",
"Message": "Message",
Expand Down Expand Up @@ -1871,8 +1869,10 @@
"{{ numberOfItems }} items": "{{ numberOfItems }} items",
"Search value cannot contain spaces": "Search value cannot contain spaces",
"The virtual machine is starting. Console will be available once running.": "The virtual machine is starting. Console will be available once running.",
"The virtual machine is stopped. Start the VM to access the console.": "The virtual machine is stopped. Start the VM to access the console.",
"The virtual machine is stopping. Start the VM to access the console.": "The virtual machine is stopping. Start the VM to access the console.",
"The virtual machine is not running. Start the VM to access the console.": "The virtual machine is not running. Start the VM to access the console.",
"Connection was closed": "Connection was closed",
"Connection was closed. The VM may be starting, stopping, or stopped.": "Connection was closed. The VM may be starting, stopping, or stopped.",
"Reconnect": "Reconnect",
"Connected to serial console: {{ appName }}": "Connected to serial console: {{ appName }}",
"No virtual machines found. Create a virtual machine to access its serial console.": "No virtual machines found. Create a virtual machine to access its serial console.",
Expand All @@ -1884,9 +1884,11 @@
"End active console session?": "End active console session?",
"This will terminate the existing console session for \"{{appName}}\". If another user is connected, they will be disconnected immediately.": "This will terminate the existing console session for \"{{appName}}\". If another user is connected, they will be disconnected immediately.",
"End session and connect": "End session and connect",
"Connection was closed": "Connection was closed",
"Waiting for terminal session to open...": "Waiting for terminal session to open...",
"Only one serial console session can be active at a time. Another user or browser tab may already be connected to this virtual machine. Close any other active session, then try again.": "Only one serial console session can be active at a time. Another user or browser tab may already be connected to this virtual machine. Close any other active session, then try again.",
"This console session was ended because another user connected to the same virtual machine.": "This console session was ended because another user connected to the same virtual machine.",
"The virtual machine console is unavailable at the moment. The VM may be starting, stopping, or stopped.": "The virtual machine console is unavailable at the moment. The VM may be starting, stopping, or stopped.",
"You do not have permission to access the virtual machine console.": "You do not have permission to access the virtual machine console.",
"The virtual machine application was not found.": "The virtual machine application was not found.",
"Timed out connecting to the virtual machine console. The VM may still be starting.": "Timed out connecting to the virtual machine console. The VM may still be starting.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getDisabledTooltipProps } from '../../../utils/tooltip';
import {
type ApplicationLifecycleAction,
hasAplicationStatusMismatch,
isAppConsoleAvailable,
startableStatuses,
stoppableStatuses,
transitionalStatuses,
Expand Down Expand Up @@ -108,6 +109,7 @@ const ApplicationLifecycleActions = ({

const isAppRunning = appStatus === ApplicationStatusType.ApplicationStatusRunning;
const desiredStateIsStopped = desiredState === ApplicationDesiredState.ApplicationDesiredStateStopped;
const canOpenConsole = isAppConsoleAvailable(appStatus, desiredState);
const canStart = startableStatuses.includes(appStatus);
const canStop = stoppableStatuses.includes(appStatus);
const isTransitioning = transitionalStatuses.includes(appStatus);
Expand Down Expand Up @@ -192,7 +194,7 @@ const ApplicationLifecycleActions = ({
<Button
variant={ButtonVariant.link}
icon={<TerminalIcon />}
isDisabled={!isAppRunning}
isDisabled={!canOpenConsole}
onClick={() => onOpenConsole?.(appStatusObj.name)}
>
{t('Open console')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,49 @@ const AppExpandedDetails = ({
return <WorkloadAppExpandedDetails application={application} desiredState={desiredState} />;
};

type RestartLoopStopButtonProps = {
onStop: () => void;
isDisabled: boolean;
isLoading: boolean;
};

const RestartLoopStopButton = ({ onStop, isDisabled, isLoading }: RestartLoopStopButtonProps) => {
const { t } = useTranslation();
return (
<Button variant="secondary" onClick={onStop} isDisabled={isDisabled} isLoading={isLoading}>
{t('Stop application')}
</Button>
);
};

type RestartLoopWarningProps = {
restartDelta: number;
canStop: boolean;
stopDisabled: boolean;
stopLoading: boolean;
onStop: () => void;
onStop: VoidFunction;
};
Comment thread
celdrake marked this conversation as resolved.

const RestartLoopWarningContent = ({
restartDelta,
canStop,
stopDisabled,
stopLoading,
onStop,
}: RestartLoopWarningProps) => {
const { t } = useTranslation();
return (
<Stack hasGutter>
<StackItem>
{canStop
? t(
'The application has restarted {{ restartDelta }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.',
{ restartDelta },
)
: t(
'The application has restarted {{ restartDelta }} times this session and may be misconfigured. Contact an administrator to stop the application and investigate the issue.',
{ restartDelta },
)}
</StackItem>
{canStop && (
<Button
variant="secondary"
size="sm"
onClick={onStop}
isDisabled={stopDisabled}
isLoading={stopLoading}
style={{ width: 'fit-content' }}
>
{t('Stop application')}
</Button>
)}
</Stack>
);
};

const AppRestartsWarning = ({
Expand All @@ -121,31 +143,23 @@ const AppRestartsWarning = ({
onStop,
}: RestartLoopWarningProps & { restarts: number }) => {
const { t } = useTranslation();
const warningTitle = t('Restart loop detected');
return (
<Popover
aria-label={t('Restart loop detected')}
headerContent={t('Restart loop detected')}
aria-label={warningTitle}
headerContent={warningTitle}
bodyContent={
<Stack hasGutter>
<StackItem>
{t(
'This application has restarted {{ count }} times this session. Stop the application to prevent further restarts and investigate the issue.',
{
count: restartDelta,
},
)}
</StackItem>

{canStop && (
<StackItem>
<RestartLoopStopButton onStop={onStop} isDisabled={stopDisabled} isLoading={stopLoading} />
</StackItem>
)}
</Stack>
<RestartLoopWarningContent
restartDelta={restartDelta}
canStop={canStop}
stopDisabled={stopDisabled}
stopLoading={stopLoading}
onStop={onStop}
/>
}
withFocusTrap={false}
>
<Button aria-label={t('Restart loop detected')} variant="link" isInline>
<Button aria-label={warningTitle} variant="link" isInline>
<Label status="warning" variant="outline">
{restarts}
</Label>
Expand All @@ -154,29 +168,6 @@ const AppRestartsWarning = ({
);
};

const RestartLoopAlert = ({ restartDelta, canStop, stopDisabled, stopLoading, onStop }: RestartLoopWarningProps) => {
const { t } = useTranslation();
return (
<Alert isInline variant="warning" title={t('This application is restarting repeatedly')}>
<Stack hasGutter>
<StackItem>
{t(
'The application has restarted {{ count }} times this session and may be misconfigured. Stop the application to prevent further restarts and investigate the issue.',
{
count: restartDelta,
},
)}
</StackItem>
{canStop && (
<StackItem>
<RestartLoopStopButton onStop={onStop} isDisabled={stopDisabled} isLoading={stopLoading} />
</StackItem>
)}
</Stack>
</Alert>
);
};

type ApplicationTableRowProps = BaseApplicationsTableProps & {
desiredState?: ApplicationDesiredState;
application: StatusAppWithSpec;
Expand Down Expand Up @@ -284,13 +275,15 @@ const ApplicationTableRow = ({
</StackItem>
{showRestartLoopWarning && isExpanded && (
<StackItem>
<RestartLoopAlert
restartDelta={restartDelta}
canStop={canStop}
stopDisabled={isStopDisabled}
stopLoading={lifecycle.isSubmitting}
onStop={onStop}
/>
<Alert isInline variant="warning" title={t('This application is restarting repeatedly')}>
<RestartLoopWarningContent
restartDelta={restartDelta}
canStop={canStop}
stopDisabled={isStopDisabled}
stopLoading={lifecycle.isSubmitting}
onStop={onStop}
/>
</Alert>
</StackItem>
)}
<StackItem>
Expand Down
Loading
Loading