fix(editor): Revert remove tooltip from info tip (no-changelog) (#10771)

This commit is contained in:
Tomi Turtiainen 2024-09-11 16:09:15 +03:00 committed by GitHub
parent a1e011dd2a
commit 99ba710642
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 57 additions and 3 deletions

View file

@ -132,6 +132,10 @@ describe('NDV', () => {
'contains.text', 'contains.text',
"An expression here won't work because it uses .item and n8n can't figure out the matching item.", "An expression here won't work because it uses .item and n8n can't figure out the matching item.",
); );
ndv.getters.nodeRunErrorIndicator().should('be.visible');
// The error details should be hidden behind a tooltip
ndv.getters.nodeRunErrorIndicator().should('not.contain', 'Start Time');
ndv.getters.nodeRunErrorIndicator().should('not.contain', 'Execution Time');
}); });
it('should save workflow using keyboard shortcut from NDV', () => { it('should save workflow using keyboard shortcut from NDV', () => {

View file

@ -17,3 +17,9 @@ const Template: StoryFn = (args, { argTypes }) => ({
}); });
export const Note = Template.bind({}); export const Note = Template.bind({});
export const Tooltip = Template.bind({});
Tooltip.args = {
type: 'tooltip',
tooltipPlacement: 'right',
};

View file

@ -2,11 +2,14 @@
import { computed } from 'vue'; import { computed } from 'vue';
import type { Placement } from 'element-plus'; import type { Placement } from 'element-plus';
import N8nIcon from '../N8nIcon'; import N8nIcon from '../N8nIcon';
import N8nTooltip from '../N8nTooltip';
const THEME = ['info', 'info-light', 'warning', 'danger', 'success'] as const; const THEME = ['info', 'info-light', 'warning', 'danger', 'success'] as const;
const TYPE = ['note', 'tooltip'] as const;
interface InfoTipProps { interface InfoTipProps {
theme?: (typeof THEME)[number]; theme?: (typeof THEME)[number];
type?: (typeof TYPE)[number];
bold?: boolean; bold?: boolean;
tooltipPlacement?: Placement; tooltipPlacement?: Placement;
} }
@ -14,6 +17,7 @@ interface InfoTipProps {
defineOptions({ name: 'N8nInfoTip' }); defineOptions({ name: 'N8nInfoTip' });
const props = withDefaults(defineProps<InfoTipProps>(), { const props = withDefaults(defineProps<InfoTipProps>(), {
theme: 'info', theme: 'info',
type: 'note',
bold: true, bold: true,
tooltipPlacement: 'top', tooltipPlacement: 'top',
}); });
@ -58,13 +62,28 @@ const iconData = computed((): { icon: string; color: string } => {
<div <div
:class="{ :class="{
'n8n-info-tip': true, 'n8n-info-tip': true,
[$style.note]: true,
[$style.infoTip]: true, [$style.infoTip]: true,
[$style[theme]]: true, [$style[theme]]: true,
[$style[type]]: true,
[$style.bold]: bold, [$style.bold]: bold,
}" }"
> >
<span :class="$style.iconText"> <N8nTooltip
v-if="type === 'tooltip'"
:placement="tooltipPlacement"
:popper-class="$style.tooltipPopper"
:disabled="type !== 'tooltip'"
>
<span :class="$style.iconText" :style="{ color: iconData.color }">
<N8nIcon :icon="iconData.icon" />
</span>
<template #content>
<span>
<slot />
</span>
</template>
</N8nTooltip>
<span v-else :class="$style.iconText">
<N8nIcon :icon="iconData.icon" /> <N8nIcon :icon="iconData.icon" />
<span> <span>
<slot /> <slot />
@ -102,6 +121,11 @@ const iconData = computed((): { icon: string; color: string } => {
} }
} }
.tooltipPopper {
composes: base;
display: inline-flex;
}
.iconText { .iconText {
display: inline-flex; display: inline-flex;
align-items: flex-start; align-items: flex-start;

View file

@ -16,4 +16,17 @@ describe('N8nInfoTip', () => {
}); });
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });
it('should render correctly as tooltip', () => {
const wrapper = render(N8nInfoTip, {
slots,
props: {
type: 'tooltip',
},
global: {
stubs,
},
});
expect(wrapper.html()).toMatchSnapshot();
});
}); });

View file

@ -1,3 +1,10 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`N8nInfoTip > should render correctly as note 1`] = `"<div class="n8n-info-tip note infoTip info bold"><span class="iconText"><span class="n8n-text compact size-medium regular n8n-icon n8n-icon"><!----></span><span>Need help doing something?<a href="/docs" target="_blank">Open docs</a></span></span></div>"`; exports[`N8nInfoTip > should render correctly as note 1`] = `"<div class="n8n-info-tip infoTip info note bold"><span class="iconText"><span class="n8n-text compact size-medium regular n8n-icon n8n-icon"><!----></span><span>Need help doing something?<a href="/docs" target="_blank">Open docs</a></span></span></div>"`;
exports[`N8nInfoTip > should render correctly as tooltip 1`] = `
"<div class="n8n-info-tip infoTip info tooltip bold"><span class="iconText el-tooltip__trigger el-tooltip__trigger"><span class="n8n-text compact size-medium regular n8n-icon n8n-icon"><!----></span></span>
<!--teleport start-->
<!--teleport end-->
</div>"
`;