mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 23:37:39 -02:30
Fixes missing name bug
This commit is contained in:
@@ -5,7 +5,6 @@ import { t } from '@lingui/macro';
|
|||||||
import { getQSConfig, parseQueryString } from '../../../util/qs';
|
import { getQSConfig, parseQueryString } from '../../../util/qs';
|
||||||
import PaginatedDataList, {
|
import PaginatedDataList, {
|
||||||
ToolbarAddButton,
|
ToolbarAddButton,
|
||||||
ToolbarDeleteButton,
|
|
||||||
} from '../../../components/PaginatedDataList';
|
} from '../../../components/PaginatedDataList';
|
||||||
import useSelected from '../../../util/useSelected';
|
import useSelected from '../../../util/useSelected';
|
||||||
import useRequest from '../../../util/useRequest';
|
import useRequest from '../../../util/useRequest';
|
||||||
@@ -39,7 +38,7 @@ function UserTokenList({ i18n }) {
|
|||||||
application: result.summary_fields.application,
|
application: result.summary_fields.application,
|
||||||
user_capabilities: { delete: true },
|
user_capabilities: { delete: true },
|
||||||
};
|
};
|
||||||
result.username = result.summary_fields.user.username;
|
result.name = result.summary_fields.application?.name;
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
return { tokens: modifiedResults, itemCount: count };
|
return { tokens: modifiedResults, itemCount: count };
|
||||||
@@ -114,12 +113,6 @@ function UserTokenList({ i18n }) {
|
|||||||
/>,
|
/>,
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
<ToolbarDeleteButton
|
|
||||||
key="delete"
|
|
||||||
onDelete={() => {}}
|
|
||||||
itemsToDelete={selected}
|
|
||||||
pluralizedItemName="Tokens"
|
|
||||||
/>,
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -130,7 +123,6 @@ function UserTokenList({ i18n }) {
|
|||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
handleSelect(token);
|
handleSelect(token);
|
||||||
}}
|
}}
|
||||||
detailUrl={`${location.pathname}/details`}
|
|
||||||
isSelected={selected.some(row => row.id === token.id)}
|
isSelected={selected.some(row => row.id === token.id)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -141,10 +141,6 @@ describe('<UserTokenList />', () => {
|
|||||||
wrapper = mountWithContexts(<UserTokenList />);
|
wrapper = mountWithContexts(<UserTokenList />);
|
||||||
});
|
});
|
||||||
waitForElement(wrapper, 'ContentEmpty', el => el.length === 0);
|
waitForElement(wrapper, 'ContentEmpty', el => el.length === 0);
|
||||||
|
|
||||||
expect(wrapper.find('Button[aria-label="Delete"]').prop('isDisabled')).toBe(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should enable edit button', async () => {
|
test('should enable edit button', async () => {
|
||||||
@@ -165,8 +161,5 @@ describe('<UserTokenList />', () => {
|
|||||||
expect(
|
expect(
|
||||||
wrapper.find('DataListCheck[id="select-token-3"]').props().checked
|
wrapper.find('DataListCheck[id="select-token-3"]').props().checked
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
expect(wrapper.find('Button[aria-label="Delete"]').prop('isDisabled')).toBe(
|
|
||||||
false
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import {
|
import {
|
||||||
DataListItemCells,
|
DataListItemCells,
|
||||||
DataListCheck,
|
DataListCheck,
|
||||||
@@ -9,6 +8,7 @@ import {
|
|||||||
DataListItem,
|
DataListItem,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { toTitleCase } from '../../../util/strings';
|
||||||
|
|
||||||
import { formatDateStringUTC } from '../../../util/dates';
|
import { formatDateStringUTC } from '../../../util/dates';
|
||||||
import DataListCell from '../../../components/DataListCell';
|
import DataListCell from '../../../components/DataListCell';
|
||||||
@@ -16,7 +16,12 @@ import DataListCell from '../../../components/DataListCell';
|
|||||||
const Label = styled.b`
|
const Label = styled.b`
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
`;
|
`;
|
||||||
function UserTokenListItem({ i18n, token, isSelected, detailUrl, onSelect }) {
|
|
||||||
|
const NameLabel = styled.b`
|
||||||
|
margin-right: 5px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
function UserTokenListItem({ i18n, token, isSelected, onSelect }) {
|
||||||
const labelId = `check-action-${token.id}`;
|
const labelId = `check-action-${token.id}`;
|
||||||
return (
|
return (
|
||||||
<DataListItem key={token.id} aria-labelledby={labelId} id={`${token.id}`}>
|
<DataListItem key={token.id} aria-labelledby={labelId} id={`${token.id}`}>
|
||||||
@@ -29,14 +34,22 @@ function UserTokenListItem({ i18n, token, isSelected, detailUrl, onSelect }) {
|
|||||||
/>
|
/>
|
||||||
<DataListItemCells
|
<DataListItemCells
|
||||||
dataListCells={[
|
dataListCells={[
|
||||||
<DataListCell aria-label={i18n._(t`name`)} key={token.id}>
|
<DataListCell
|
||||||
<Link to={`${detailUrl}`}>
|
aria-label={i18n._(t`application name`)}
|
||||||
{token.summary_fields.application.name}
|
key={token.id}
|
||||||
</Link>
|
>
|
||||||
|
{token.summary_fields?.application?.name ? (
|
||||||
|
<span>
|
||||||
|
<NameLabel>{i18n._(t`Application:`)}</NameLabel>
|
||||||
|
{token.summary_fields.application.name}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
i18n._(t`Personal access token`)
|
||||||
|
)}
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell aria-label={i18n._(t`scope`)} key={token.scope}>
|
<DataListCell aria-label={i18n._(t`scope`)} key={token.scope}>
|
||||||
<Label>{i18n._(t`Scope`)}</Label>
|
<Label>{i18n._(t`Scope`)}</Label>
|
||||||
{token.scope}
|
{toTitleCase(token.scope)}
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell aria-label={i18n._(t`expiration`)} key="expiration">
|
<DataListCell aria-label={i18n._(t`expiration`)} key="expiration">
|
||||||
<Label>{i18n._(t`Expires`)}</Label>
|
<Label>{i18n._(t`Expires`)}</Label>
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ describe('<UserTokenListItem />', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(wrapper.find('DataListCheck').prop('checked')).toBe(false);
|
expect(wrapper.find('DataListCheck').prop('checked')).toBe(false);
|
||||||
expect(wrapper.find('PFDataListCell[aria-label="name"]').text()).toBe(
|
expect(
|
||||||
'app'
|
wrapper.find('PFDataListCell[aria-label="application name"]').text()
|
||||||
);
|
).toBe('Application:app');
|
||||||
expect(wrapper.find('PFDataListCell[aria-label="scope"]').text()).toBe(
|
expect(wrapper.find('PFDataListCell[aria-label="scope"]').text()).toBe(
|
||||||
'Scoperead'
|
'ScopeRead'
|
||||||
);
|
);
|
||||||
expect(wrapper.find('PFDataListCell[aria-label="expiration"]').text()).toBe(
|
expect(wrapper.find('PFDataListCell[aria-label="expiration"]').text()).toBe(
|
||||||
'Expires10/25/3019, 3:06:43 PM'
|
'Expires10/25/3019, 3:06:43 PM'
|
||||||
|
|||||||
Reference in New Issue
Block a user