Skip to content
代码片段 群组 项目
未验证 提交 8bac3d40 编辑于 作者: David Pisek's avatar David Pisek 提交者: GitLab
浏览文件

Merge branch '435808-add-ai-tooltip-split-button' into 'master'

Add tooltip to resolve with ai split button

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/140198



Merged-by: default avatarDavid Pisek <dpisek@gitlab.com>
Approved-by: default avatarZamir Martins <zfilho@gitlab.com>
Approved-by: default avatarDavid Pisek <dpisek@gitlab.com>
Reviewed-by: default avatarDavid Pisek <dpisek@gitlab.com>
Co-authored-by: default avatarSamantha Ming <sming@gitlab.com>
No related branches found
No related tags found
无相关合并请求
<script> <script>
import { GlButtonGroup, GlButton, GlCollapsibleListbox, GlIcon, GlBadge } from '@gitlab/ui'; import {
GlButtonGroup,
GlButton,
GlCollapsibleListbox,
GlIcon,
GlBadge,
GlTooltipDirective as GlTooltip,
} from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -11,6 +18,9 @@ export default { ...@@ -11,6 +18,9 @@ export default {
GlIcon, GlIcon,
GlBadge, GlBadge,
}, },
directives: {
GlTooltip,
},
props: { props: {
buttons: { buttons: {
type: Array, type: Array,
...@@ -59,7 +69,13 @@ export default { ...@@ -59,7 +69,13 @@ export default {
<!--TODO: Replace button-group workaround once `split` option for new dropdowns is implemented.--> <!--TODO: Replace button-group workaround once `split` option for new dropdowns is implemented.-->
<!-- See issue at https://gitlab.com/gitlab-org/gitlab-ui/-/issues/2263--> <!-- See issue at https://gitlab.com/gitlab-org/gitlab-ui/-/issues/2263-->
<gl-button-group v-if="selectedButton"> <gl-button-group v-if="selectedButton">
<!-- Must set a unique "key" to force re-rendering. -->
<!-- This ensures the tooltip is reset correctly when selectedButton changes. -->
<gl-button <gl-button
:key="selectedButton.name"
v-gl-tooltip
:title="selectedButton.tooltip"
:aria-label="selectedButton.tooltip"
:disabled="disabled" :disabled="disabled"
variant="confirm" variant="confirm"
:href="selectedButton.href" :href="selectedButton.href"
......
import { GlButton, GlButtonGroup, GlCollapsibleListbox, GlListboxItem, GlBadge } from '@gitlab/ui'; import { GlButton, GlButtonGroup, GlCollapsibleListbox, GlListboxItem, GlBadge } from '@gitlab/ui';
import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import SplitButton from 'ee/vue_shared/security_reports/components/split_button.vue'; import SplitButton from 'ee/vue_shared/security_reports/components/split_button.vue';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
...@@ -33,6 +34,9 @@ describe('Split Button', () => { ...@@ -33,6 +34,9 @@ describe('Split Button', () => {
const createComponent = (props, mountFn = shallowMountExtended) => { const createComponent = (props, mountFn = shallowMountExtended) => {
wrapper = mountFn(SplitButton, { wrapper = mountFn(SplitButton, {
directives: {
GlTooltip: createMockDirective('gl-tooltip'),
},
propsData: { propsData: {
...defaultProps, ...defaultProps,
...props, ...props,
...@@ -99,6 +103,19 @@ describe('Split Button', () => { ...@@ -99,6 +103,19 @@ describe('Split Button', () => {
expect(findButtonBadge().text()).toBe(badge); expect(findButtonBadge().text()).toBe(badge);
expect(findButtonBadge().props('size')).toBe('sm'); expect(findButtonBadge().props('size')).toBe('sm');
}); });
it('renders the tooltip', () => {
const tooltipText = 'some tooltip message';
const { buttons } = defaultProps;
createComponent({ buttons: [{ ...buttons[0], tooltip: tooltipText }] }, mountExtended);
const selectedButton = findButton();
const tooltip = getBinding(selectedButton.element, 'gl-tooltip');
expect(tooltip).toBeDefined();
expect(selectedButton.attributes('title')).toBe(tooltipText);
expect(selectedButton.attributes('aria-label')).toBe(tooltipText);
});
}); });
describe('dropdown listbox', () => { describe('dropdown listbox', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册