Commit 594ebe7a authored by Andrew Fontaine's avatar Andrew Fontaine

Add deployment IID to new environments table

Show a deployment's IID to ensure users can refer to a specific
deployment easier.
parent 5033a9b8
<script> <script>
import { GlBadge } from '@gitlab/ui'; import { GlBadge, GlIcon, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import DeploymentStatusBadge from './deployment_status_badge.vue'; import DeploymentStatusBadge from './deployment_status_badge.vue';
...@@ -7,6 +7,10 @@ export default { ...@@ -7,6 +7,10 @@ export default {
components: { components: {
DeploymentStatusBadge, DeploymentStatusBadge,
GlBadge, GlBadge,
GlIcon,
},
directives: {
GlTooltip,
}, },
props: { props: {
deployment: { deployment: {
...@@ -23,9 +27,13 @@ export default { ...@@ -23,9 +27,13 @@ export default {
status() { status() {
return this.deployment?.status; return this.deployment?.status;
}, },
iid() {
return this.deployment?.iid;
},
}, },
i18n: { i18n: {
latestBadge: s__('Deployment|Latest Deployed'), latestBadge: s__('Deployment|Latest Deployed'),
deploymentId: s__('Deployment|Deployment ID'),
}, },
}; };
</script> </script>
...@@ -33,5 +41,13 @@ export default { ...@@ -33,5 +41,13 @@ export default {
<div class="gl-display-flex gl-align-items-center gl-gap-x-3"> <div class="gl-display-flex gl-align-items-center gl-gap-x-3">
<deployment-status-badge v-if="status" :status="status" /> <deployment-status-badge v-if="status" :status="status" />
<gl-badge v-if="latest" variant="info">{{ $options.i18n.latestBadge }}</gl-badge> <gl-badge v-if="latest" variant="info">{{ $options.i18n.latestBadge }}</gl-badge>
<div
v-if="iid"
v-gl-tooltip
:title="$options.i18n.deploymentId"
:aria-label="$options.i18n.deploymentId"
>
<gl-icon ref="deployment-iid-icon" name="deployments" /> {{ iid }}
</div>
</div> </div>
</template> </template>
...@@ -11994,6 +11994,9 @@ msgstr "" ...@@ -11994,6 +11994,9 @@ msgstr ""
msgid "Deployment|Created" msgid "Deployment|Created"
msgstr "" msgstr ""
msgid "Deployment|Deployment ID"
msgstr ""
msgid "Deployment|Failed" msgid "Deployment|Failed"
msgstr "" msgstr ""
......
...@@ -5,12 +5,13 @@ import DeploymentStatusBadge from '~/environments/components/deployment_status_b ...@@ -5,12 +5,13 @@ import DeploymentStatusBadge from '~/environments/components/deployment_status_b
import { resolvedEnvironment } from './graphql/mock_data'; import { resolvedEnvironment } from './graphql/mock_data';
describe('~/environments/components/deployment.vue', () => { describe('~/environments/components/deployment.vue', () => {
const deployment = resolvedEnvironment.lastDeployment;
let wrapper; let wrapper;
const createWrapper = ({ propsData = {} } = {}) => const createWrapper = ({ propsData = {} } = {}) =>
mountExtended(Deployment, { mountExtended(Deployment, {
propsData: { propsData: {
deployment: resolvedEnvironment.lastDeployment, deployment,
...propsData, ...propsData,
}, },
}); });
...@@ -22,9 +23,7 @@ describe('~/environments/components/deployment.vue', () => { ...@@ -22,9 +23,7 @@ describe('~/environments/components/deployment.vue', () => {
describe('status', () => { describe('status', () => {
it('should pass the deployable status to the badge', () => { it('should pass the deployable status to the badge', () => {
wrapper = createWrapper(); wrapper = createWrapper();
expect(wrapper.findComponent(DeploymentStatusBadge).props('status')).toBe( expect(wrapper.findComponent(DeploymentStatusBadge).props('status')).toBe(deployment.status);
resolvedEnvironment.lastDeployment.status,
);
}); });
}); });
...@@ -45,4 +44,41 @@ describe('~/environments/components/deployment.vue', () => { ...@@ -45,4 +44,41 @@ describe('~/environments/components/deployment.vue', () => {
expect(badge.exists()).toBe(false); expect(badge.exists()).toBe(false);
}); });
}); });
describe('iid', () => {
const findIid = () => wrapper.findByTitle(s__('Deployment|Deployment ID'));
const findDeploymentIcon = () => wrapper.findComponent({ ref: 'deployment-iid-icon' });
describe('is present', () => {
beforeEach(() => {
wrapper = createWrapper();
});
it('should show the iid', () => {
const iid = findIid();
expect(iid.exists()).toBe(true);
});
it('should show an icon for the iid', () => {
const deploymentIcon = findDeploymentIcon();
expect(deploymentIcon.props('name')).toBe('deployments');
});
});
describe('is not present', () => {
beforeEach(() => {
wrapper = createWrapper({ propsData: { deployment: { ...deployment, iid: '' } } });
});
it('should not show the iid', () => {
const iid = findIid();
expect(iid.exists()).toBe(false);
});
it('should not show an icon for the iid', () => {
const deploymentIcon = findDeploymentIcon();
expect(deploymentIcon.exists()).toBe(false);
});
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment