Commit d2cc4ddb authored by Phil Hughes's avatar Phil Hughes

Merge branch '327647_01-geo-node-beta-new-edit-actions' into 'master'

Geo Status Page 2.0 - Edit Actions

See merge request gitlab-org/gitlab!59686
parents 1ec8b0be 36bf7bf9
...@@ -9,10 +9,9 @@ export default { ...@@ -9,10 +9,9 @@ export default {
GeoNodeActionsDesktop, GeoNodeActionsDesktop,
}, },
props: { props: {
primary: { node: {
type: Boolean, type: Object,
required: false, required: true,
default: false,
}, },
}, },
}; };
...@@ -20,7 +19,7 @@ export default { ...@@ -20,7 +19,7 @@ export default {
<template> <template>
<div> <div>
<geo-node-actions-mobile class="gl-lg-display-none" :primary="primary" /> <geo-node-actions-mobile class="gl-lg-display-none" :node="node" />
<geo-node-actions-desktop class="gl-display-none gl-lg-display-flex" :primary="primary" /> <geo-node-actions-desktop class="gl-display-none gl-lg-display-flex" :node="node" />
</div> </div>
</template> </template>
...@@ -12,10 +12,9 @@ export default { ...@@ -12,10 +12,9 @@ export default {
GlButton, GlButton,
}, },
props: { props: {
primary: { node: {
type: Boolean, type: Object,
required: false, required: true,
default: false,
}, },
}, },
}; };
...@@ -23,11 +22,13 @@ export default { ...@@ -23,11 +22,13 @@ export default {
<template> <template>
<div> <div>
<gl-button class="gl-mr-3">{{ $options.i18n.editButtonLabel }}</gl-button> <gl-button class="gl-mr-3" :href="node.webEditUrl">{{
$options.i18n.editButtonLabel
}}</gl-button>
<gl-button <gl-button
variant="danger" variant="danger"
category="secondary" category="secondary"
:disabled="primary" :disabled="node.primary"
data-testid="geo-desktop-remove-action" data-testid="geo-desktop-remove-action"
>{{ $options.i18n.removeButtonLabel }}</gl-button >{{ $options.i18n.removeButtonLabel }}</gl-button
> >
......
...@@ -14,15 +14,14 @@ export default { ...@@ -14,15 +14,14 @@ export default {
GlIcon, GlIcon,
}, },
props: { props: {
primary: { node: {
type: Boolean, type: Object,
required: false, required: true,
default: false,
}, },
}, },
computed: { computed: {
dropdownRemoveClass() { dropdownRemoveClass() {
return this.primary ? 'gl-text-gray-400' : 'gl-text-red-500'; return this.node.primary ? 'gl-text-gray-400' : 'gl-text-red-500';
}, },
}, },
}; };
...@@ -33,8 +32,8 @@ export default { ...@@ -33,8 +32,8 @@ export default {
<template #button-content> <template #button-content>
<gl-icon name="ellipsis_h" /> <gl-icon name="ellipsis_h" />
</template> </template>
<gl-dropdown-item>{{ $options.i18n.editButtonLabel }}</gl-dropdown-item> <gl-dropdown-item :href="node.webEditUrl">{{ $options.i18n.editButtonLabel }}</gl-dropdown-item>
<gl-dropdown-item :disabled="primary" data-testid="geo-mobile-remove-action"> <gl-dropdown-item :disabled="node.primary" data-testid="geo-mobile-remove-action">
<span :class="dropdownRemoveClass">{{ $options.i18n.removeButtonLabel }}</span> <span :class="dropdownRemoveClass">{{ $options.i18n.removeButtonLabel }}</span>
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
......
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
</div> </div>
</div> </div>
<div class="gl-display-flex gl-align-items-center gl-justify-content-end"> <div class="gl-display-flex gl-align-items-center gl-justify-content-end">
<geo-node-actions :primary="node.primary" /> <geo-node-actions :node="node" />
</div> </div>
</div> </div>
</template> </template>
...@@ -2,7 +2,11 @@ import { GlButton } from '@gitlab/ui'; ...@@ -2,7 +2,11 @@ import { GlButton } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue'; import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data'; import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -11,7 +15,7 @@ describe('GeoNodeActionsDesktop', () => { ...@@ -11,7 +15,7 @@ describe('GeoNodeActionsDesktop', () => {
let wrapper; let wrapper;
const defaultProps = { const defaultProps = {
primary: true, node: MOCK_NODES[0],
}; };
const createComponent = (initialState, props) => { const createComponent = (initialState, props) => {
...@@ -54,6 +58,12 @@ describe('GeoNodeActionsDesktop', () => { ...@@ -54,6 +58,12 @@ describe('GeoNodeActionsDesktop', () => {
'Remove', 'Remove',
]); ]);
}); });
it('renders edit link correctly', () => {
expect(findGeoDesktopActionsButtons().at(0).attributes('href')).toBe(
MOCK_NODES[0].webEditUrl,
);
});
}); });
describe.each` describe.each`
...@@ -62,11 +72,11 @@ describe('GeoNodeActionsDesktop', () => { ...@@ -62,11 +72,11 @@ describe('GeoNodeActionsDesktop', () => {
${false} | ${undefined} ${false} | ${undefined}
`(`conditionally`, ({ primary, disabled }) => { `(`conditionally`, ({ primary, disabled }) => {
beforeEach(() => { beforeEach(() => {
createComponent(null, { primary }); createComponent(null, { node: { primary } });
}); });
describe(`when primary is ${primary}`, () => { describe(`when primary is ${primary}`, () => {
it('disables the Desktop Remove button', () => { it(`does ${primary ? '' : 'not '}disable the Desktop Remove button`, () => {
expect(findGeoDesktopActionsRemoveButton().attributes('disabled')).toBe(disabled); expect(findGeoDesktopActionsRemoveButton().attributes('disabled')).toBe(disabled);
}); });
}); });
......
...@@ -2,7 +2,11 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; ...@@ -2,7 +2,11 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue'; import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data'; import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -11,7 +15,7 @@ describe('GeoNodeActionsMobile', () => { ...@@ -11,7 +15,7 @@ describe('GeoNodeActionsMobile', () => {
let wrapper; let wrapper;
const defaultProps = { const defaultProps = {
primary: true, node: MOCK_NODES[0],
}; };
const createComponent = (initialState, props) => { const createComponent = (initialState, props) => {
...@@ -59,6 +63,12 @@ describe('GeoNodeActionsMobile', () => { ...@@ -59,6 +63,12 @@ describe('GeoNodeActionsMobile', () => {
'Remove', 'Remove',
]); ]);
}); });
it('renders edit link correctly', () => {
expect(findGeoMobileActionsDropdownItems().at(0).attributes('href')).toBe(
MOCK_NODES[0].webEditUrl,
);
});
}); });
describe.each` describe.each`
...@@ -67,11 +77,13 @@ describe('GeoNodeActionsMobile', () => { ...@@ -67,11 +77,13 @@ describe('GeoNodeActionsMobile', () => {
${false} | ${undefined} | ${'gl-text-red-500'} ${false} | ${undefined} | ${'gl-text-red-500'}
`(`conditionally`, ({ primary, disabled, dropdownClass }) => { `(`conditionally`, ({ primary, disabled, dropdownClass }) => {
beforeEach(() => { beforeEach(() => {
createComponent(null, { primary }); createComponent(null, { node: { primary } });
}); });
describe(`when primary is ${primary}`, () => { describe(`when primary is ${primary}`, () => {
it('disables the Mobile Remove dropdown item and adds proper class', () => { it(`does ${
primary ? '' : 'not '
}disable the Mobile Remove dropdown item and adds proper class`, () => {
expect(findGeoMobileActionsRemoveDropdownItem().attributes('disabled')).toBe(disabled); expect(findGeoMobileActionsRemoveDropdownItem().attributes('disabled')).toBe(disabled);
expect(findGeoMobileActionsRemoveDropdownItem().find('span').classes(dropdownClass)).toBe( expect(findGeoMobileActionsRemoveDropdownItem().find('span').classes(dropdownClass)).toBe(
true, true,
......
...@@ -3,7 +3,11 @@ import Vuex from 'vuex'; ...@@ -3,7 +3,11 @@ import Vuex from 'vuex';
import GeoNodeActions from 'ee/geo_nodes_beta/components/header/geo_node_actions.vue'; import GeoNodeActions from 'ee/geo_nodes_beta/components/header/geo_node_actions.vue';
import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue'; import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue';
import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue'; import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data'; import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -12,7 +16,7 @@ describe('GeoNodeActions', () => { ...@@ -12,7 +16,7 @@ describe('GeoNodeActions', () => {
let wrapper; let wrapper;
const defaultProps = { const defaultProps = {
primary: true, node: MOCK_NODES[0],
}; };
const createComponent = (initialState, props) => { const createComponent = (initialState, props) => {
......
...@@ -140,6 +140,7 @@ export const MOCK_NODES = [ ...@@ -140,6 +140,7 @@ export const MOCK_NODES = [
replicationSlotsUsedCount: 0, replicationSlotsUsedCount: 0,
version: '10.4.0-pre', version: '10.4.0-pre',
revision: 'b93c51849b', revision: 'b93c51849b',
webEditUrl: 'http://127.0.0.1:3001/admin/geo/nodes/1',
}, },
{ {
id: 2, id: 2,
...@@ -209,6 +210,7 @@ export const MOCK_NODE_STATUSES_RES = [ ...@@ -209,6 +210,7 @@ export const MOCK_NODE_STATUSES_RES = [
replication_slots_used_count: 0, replication_slots_used_count: 0,
version: '10.4.0-pre', version: '10.4.0-pre',
revision: 'b93c51849b', revision: 'b93c51849b',
web_edit_url: 'http://127.0.0.1:3001/admin/geo/nodes/1',
}, },
{ {
geo_node_id: 2, geo_node_id: 2,
......
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