Commit cc9def05 authored by Adriel Santiago's avatar Adriel Santiago Committed by Fatih Acet

Resolve "Show number of pods deployed on Deploy Boards"

parent bff7c4b1
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
import _ from 'underscore'; import _ from 'underscore';
import { n__ } from '~/locale'; import { n__ } from '~/locale';
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import deployBoardSvg from 'ee_empty_states/icons/_deploy_board.svg'; import deployBoardSvg from 'ee_empty_states/icons/_deploy_board.svg';
import instanceComponent from './deploy_board_instance_component.vue'; import instanceComponent from './deploy_board_instance_component.vue';
...@@ -19,6 +20,9 @@ ...@@ -19,6 +20,9 @@
instanceComponent, instanceComponent,
loadingIcon, loadingIcon,
}, },
directives: {
tooltip,
},
props: { props: {
deployBoardData: { deployBoardData: {
type: Object, type: Object,
...@@ -45,8 +49,24 @@ ...@@ -45,8 +49,24 @@
canRenderEmptyState() { canRenderEmptyState() {
return !this.isLoading && this.isEmpty; return !this.isLoading && this.isEmpty;
}, },
instanceCount() {
const { instances } = this.deployBoardData;
return Array.isArray(instances) ? instances.length : 0;
},
instanceIsCompletedCount() {
const completionPercentage = this.deployBoardData.completion / 100;
const completionCount = Math.floor(completionPercentage * this.instanceCount);
return Number.isNaN(completionCount) ? 0 : completionCount;
},
instanceIsCompletedText() {
const title = n__('instance completed', 'instances completed', this.instanceIsCompletedCount);
return `${this.instanceIsCompletedCount} ${title}`;
},
instanceTitle() { instanceTitle() {
return n__('Instance', 'Instances', this.deployBoardData.instances.length); return n__('Instance', 'Instances', this.instanceCount);
}, },
projectName() { projectName() {
return '<projectname>'; return '<projectname>';
...@@ -65,14 +85,20 @@ ...@@ -65,14 +85,20 @@
<div v-if="canRenderDeployBoard"> <div v-if="canRenderDeployBoard">
<section class="deploy-board-information"> <section class="deploy-board-information">
<span> <span
v-tooltip
:title="instanceIsCompletedText"
>
<span class="percentage">{{ deployBoardData.completion }}%</span> <span class="percentage">{{ deployBoardData.completion }}%</span>
<span class="text">Complete</span> <span class="text">Complete</span>
</span> </span>
</section> </section>
<section class="deploy-board-instances"> <section class="deploy-board-instances">
<p class="text">{{ instanceTitle }}</p> <p class="text">
<span>{{ instanceTitle }}</span>
<span class="total-instances">({{ instanceCount }})</span>
</p>
<div class="deploy-board-instances-container"> <div class="deploy-board-instances-container">
<template v-for="(instance, i) in deployBoardData.instances"> <template v-for="(instance, i) in deployBoardData.instances">
......
---
title: Show total and completed instances deployed on deploy boards
merge_request: 6955
author:
type: added
...@@ -29,6 +29,15 @@ describe('Deploy Board', () => { ...@@ -29,6 +29,15 @@ describe('Deploy Board', () => {
).toEqual(`${deployBoardMockData.completion}%`); ).toEqual(`${deployBoardMockData.completion}%`);
}); });
it('should render total instance count', () => {
const renderedTotal = component.$el.querySelector('.deploy-board-instances .total-instances');
const actualTotal = deployBoardMockData.instances.length;
expect(
renderedTotal.textContent,
).toEqual(`(${actualTotal})`);
});
it('should render all instances', () => { it('should render all instances', () => {
const instances = component.$el.querySelectorAll('.deploy-board-instances-container a'); const instances = component.$el.querySelectorAll('.deploy-board-instances-container a');
......
...@@ -8476,6 +8476,11 @@ msgstr "" ...@@ -8476,6 +8476,11 @@ msgstr ""
msgid "importing" msgid "importing"
msgstr "" msgstr ""
msgid "instance completed"
msgid_plural "instances completed"
msgstr[0] ""
msgstr[1] ""
msgid "is invalid because there is downstream lock" msgid "is invalid because there is downstream lock"
msgstr "" msgstr ""
......
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