mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 18:37:39 -02:30
Merge pull request #10696 from nixocio/ui_status_label
Create map of strings to be translated
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
import { oneOf } from 'prop-types';
|
import { oneOf } from 'prop-types';
|
||||||
import { Label, Tooltip } from '@patternfly/react-core';
|
import { Label, Tooltip } from '@patternfly/react-core';
|
||||||
import {
|
import {
|
||||||
@@ -49,7 +50,18 @@ const icons = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function StatusLabel({ status, tooltipContent = '' }) {
|
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 color = colors[status] || 'grey';
|
||||||
const Icon = icons[status];
|
const Icon = icons[status];
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ describe('StatusLabel', () => {
|
|||||||
expect(wrapper.text()).toEqual('Waiting');
|
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', () => {
|
test('should render canceled', () => {
|
||||||
const wrapper = mount(<StatusLabel status="canceled" />);
|
const wrapper = mount(<StatusLabel status="canceled" />);
|
||||||
expect(wrapper).toHaveLength(1);
|
expect(wrapper).toHaveLength(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user