Commit be4c0661 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'afontaine/new-deployment-component' into 'master'

Add empty deployment component

See merge request gitlab-org/gitlab!78003
parents bc474e19 d46797cc
<script>
export default {
props: {
deployment: {
type: Object,
required: true,
},
},
};
</script>
<template>
<div></div>
</template>
...@@ -70,9 +70,9 @@ export default { ...@@ -70,9 +70,9 @@ export default {
<template> <template>
<div <div
:class="{ 'gl-pb-5': !visible }" :class="{ 'gl-pb-5': !visible }"
class="gl-border-b-solid gl-border-gray-100 gl-border-1 gl-px-3 gl-pt-3" class="gl-border-b-solid gl-border-gray-100 gl-border-1 gl-pt-3"
> >
<div class="gl-w-full gl-display-flex gl-align-items-center"> <div class="gl-w-full gl-display-flex gl-align-items-center gl-px-3">
<gl-button <gl-button
class="gl-mr-4 gl-fill-current-color gl-text-gray-500" class="gl-mr-4 gl-fill-current-color gl-text-gray-500"
:aria-label="label" :aria-label="label"
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
:key="environment.name" :key="environment.name"
:environment="environment" :environment="environment"
:class="{ 'gl-mt-5': isFirstEnvironment(index) }" :class="{ 'gl-mt-5': isFirstEnvironment(index) }"
class="gl-border-gray-100 gl-border-t-solid gl-border-1 gl-pl-7 gl-pt-3" class="gl-border-gray-100 gl-border-t-solid gl-border-1 gl-pt-3"
in-folder in-folder
/> />
</gl-collapse> </gl-collapse>
......
...@@ -17,6 +17,7 @@ import Pin from './environment_pin.vue'; ...@@ -17,6 +17,7 @@ import Pin from './environment_pin.vue';
import Monitoring from './environment_monitoring.vue'; import Monitoring from './environment_monitoring.vue';
import Terminal from './environment_terminal_button.vue'; import Terminal from './environment_terminal_button.vue';
import Delete from './environment_delete.vue'; import Delete from './environment_delete.vue';
import Deployment from './deployment.vue';
export default { export default {
components: { components: {
...@@ -25,6 +26,7 @@ export default { ...@@ -25,6 +26,7 @@ export default {
GlButton, GlButton,
GlLink, GlLink,
Actions, Actions,
Deployment,
ExternalUrl, ExternalUrl,
StopComponent, StopComponent,
Rollback, Rollback,
...@@ -75,11 +77,17 @@ export default { ...@@ -75,11 +77,17 @@ export default {
label() { label() {
return this.visible ? this.$options.i18n.collapse : this.$options.i18n.expand; return this.visible ? this.$options.i18n.collapse : this.$options.i18n.expand;
}, },
lastDeployment() {
return this.environment?.lastDeployment;
},
upcomingDeployment() {
return this.environment?.upcomingDeployment;
},
actions() { actions() {
if (!this.environment?.lastDeployment) { if (!this.lastDeployment) {
return []; return [];
} }
const { manualActions = [], scheduledActions = [] } = this.environment.lastDeployment; const { manualActions = [], scheduledActions = [] } = this.lastDeployment;
const combinedActions = [...manualActions, ...scheduledActions]; const combinedActions = [...manualActions, ...scheduledActions];
return combinedActions.map((action) => ({ return combinedActions.map((action) => ({
...action, ...action,
...@@ -89,7 +97,7 @@ export default { ...@@ -89,7 +97,7 @@ export default {
return this.environment?.canStop; return this.environment?.canStop;
}, },
retryPath() { retryPath() {
return this.environment?.lastDeployment?.deployable?.retryPath; return this.lastDeployment?.deployable?.retryPath;
}, },
hasExtraActions() { hasExtraActions() {
return Boolean( return Boolean(
...@@ -131,6 +139,14 @@ export default { ...@@ -131,6 +139,14 @@ export default {
this.visible = !this.visible; this.visible = !this.visible;
}, },
}, },
deploymentClasses: [
'gl-border-gray-100',
'gl-border-t-solid',
'gl-border-1',
'gl-py-5',
'gl-pl-7',
'gl-bg-gray-10',
],
}; };
</script> </script>
<template> <template>
...@@ -138,7 +154,10 @@ export default { ...@@ -138,7 +154,10 @@ export default {
<div <div
class="gl-px-3 gl-pt-3 gl-pb-5 gl-display-flex gl-justify-content-space-between gl-align-items-center" class="gl-px-3 gl-pt-3 gl-pb-5 gl-display-flex gl-justify-content-space-between gl-align-items-center"
> >
<div class="gl-min-w-0 gl-mr-4 gl-display-flex gl-align-items-center"> <div
:class="{ 'gl-ml-7': inFolder }"
class="gl-min-w-0 gl-mr-4 gl-display-flex gl-align-items-center"
>
<gl-button <gl-button
class="gl-mr-4 gl-min-w-fit-content" class="gl-mr-4 gl-min-w-fit-content"
:icon="icon" :icon="icon"
...@@ -234,6 +253,13 @@ export default { ...@@ -234,6 +253,13 @@ export default {
</div> </div>
</div> </div>
</div> </div>
<gl-collapse :visible="visible" /> <gl-collapse :visible="visible">
<div v-if="lastDeployment" :class="$options.deploymentClasses">
<deployment :deployment="lastDeployment" :class="{ 'gl-ml-7': inFolder }" />
</div>
<div v-if="upcomingDeployment" :class="$options.deploymentClasses">
<deployment :deployment="upcomingDeployment" :class="{ 'gl-ml-7': inFolder }" />
</div>
</gl-collapse>
</div> </div>
</template> </template>
...@@ -6,6 +6,7 @@ import { mountExtended } from 'helpers/vue_test_utils_helper'; ...@@ -6,6 +6,7 @@ import { mountExtended } from 'helpers/vue_test_utils_helper';
import { stubTransition } from 'helpers/stub_transition'; import { stubTransition } from 'helpers/stub_transition';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import EnvironmentItem from '~/environments/components/new_environment_item.vue'; import EnvironmentItem from '~/environments/components/new_environment_item.vue';
import Deployment from '~/environments/components/deployment.vue';
import { resolvedEnvironment } from './graphql/mock_data'; import { resolvedEnvironment } from './graphql/mock_data';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -24,6 +25,8 @@ describe('~/environments/components/new_environment_item.vue', () => { ...@@ -24,6 +25,8 @@ describe('~/environments/components/new_environment_item.vue', () => {
stubs: { transition: stubTransition() }, stubs: { transition: stubTransition() },
}); });
const findDeployment = () => wrapper.findComponent(Deployment);
afterEach(() => { afterEach(() => {
wrapper?.destroy(); wrapper?.destroy();
}); });
...@@ -273,12 +276,37 @@ describe('~/environments/components/new_environment_item.vue', () => { ...@@ -273,12 +276,37 @@ describe('~/environments/components/new_environment_item.vue', () => {
}); });
it('opens on click', async () => { it('opens on click', async () => {
expect(findDeployment().isVisible()).toBe(false);
await button.trigger('click'); await button.trigger('click');
expect(button.attributes('aria-label')).toBe(__('Collapse')); expect(button.attributes('aria-label')).toBe(__('Collapse'));
expect(collapse.attributes('visible')).toBe('visible'); expect(collapse.attributes('visible')).toBe('visible');
expect(icon.props('name')).toEqual('angle-down'); expect(icon.props('name')).toEqual('angle-down');
expect(environmentName.classes('gl-font-weight-bold')).toBe(true); expect(environmentName.classes('gl-font-weight-bold')).toBe(true);
expect(findDeployment().isVisible()).toBe(true);
});
});
describe('last deployment', () => {
it('should pass the last deployment to the deployment component when it exists', () => {
wrapper = createWrapper({ apolloProvider: createApolloProvider() });
const deployment = findDeployment();
expect(deployment.props('deployment')).toEqual(resolvedEnvironment.lastDeployment);
});
it('should not show the last deployment to the deployment component when it is missing', () => {
const environment = {
...resolvedEnvironment,
lastDeployment: null,
};
wrapper = createWrapper({
propsData: { environment },
apolloProvider: createApolloProvider(),
});
const deployment = findDeployment();
expect(deployment.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