Create map of strings to be translated

Create map of strings to be translated to StatusLabel

closes:https://github.com/ansible/awx/issues/8586
This commit is contained in:
nixocio 2021-07-20 16:25:38 -04:00
parent c073583663
commit c1b2428b5d
2 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import 'styled-components/macro';
import React from 'react';
import { t } from '@lingui/macro';
import { oneOf } from 'prop-types';
import { Label, Tooltip } from '@patternfly/react-core';
import {
@ -49,7 +50,18 @@ const icons = {
};
export default function StatusLabel({ status, tooltipContent = '' }) {
const label = status.charAt(0).toUpperCase() + status.slice(1);
const upperCaseStatus = {
success: t`Success`,
successful: t`Successful`,
failed: t`Failed`,
error: t`Error`,
running: t`Running`,
pending: t`Pending`,
waiting: t`Waiting`,
disabled: t`Disabled`,
canceled: t`Canceled`,
};
const label = upperCaseStatus[status] || t`Undefined`;
const color = colors[status] || 'grey';
const Icon = icons[status];

View File

@ -52,6 +52,14 @@ describe('StatusLabel', () => {
expect(wrapper.text()).toEqual('Waiting');
});
test('should render disabled', () => {
const wrapper = mount(<StatusLabel status="disabled" />);
expect(wrapper).toHaveLength(1);
expect(wrapper.find('MinusCircleIcon')).toHaveLength(1);
expect(wrapper.find('Label').prop('color')).toEqual('grey');
expect(wrapper.text()).toEqual('Disabled');
});
test('should render canceled', () => {
const wrapper = mount(<StatusLabel status="canceled" />);
expect(wrapper).toHaveLength(1);