Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • albert.khasanov/gitlab-ui
  • SevenOutman/gitlab-ui
  • ClemMakesApps/gitlab-ui
  • gitlab-org/gitlab-ui
  • gtsiolis/gitlab-ui
  • mark.obradley/gitlab-ui
  • piall/gitlab-ui
  • redreamer/gitlab-ui
  • runrog/gitlab-ui
  • yangchigi/gitlab-ui
  • jayalakshmij/gitlab-ui
  • sonqu/gitlab-ui
  • nnelson/gitlab-ui
  • michel.engelen/gitlab-ui
  • bsradcliffe/gitlab-ui
  • petahbyte/gitlab-ui
  • joe.wollard/gitlab-ui
  • jihye.paik/gitlab-ui
  • Kamikadze4GAME/gitlab-ui
  • Gaslan/gitlab-ui
  • inyee786/gitlab-ui
  • abuuzayr/gitlab-ui
  • NativeUser/gitlab-ui
  • _23phy/gitlab-ui
  • v_hladko/gitlab-ui
  • killbotxd/gitlab-ui
  • yeonyu/gitlab-ui
  • mnzone/gitlab-ui
  • ashishgkwd/gitlab-ui
  • Keimeno/gitlab-ui
  • dcouture/gitlab-ui
  • Rory_Chillmore/gitlab-ui
  • misha28x/gitlab-ui
  • shawchandeshwar61/gitlab-ui
  • aszs/gitlab-ui
  • leetickett/gitlab-ui
  • stalker3343/gitlab-ui
  • davepies/gitlab-ui
  • pravi/gitlab-ui
  • ChasLui/gitlab-ui
  • wangko27/gitlab-ui
  • kaangokdemir/gitlab-ui
  • rajiff/gitlab-ui
  • gitlab-org/frontend/playground/gitlab-ui
  • orozot/gitlab-ui
  • gitlab-renovate-forks/gitlab-ui
  • Meghana-12/gitlab-ui
  • tweichart/gitlab-ui
  • leipert/gitlab-ui
  • wenweicui/gitlab-ui
  • mohanraj.geniebeaver/gitlab-ui
  • imrishabh18/gitlab-ui
  • ma-lihui/gitlab-ui
  • piyushsinghania/gitlab-ui
  • NeetuJain/gitlab-ui
  • waridrox/gitlab-ui
  • ankita.singh.200020/gitlab-ui
  • sercan55344/gitlab-ui
  • pangjian/gitlab-ui
  • 2002newhritik/gitlab-ui
  • rachelvfmurphy/gitlab-ui
  • shridharbhat1998/gitlab-ui
  • paulwvnjohi/gitlab-ui
  • edith007/gitlab-ui
  • IgorPahota/gitlab-ui
  • yashmaheshwari/gitlab-ui
  • chiachenglu/gitlab-ui
  • Dhairya3124/gitlab-ui
  • preetidevsang/gitlab-ui
  • revbp/gitlab-ui
  • khout/gitlab-ui
  • Bajjouayoub/gitlab-ui
  • ali_o_kan/gitlab-ui
  • marcel.feldmann/gitlab-ui
  • serenafang/gitlab-ui
  • jamesliu-gitlab/gitlab-ui
  • wallisaleh87/gitlab-ui
  • ALypovyi/gitlab-ui
  • thutterer/gitlab-ui
  • pikepaule/gitlab-ui
  • splattael/gitlab-ui
  • rettalps/gitlab-ui
  • rajdevelopr/gitlab-ui
  • Mohamadhassan98/gitlab-ui
  • dannyelcf/gitlab-ui
  • vchan14/gitlab-ui
  • 23bytes/gitlab-ui
  • dr.shvets/gitlab-ui
  • crystal.alchemist/gitlab-ui
  • chriscordoba1948/gitlab-ui
  • markrian/gitlab-ui
  • zillemarco/gitlab-ui
  • bhatewarak/gitlab-ui
  • hamare-contrib/gitlab-ui
  • agnieszka.gancarczyk/gitlab-ui
  • khulnasoft/khulnasoft-ui
  • abitrolly/gitlab-ui
  • normatov13/gitlab-ui
  • Brwnknight20/gitlab-ui
  • chekerTlili/medmed-front-test
  • Fcogp90/gitlab-ui
  • Harith_training/gitlab-ui
  • rahulpan_altair/gitlab-ui
  • HelloZJW/gitlab-ui
  • fathead32/gitlab-ui
  • akumar1503/gitlab-ui
  • KhaledElkhoreby/gitlab-ui
  • pierrebelloy/gitlab-ui
  • lxwan/gitlab-ui
  • dpalubin/gitlab-ui
  • gitlab-community/gitlab-ui
  • ubaidisaev/gitlab-ui
  • serenafang/gitlab-ui-serena-test
  • hamzasouelmi/gitlab-ui
  • youngbeomshin/gitlab-ui
  • kimseoha1993/gitlab-ui
  • kevin.rojas/gitlab-ui
  • catinbag/gitlab-ui
  • mathieu.pillar/gitlab-ui
  • qk44077907/gitlab-ui
  • fenyuluoshang/gitlab-ui
  • QingJ/gitlab-ui
  • x--/gitlab-ui
  • nraj0408/gitlab-ui
  • victorelmov/gitlab-ui
  • sollo.nic.c.cc/gitlab-ui
  • sksardar42/gitlab-ui
  • nqdev-fork/gitlab-org/gitlab-ui
  • JeremyWuuuuu/gitlab-ui
  • kara006n/gitlab-ui
  • ndt-contribute/gitlab-ui
  • sahadat-sk/gitlab-ui
  • mdwiltfong/gitlab-ui
  • muntazacloud/gitlab-ui
  • drewcauchi/gitlab-ui
  • liummmm/gitlab-ui
  • ale3oula/gitlab-ui
  • kiran-4444/gitlab-ui
  • DUCKDUCKGODEVELOPER/gitlab-ui
  • g32james/gitlab-ui
  • Saeed178/gitlab-ui
  • nickaldwin/gitlab-ui
  • armbiant/gitlab-gui
  • satyamkale27/gitlab-ui
  • jannik_lehmann/gitlab-ui-mono-tinkering
  • zayminkhant/gitlab-ui
  • aytacyaydem/gitlab-ui
  • initdc/gitlab-ui
  • rungruang1/gitlab-ui
  • dormanshylas1/gitlab-ui
  • armbiant/gitlab-ui
  • Piyush-r-bhaskar/gitlab-ui
  • ollevche/gitlab-ui
  • joefoti178/gitlab-ui
  • william.allen1/gitlab-ui
  • anupam42/gitlab-ui
