Skip to content

Commit

Permalink
Merge pull request ansible#9437 from nixocio/ui_issue_9432
Browse files Browse the repository at this point in the history
Add organization to EE details page

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
  • Loading branch information
2 parents a3bb022 + ce7bf59 commit b40145e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import { ExecutionEnvironmentsAPI } from '../../../api';

function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
const history = useHistory();
const { id, name, image, description, pull } = executionEnvironment;
const {
id,
name,
image,
description,
pull,
organization,
summary_fields,
} = executionEnvironment;

const {
request: deleteExecutionEnvironment,
Expand Down Expand Up @@ -51,6 +59,21 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
value={description}
dataCy="execution-environment-detail-description"
/>
<Detail
label={i18n._(t`Organization`)}
value={
organization ? (
<Link
to={`/organizations/${summary_fields.organization.id}/details`}
>
{summary_fields.organization.name}
</Link>
) : (
i18n._(t`Globally Available`)
)
}
dataCy="execution-environment-detail-organization"
/>
<Detail
label={i18n._(t`Pull`)}
value={pull === '' ? i18n._(t`Missing`) : toTitleCase(pull)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,45 @@ describe('<ExecutionEnvironmentDetails/>', () => {
expect(wrapper.find('Detail[label="Description"]').prop('value')).toEqual(
'Foo'
);
expect(wrapper.find('Detail[label="Organization"]').prop('value')).toEqual(
'Globally Available'
);
expect(
wrapper.find('Detail[label="Credential"]').prop('value').props.children
).toEqual(executionEnvironment.summary_fields.credential.name);
const dates = wrapper.find('UserDateDetail');
expect(dates).toHaveLength(2);
expect(dates.at(0).prop('date')).toEqual(executionEnvironment.created);
expect(dates.at(1).prop('date')).toEqual(executionEnvironment.modified);
});

test('should render organization detail', async () => {
await act(async () => {
wrapper = mountWithContexts(
<ExecutionEnvironmentDetails
executionEnvironment={{
...executionEnvironment,
organization: 1,
summary_fields: {
organization: { id: 1, name: 'Bar' },
credential: {
id: 4,
name: 'Container Registry',
},
},
}}
/>
);
});
wrapper.update();

expect(wrapper.find('Detail[label="Image"]').prop('value')).toEqual(
executionEnvironment.image
);
expect(wrapper.find('Detail[label="Description"]').prop('value')).toEqual(
'Foo'
);
expect(wrapper.find(`Detail[label="Organization"] dd`).text()).toBe('Bar');
expect(
wrapper.find('Detail[label="Credential"]').prop('value').props.children
).toEqual(executionEnvironment.summary_fields.credential.name);
Expand Down

0 comments on commit b40145e

Please sign in to comment.