Skip to content

Commit

Permalink
PMM-13348 Fix status presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Sep 10, 2024
1 parent 2e456a6 commit c3f81c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions public/app/percona/inventory/Tabs/Agents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { GET_AGENTS_CANCEL_TOKEN, GET_NODES_CANCEL_TOKEN, GET_SERVICES_CANCEL_TO
import { Messages } from '../Inventory.messages';
import { InventoryService } from '../Inventory.service';

import { beautifyAgentType, getAgentStatusColor, toAgentModel } from './Agents.utils';
import { beautifyAgentType, getAgentStatusColor, getBadgeTextForAgentStatus, toAgentModel } from './Agents.utils';
import { formatNodeId } from './Nodes.utils';
import { getStyles } from './Tabs.styles';

Expand Down Expand Up @@ -64,7 +64,7 @@ export const Agents: FC<GrafanaRouteComponentProps<{ serviceId: string; nodeId:
Header: Messages.agents.columns.status,
accessor: 'status',
Cell: ({ value }: { value: ServiceAgentStatus }) => (
<Badge text={capitalizeText(value)} color={getAgentStatusColor(value)} />
<Badge text={getBadgeTextForAgentStatus(value)} color={getAgentStatusColor(value)} />
),
type: FilterFieldTypes.DROPDOWN,
options: [
Expand Down
7 changes: 6 additions & 1 deletion public/app/percona/inventory/Tabs/Agents.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BadgeColor } from '@grafana/ui';
import { capitalizeText } from "app/percona/shared/helpers/capitalizeText";
import { payloadToCamelCase } from 'app/percona/shared/helpers/payloadToCamelCase';

import { Agent, AgentType, ServiceAgentPayload, ServiceAgentStatus } from '../Inventory.types';
Expand Down Expand Up @@ -53,4 +54,8 @@ export const beautifyAgentType = (type: AgentType): string =>
type.replace(/^\w/, (c) => c.toUpperCase()).replace(/[_-]/g, ' ');

export const getAgentStatusColor = (status: ServiceAgentStatus): BadgeColor =>
status === ServiceAgentStatus.STARTING || status === ServiceAgentStatus.RUNNING ? 'green' : 'red';
status === ServiceAgentStatus.STARTING || status === ServiceAgentStatus.RUNNING ? 'green' : status === ServiceAgentStatus.UNKNOWN ? 'gray' : 'red';

export const getBadgeTextForAgentStatus = (status: ServiceAgentStatus): string => {
return capitalizeText(status.replace('_', ' '));
};

0 comments on commit c3f81c3

Please sign in to comment.