Commit b9338d5c authored by Frédéric Caplette's avatar Frédéric Caplette

Merge branch '327124-runner-installation-modal-should-support-smaller-screens' into 'master'

Adjust runner instructions modal in small screens

See merge request gitlab-org/gitlab!60588
parents 9ac62f19 37634ab0
...@@ -9,7 +9,9 @@ import { ...@@ -9,7 +9,9 @@ import {
GlIcon, GlIcon,
GlLoadingIcon, GlLoadingIcon,
GlSkeletonLoader, GlSkeletonLoader,
GlResizeObserverDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue'; import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
...@@ -33,6 +35,9 @@ export default { ...@@ -33,6 +35,9 @@ export default {
GlSkeletonLoader, GlSkeletonLoader,
ModalCopyButton, ModalCopyButton,
}, },
directives: {
GlResizeObserver: GlResizeObserverDirective,
},
props: { props: {
modalId: { modalId: {
type: String, type: String,
...@@ -87,6 +92,7 @@ export default { ...@@ -87,6 +92,7 @@ export default {
selectedArchitecture: null, selectedArchitecture: null,
showAlert: false, showAlert: false,
instructions: {}, instructions: {},
platformsButtonGroupVertical: false,
}; };
}, },
computed: { computed: {
...@@ -127,6 +133,13 @@ export default { ...@@ -127,6 +133,13 @@ export default {
toggleAlert(state) { toggleAlert(state) {
this.showAlert = state; this.showAlert = state;
}, },
onPlatformsButtonResize() {
if (bp.getBreakpointSize() === 'xs') {
this.platformsButtonGroupVertical = true;
} else {
this.platformsButtonGroupVertical = false;
}
},
}, },
i18n: { i18n: {
installARunner: s__('Runners|Install a runner'), installARunner: s__('Runners|Install a runner'),
...@@ -159,17 +172,23 @@ export default { ...@@ -159,17 +172,23 @@ export default {
<h5> <h5>
{{ __('Environment') }} {{ __('Environment') }}
</h5> </h5>
<gl-button-group class="gl-mb-3"> <div v-gl-resize-observer="onPlatformsButtonResize">
<gl-button <gl-button-group
v-for="platform in platforms" :vertical="platformsButtonGroupVertical"
:key="platform.name" :class="{ 'gl-w-full': platformsButtonGroupVertical }"
:selected="selectedPlatform && selectedPlatform.name === platform.name" class="gl-mb-3"
data-testid="platform-button" data-testid="platform-buttons"
@click="selectPlatform(platform)"
> >
{{ platform.humanReadableName }} <gl-button
</gl-button> v-for="platform in platforms"
</gl-button-group> :key="platform.name"
:selected="selectedPlatform && selectedPlatform.name === platform.name"
@click="selectPlatform(platform)"
>
{{ platform.humanReadableName }}
</gl-button>
</gl-button-group>
</div>
</template> </template>
<template v-if="hasArchitecureList"> <template v-if="hasArchitecureList">
<template v-if="selectedPlatform"> <template v-if="selectedPlatform">
...@@ -190,7 +209,7 @@ export default { ...@@ -190,7 +209,7 @@ export default {
{{ architecture.name }} {{ architecture.name }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
<div class="gl-display-flex gl-align-items-center gl-mb-3"> <div class="gl-sm-display-flex gl-align-items-center gl-mb-3">
<h5>{{ $options.i18n.downloadInstallBinary }}</h5> <h5>{{ $options.i18n.downloadInstallBinary }}</h5>
<gl-button <gl-button
class="gl-ml-auto" class="gl-ml-auto"
......
---
title: This change captures resizes of the runner installation instructions modal
to make it usable on screens.
merge_request: 60588
author:
type: changed
import { GlAlert, GlLoadingIcon, GlSkeletonLoader } from '@gitlab/ui'; import { GlAlert, GlButton, GlLoadingIcon, GlSkeletonLoader } from '@gitlab/ui';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
...@@ -18,6 +19,24 @@ import { ...@@ -18,6 +19,24 @@ import {
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
let resizeCallback;
const MockResizeObserver = {
bind(el, { value }) {
resizeCallback = value;
},
mockResize(size) {
bp.getBreakpointSize.mockReturnValue(size);
resizeCallback();
},
unbind() {
resizeCallback = null;
},
};
localVue.directive('gl-resize-observer', MockResizeObserver);
jest.mock('@gitlab/ui/dist/utils');
describe('RunnerInstructionsModal component', () => { describe('RunnerInstructionsModal component', () => {
let wrapper; let wrapper;
let fakeApollo; let fakeApollo;
...@@ -27,7 +46,8 @@ describe('RunnerInstructionsModal component', () => { ...@@ -27,7 +46,8 @@ describe('RunnerInstructionsModal component', () => {
const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader);
const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findAlert = () => wrapper.findComponent(GlAlert); const findAlert = () => wrapper.findComponent(GlAlert);
const findPlatformButtons = () => wrapper.findAllByTestId('platform-button'); const findPlatformButtonGroup = () => wrapper.findByTestId('platform-buttons');
const findPlatformButtons = () => findPlatformButtonGroup().findAllComponents(GlButton);
const findArchitectureDropdownItems = () => wrapper.findAllByTestId('architecture-dropdown-item'); const findArchitectureDropdownItems = () => wrapper.findAllByTestId('architecture-dropdown-item');
const findBinaryInstructions = () => wrapper.findByTestId('binary-instructions'); const findBinaryInstructions = () => wrapper.findByTestId('binary-instructions');
const findRegisterCommand = () => wrapper.findByTestId('register-command'); const findRegisterCommand = () => wrapper.findByTestId('register-command');
...@@ -141,6 +161,22 @@ describe('RunnerInstructionsModal component', () => { ...@@ -141,6 +161,22 @@ describe('RunnerInstructionsModal component', () => {
}); });
}); });
describe('when the modal resizes', () => {
it('to an xs viewport', async () => {
MockResizeObserver.mockResize('xs');
await nextTick();
expect(findPlatformButtonGroup().attributes('vertical')).toBeTruthy();
});
it('to a non-xs viewport', async () => {
MockResizeObserver.mockResize('sm');
await nextTick();
expect(findPlatformButtonGroup().props('vertical')).toBeFalsy();
});
});
describe('when apollo is loading', () => { describe('when apollo is loading', () => {
it('should show a skeleton loader', async () => { it('should show a skeleton loader', async () => {
createComponent(); createComponent();
......
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