156 results
Show changes
Commits on Source (3)
# [102.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v102.1.6...v102.2.0) (2024-11-14)
### Features
* **DuoChat:** Emit chat-slash event on slash commands opened ([07d8ed6](https://gitlab.com/gitlab-org/gitlab-ui/commit/07d8ed6062ca498bfcf7a2b156dcae6deaf7b08f))
## [102.1.6](https://gitlab.com/gitlab-org/gitlab-ui/compare/v102.1.5...v102.1.6) (2024-11-14)
......
{
"name": "@gitlab/ui",
"version": "102.1.6",
"version": "102.2.0",
"description": "GitLab UI Components",
"license": "MIT",
"main": "dist/index.js",
......
......@@ -1010,12 +1010,20 @@ describe('GlDuoChat', () => {
expect(findSlashCommandsCard().exists()).toBe(false);
});
it('does not render slash commands when prompt is "/"', async () => {
createComponent();
setPromptInput('/');
describe('when prompt is "/"', () => {
beforeEach(async () => {
createComponent();
setPromptInput('/');
await nextTick();
});
await nextTick();
expect(findSlashCommandsCard().exists()).toBe(false);
it('does not render slash', () => {
expect(findSlashCommandsCard().exists()).toBe(false);
});
it('does not emit chat-slash', () => {
expect(wrapper.emitted('chat-slash')).toBeUndefined();
});
});
});
......@@ -1031,24 +1039,6 @@ describe('GlDuoChat', () => {
expect(findSlashCommandsCard().exists()).toBe(false);
});
it('renders all slash commands when prompt is "/"', async () => {
createComponent({
propsData: {
slashCommands,
},
});
setPromptInput('/');
await nextTick();
expect(findSlashCommandsCard().exists()).toBe(true);
expect(findSlashCommands()).toHaveLength(slashCommands.length);
slashCommands.forEach((command, index) => {
expect(findSlashCommands().at(index).text()).toContain(command.name);
expect(findSlashCommands().at(index).text()).toContain(command.description);
});
});
it('prevents passing down invalid slash commands', () => {
expect(() => {
wrapper = shallowMount(GlDuoChat, {
......@@ -1075,20 +1065,28 @@ describe('GlDuoChat', () => {
});
describe('when the prompt includes the "/" character or no characters', () => {
it.each(['', '//', '\\', 'foo', '/foo'])(
'does not render the slash commands if prompt is "$prompt"',
async (prompt) => {
createComponent({
propsData: {
slashCommands,
},
});
setPromptInput(prompt);
beforeEach(() => {
createComponent({
propsData: {
slashCommands,
},
});
});
describe.each(['', '//', '\\', 'foo', '/foo'])('when prompt is "%s"', (prompt) => {
beforeEach(async () => {
setPromptInput(prompt);
await nextTick();
});
it('does not emit a chat-slash event', () => {
expect(wrapper.emitted('chat-slash')).toBeUndefined();
});
it('does not render the slash commands', () => {
expect(findSlashCommandsCard().exists()).toBe(false);
}
);
});
});
});
describe('when prompt presents a partial match to an existing slash command', () => {
......@@ -1125,6 +1123,32 @@ describe('GlDuoChat', () => {
);
});
});
describe('with slash commands and prompt "/"', () => {
beforeEach(async () => {
createComponent({
propsData: {
slashCommands,
},
});
setPromptInput('/');
await nextTick();
});
it('renders all slash commands', () => {
expect(findSlashCommandsCard().exists()).toBe(true);
expect(findSlashCommands()).toHaveLength(slashCommands.length);
slashCommands.forEach((command, index) => {
expect(findSlashCommands().at(index).text()).toContain(command.name);
expect(findSlashCommands().at(index).text()).toContain(command.description);
});
});
it('emits slash event', () => {
expect(wrapper.emitted('chat-slash')).toHaveLength(1);
});
});
});
describe('interaction', () => {
......
......@@ -151,6 +151,9 @@ export const Interactive = (args, { argTypes }) => ({
this.requestId += 1;
this.promptInFlight = false;
},
onChatSlash() {
this.loggerInfo += `Slash command menu opened\n\n`;
},
showChat() {
this.isHidden = false;
this.loggerInfo += `Chat opened\n\n`;
......@@ -278,6 +281,7 @@ export const Interactive = (args, { argTypes }) => ({
@send-chat-prompt="onSendChatPrompt"
@chat-hidden="onChatHidden"
@chat-cancel="onChatCancel"
@chat-slash="onChatSlash"
@insert-code-snippet="onInsertCodeSnippet"
@get-context-item-content="handleGetContextItemContent"
>
......
......@@ -357,6 +357,11 @@ export default {
this.scrollToBottom();
}
},
shouldShowSlashCommands(shouldShow) {
if (shouldShow) {
this.onShowSlashCommands();
}
},
},
created() {
this.handleScrollingTrottled = throttle(this.handleScrolling, 200); // Assume a 200ms throttle for example
......@@ -441,6 +446,12 @@ export default {
*/
this.$emit('track-feedback', event);
},
onShowSlashCommands() {
/**
* Emitted when user opens the slash commands menu
*/
this.$emit('chat-slash');
},
sendChatPromptOnEnter(e) {
const { metaKey, ctrlKey, altKey, shiftKey, isComposing } = e;
const isModifierKey = metaKey || ctrlKey || altKey || shiftKey;
......