Commit c2a31b61 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Kushal Pandya

Move out the replication slots items to the other information section

parent 7bd2eee9
...@@ -75,8 +75,8 @@ ...@@ -75,8 +75,8 @@
:node-type-primary="node.primary" :node-type-primary="node.primary"
/> />
<node-details-section-other <node-details-section-other
v-if="!node.primary"
:node-details="nodeDetails" :node-details="nodeDetails"
:node-type-primary="node.primary"
/> />
<div <div
v-if="hasError || hasVersionMismatch" v-if="hasError || hasVersionMismatch"
......
<script> <script>
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { VALUE_TYPE } from '../../constants'; import { VALUE_TYPE } from '../../constants';
...@@ -17,13 +18,24 @@ ...@@ -17,13 +18,24 @@
type: Object, type: Object,
required: true, required: true,
}, },
nodeTypePrimary: {
type: Boolean,
required: true,
},
}, },
data() { data() {
return { return {
showSectionItems: false, showSectionItems: false,
primaryNodeDetailItems: this.getPrimaryNodeDetailItems(),
secondaryNodeDetailItems: this.getSecondaryNodeDetailItems(),
}; };
}, },
computed: { computed: {
nodeDetailItems() {
return this.nodeTypePrimary ?
this.getPrimaryNodeDetailItems() :
this.getSecondaryNodeDetailItems();
},
storageShardsStatus() { storageShardsStatus() {
if (this.nodeDetails.storageShardsMatch == null) { if (this.nodeDetails.storageShardsMatch == null) {
return __('Unknown'); return __('Unknown');
...@@ -36,6 +48,42 @@ ...@@ -36,6 +48,42 @@
}, },
}, },
methods: { methods: {
getPrimaryNodeDetailItems() {
const primaryNodeDetailItems = [
{
itemTitle: s__('GeoNodes|Replication slots'),
itemValue: this.nodeDetails.replicationSlots,
itemValueType: VALUE_TYPE.GRAPH,
successLabel: s__('GeoNodes|Used slots'),
neutraLabel: s__('GeoNodes|Unused slots'),
},
];
if (this.nodeDetails.replicationSlots.totalCount) {
primaryNodeDetailItems.push(
{
itemTitle: s__('GeoNodes|Replication slot WAL'),
itemValue: numberToHumanSize(this.nodeDetails.replicationSlotWAL),
itemValueType: VALUE_TYPE.PLAIN,
cssClass: 'node-detail-value-bold',
},
);
}
return primaryNodeDetailItems;
},
getSecondaryNodeDetailItems() {
const secondaryNodeDetailItems = [
{
itemTitle: s__('GeoNodes|Storage config'),
itemValue: this.storageShardsStatus,
itemValueType: VALUE_TYPE.PLAIN,
cssClass: this.storageShardsCssClass,
},
];
return secondaryNodeDetailItems;
},
handleSectionToggle(toggleState) { handleSectionToggle(toggleState) {
this.showSectionItems = toggleState; this.showSectionItems = toggleState;
}, },
...@@ -56,10 +104,14 @@ ...@@ -56,10 +104,14 @@
class="col-md-6 prepend-left-15 prepend-top-10 section-items-container" class="col-md-6 prepend-left-15 prepend-top-10 section-items-container"
> >
<geo-node-detail-item <geo-node-detail-item
:item-title="s__('GeoNodes|Storage config')" v-for="(nodeDetailItem, index) in nodeDetailItems"
:item-value="storageShardsStatus" :key="index"
:item-value-type="$options.valueType.PLAIN" :css-class="nodeDetailItem.cssClass"
:css-class="storageShardsCssClass" :item-title="nodeDetailItem.itemTitle"
:item-value="nodeDetailItem.itemValue"
:item-value-type="nodeDetailItem.itemValueType"
:success-label="nodeDetailItem.successLabel"
:neutral-label="nodeDetailItem.neutraLabel"
/> />
</div> </div>
</div> </div>
......
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { VALUE_TYPE, HELP_INFO_URL } from '../../constants'; import { VALUE_TYPE, HELP_INFO_URL } from '../../constants';
...@@ -77,27 +76,6 @@ ...@@ -77,27 +76,6 @@
); );
} }
primaryNodeDetailItems.push(
{
itemTitle: s__('GeoNodes|Replication slots'),
itemValue: this.nodeDetails.replicationSlots,
itemValueType: VALUE_TYPE.GRAPH,
successLabel: s__('GeoNodes|Used slots'),
neutraLabel: s__('GeoNodes|Unused slots'),
},
);
if (this.nodeDetails.replicationSlots.totalCount) {
primaryNodeDetailItems.push(
{
itemTitle: s__('GeoNodes|Replication slot WAL'),
itemValue: numberToHumanSize(this.nodeDetails.replicationSlotWAL),
itemValueType: VALUE_TYPE.PLAIN,
cssClass: 'node-detail-value-bold',
},
);
}
return primaryNodeDetailItems; return primaryNodeDetailItems;
}, },
getSecondaryNodeDetailItems() { getSecondaryNodeDetailItems() {
......
...@@ -2,15 +2,18 @@ import Vue from 'vue'; ...@@ -2,15 +2,18 @@ import Vue from 'vue';
import NodeDetailsSectionOtherComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_other.vue'; import NodeDetailsSectionOtherComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_other.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { mockNodeDetails } from '../../mock_data'; import { mockNodeDetails } from '../../mock_data';
const createComponent = ( const createComponent = (
nodeDetails = Object.assign({}, mockNodeDetails), nodeDetails = Object.assign({}, mockNodeDetails),
nodeTypePrimary = false,
) => { ) => {
const Component = Vue.extend(NodeDetailsSectionOtherComponent); const Component = Vue.extend(NodeDetailsSectionOtherComponent);
return mountComponent(Component, { return mountComponent(Component, {
nodeDetails, nodeDetails,
nodeTypePrimary,
}); });
}; };
...@@ -28,6 +31,10 @@ describe('NodeDetailsSectionOther', () => { ...@@ -28,6 +31,10 @@ describe('NodeDetailsSectionOther', () => {
describe('data', () => { describe('data', () => {
it('returns default data props', () => { it('returns default data props', () => {
expect(vm.showSectionItems).toBe(false); expect(vm.showSectionItems).toBe(false);
expect(Array.isArray(vm.primaryNodeDetailItems)).toBe(true);
expect(Array.isArray(vm.secondaryNodeDetailItems)).toBe(true);
expect(vm.primaryNodeDetailItems.length > 0).toBe(true);
expect(vm.secondaryNodeDetailItems.length > 0).toBe(true);
}); });
}); });
...@@ -75,6 +82,32 @@ describe('NodeDetailsSectionOther', () => { ...@@ -75,6 +82,32 @@ describe('NodeDetailsSectionOther', () => {
}); });
}); });
describe('methods', () => {
describe('getPrimaryNodeDetailItems', () => {
it('returns array containing items to show under primary node', () => {
const items = vm.getPrimaryNodeDetailItems();
expect(items.length).toBe(2);
expect(items[0].itemTitle).toBe('Replication slots');
expect(items[0].itemValue).toBe(mockNodeDetails.replicationSlots);
expect(items[1].itemTitle).toBe('Replication slot WAL');
expect(items[1].itemValue).toBe(numberToHumanSize(mockNodeDetails.replicationSlotWAL));
});
});
describe('getSecondaryNodeDetailItems', () => {
it('returns array containing items to show under secondary node', () => {
vm.nodeDetails.storageShardsMatch = true;
const items = vm.getSecondaryNodeDetailItems();
expect(items.length).toBe(1);
expect(items[0].itemTitle).toBe('Storage config');
expect(items[0].itemValue).toBe('OK');
});
});
});
describe('template', () => { describe('template', () => {
it('renders component container element', () => { it('renders component container element', () => {
expect(vm.$el.classList.contains('other-section')).toBe(true); expect(vm.$el.classList.contains('other-section')).toBe(true);
......
...@@ -66,10 +66,6 @@ describe('NodeDetailsSectionVerification', () => { ...@@ -66,10 +66,6 @@ describe('NodeDetailsSectionVerification', () => {
title: 'Wiki checksum progress', title: 'Wiki checksum progress',
valueProp: 'wikisChecksummed', valueProp: 'wikisChecksummed',
}, },
{
title: 'Replication slots',
valueProp: 'replicationSlots',
},
]; ];
it('returns array containing items to show under primary node', () => { it('returns array containing items to show under primary node', () => {
......
...@@ -153,8 +153,8 @@ export const mockNodeDetails = { ...@@ -153,8 +153,8 @@ export const mockNodeDetails = {
storageShardsMatch: false, storageShardsMatch: false,
repositoryVerificationEnabled: true, repositoryVerificationEnabled: true,
replicationSlots: { replicationSlots: {
totalCount: null, totalCount: 1,
successCount: null, successCount: 1,
failureCount: 0, failureCount: 0,
}, },
repositories: { repositories: {
......
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