@gitlab/ui 91.5.0 → 91.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +167 -0
  3. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_category_items.js +69 -0
  4. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +9 -0
  5. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +28 -2
  6. package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +26 -11
  7. package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +17 -0
  8. package/dist/index.css +1 -1
  9. package/dist/index.css.map +1 -1
  10. package/dist/tokens/build/js/tokens.dark.js +1 -1
  11. package/dist/tokens/build/js/tokens.js +1 -1
  12. package/dist/tokens/css/tokens.css +1 -1
  13. package/dist/tokens/css/tokens.dark.css +1 -1
  14. package/dist/tokens/js/tokens.dark.js +1 -1
  15. package/dist/tokens/js/tokens.js +1 -1
  16. package/dist/tokens/json/tokens.dark.json +3 -3
  17. package/dist/tokens/json/tokens.json +3 -3
  18. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  19. package/dist/tokens/scss/_tokens.scss +1 -1
  20. package/package.json +1 -1
  21. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +174 -0
  22. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_category_items.vue +45 -0
  23. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +9 -0
  24. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +28 -1
  25. package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +22 -10
  26. package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +29 -0
  27. package/src/tokens/build/css/tokens.css +1 -1
  28. package/src/tokens/build/css/tokens.dark.css +1 -1
  29. package/src/tokens/build/js/tokens.dark.js +1 -1
  30. package/src/tokens/build/js/tokens.js +1 -1
  31. package/src/tokens/build/json/tokens.dark.json +3 -3
  32. package/src/tokens/build/json/tokens.json +3 -3
  33. package/src/tokens/build/scss/_tokens.dark.scss +1 -1
  34. package/src/tokens/build/scss/_tokens.scss +1 -1
  35. package/src/tokens/control.tokens.json +2 -2
  36. package/translations.js +1 -0
@@ -611,7 +611,7 @@ const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#428fdc'; // Used for the selec
611
611
  const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = 'rgba(05, 05, 06, 0.4)'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  const GL_CONTROL_BACKGROUND_COLOR_DISABLED = 'rgba(255, 255, 255, 0.04)'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = 'rgba(255, 255, 255, 0.04)'; // Used for the background of static content that prepends or appends a text input.
614
- const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#28272d'; // Used for the background of static content that prepends or appends a text input.
614
+ const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(255, 255, 255, 0.08)'; // Used for the background of static content that prepends or appends a text input.
615
615
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#63a6e9'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -611,7 +611,7 @@ const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#1f75cb'; // Used for the selec
611
611
  const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = '#fff'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  const GL_CONTROL_BACKGROUND_COLOR_DISABLED = '#fbfafd'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
- const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
+ const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(05, 05, 06, 0.02)'; // Used for the background of static content that prepends or appends a text input.
615
615
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#1f75cb'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -492,7 +492,7 @@
492
492
  --gl-control-background-color-selected-focus: var(--gl-color-blue-700); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
493
493
  --gl-control-background-color-selected-hover: var(--gl-color-blue-700); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
494
494
  --gl-control-background-color-selected-default: var(--gl-color-blue-500); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background. */
495
- --gl-control-background-color-readonly: var(--gl-color-neutral-10); /* Used for the background of static content that prepends or appends a text input. */
495
+ --gl-control-background-color-readonly: var(--gl-color-alpha-dark-2); /* Used for the background of static content that prepends or appends a text input. */
496
496
  --gl-control-background-color-concatenation: var(--gl-color-neutral-10); /* Used for the background of static content that prepends or appends a text input. */
497
497
  --gl-control-background-color-disabled: var(--gl-color-neutral-10); /* Used for disabled form control (checkbox, input, radio button, textarea) background. */
498
498
  --gl-control-background-color-default: var(--gl-color-neutral-0); /* Used for form control (input, radio button, checkbox, textarea) default background. */
@@ -492,7 +492,7 @@
492
492
  --gl-control-background-color-selected-focus: var(--gl-color-blue-200); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
493
493
  --gl-control-background-color-selected-hover: var(--gl-color-blue-200); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
494
494
  --gl-control-background-color-selected-default: var(--gl-color-blue-300); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background. */
495
- --gl-control-background-color-readonly: var(--gl-color-neutral-900); /* Used for the background of static content that prepends or appends a text input. */
495
+ --gl-control-background-color-readonly: var(--gl-color-alpha-light-8); /* Used for the background of static content that prepends or appends a text input. */
496
496
  --gl-control-background-color-concatenation: var(--gl-color-alpha-light-4); /* Used for the background of static content that prepends or appends a text input. */
497
497
  --gl-control-background-color-disabled: var(--gl-color-alpha-light-4); /* Used for disabled form control (checkbox, input, radio button, textarea) background. */
498
498
  --gl-control-background-color-default: var(--gl-color-alpha-dark-40); /* Used for form control (input, radio button, checkbox, textarea) default background. */
@@ -611,7 +611,7 @@ export const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#428fdc'; // Used for th
611
611
  export const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = 'rgba(05, 05, 06, 0.4)'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  export const GL_CONTROL_BACKGROUND_COLOR_DISABLED = 'rgba(255, 255, 255, 0.04)'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  export const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = 'rgba(255, 255, 255, 0.04)'; // Used for the background of static content that prepends or appends a text input.
614
- export const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#28272d'; // Used for the background of static content that prepends or appends a text input.
614
+ export const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(255, 255, 255, 0.08)'; // Used for the background of static content that prepends or appends a text input.
615
615
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#63a6e9'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -611,7 +611,7 @@ export const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#1f75cb'; // Used for th
611
611
  export const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = '#fff'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  export const GL_CONTROL_BACKGROUND_COLOR_DISABLED = '#fbfafd'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  export const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
- export const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
+ export const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(05, 05, 06, 0.02)'; // Used for the background of static content that prepends or appends a text input.
615
615
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#1f75cb'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -13516,15 +13516,15 @@
13516
13516
  ]
13517
13517
  },
13518
13518
  "readonly": {
13519
- "value": "#28272d",
13519
+ "value": "rgba(255, 255, 255, 0.08)",
13520
13520
  "$type": "color",
13521
13521
  "comment": "Used for the background of static content that prepends or appends a text input.",
13522
13522
  "filePath": "src/tokens/control.tokens.json",
13523
13523
  "isSource": true,
13524
13524
  "original": {
13525
13525
  "value": {
13526
- "default": "{color.neutral.10}",
13527
- "dark": "{color.neutral.900}"
13526
+ "default": "{color.alpha.dark.2}",
13527
+ "dark": "{color.alpha.light.8}"
13528
13528
  },
13529
13529
  "$type": "color",
13530
13530
  "comment": "Used for the background of static content that prepends or appends a text input."
@@ -13516,15 +13516,15 @@
13516
13516
  ]
13517
13517
  },
13518
13518
  "readonly": {
13519
- "value": "#fbfafd",
13519
+ "value": "rgba(05, 05, 06, 0.02)",
13520
13520
  "$type": "color",
13521
13521
  "comment": "Used for the background of static content that prepends or appends a text input.",
13522
13522
  "filePath": "src/tokens/control.tokens.json",
13523
13523
  "isSource": true,
13524
13524
  "original": {
13525
13525
  "value": {
13526
- "default": "{color.neutral.10}",
13527
- "dark": "{color.neutral.900}"
13526
+ "default": "{color.alpha.dark.2}",
13527
+ "dark": "{color.alpha.light.8}"
13528
13528
  },
13529
13529
  "$type": "color",
13530
13530
  "comment": "Used for the background of static content that prepends or appends a text input."
@@ -490,7 +490,7 @@ $gl-control-border-color-default: $gl-color-neutral-500; // Used for form contro
490
490
  $gl-control-background-color-selected-focus: $gl-color-blue-200; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
491
491
  $gl-control-background-color-selected-hover: $gl-color-blue-200; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
492
492
  $gl-control-background-color-selected-default: $gl-color-blue-300; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
493
- $gl-control-background-color-readonly: $gl-color-neutral-900; // Used for the background of static content that prepends or appends a text input.
493
+ $gl-control-background-color-readonly: $gl-color-alpha-light-8; // Used for the background of static content that prepends or appends a text input.
494
494
  $gl-control-background-color-concatenation: $gl-color-alpha-light-4; // Used for the background of static content that prepends or appends a text input.
495
495
  $gl-control-background-color-disabled: $gl-color-alpha-light-4; // Used for disabled form control (checkbox, input, radio button, textarea) background.
496
496
  $gl-control-background-color-default: $gl-color-alpha-dark-40; // Used for form control (input, radio button, checkbox, textarea) default background.
@@ -490,7 +490,7 @@ $gl-control-border-color-default: $gl-color-neutral-400; // Used for form contro
490
490
  $gl-control-background-color-selected-focus: $gl-color-blue-700; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
491
491
  $gl-control-background-color-selected-hover: $gl-color-blue-700; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
492
492
  $gl-control-background-color-selected-default: $gl-color-blue-500; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
493
- $gl-control-background-color-readonly: $gl-color-neutral-10; // Used for the background of static content that prepends or appends a text input.
493
+ $gl-control-background-color-readonly: $gl-color-alpha-dark-2; // Used for the background of static content that prepends or appends a text input.
494
494
  $gl-control-background-color-concatenation: $gl-color-neutral-10; // Used for the background of static content that prepends or appends a text input.
495
495
  $gl-control-background-color-disabled: $gl-color-neutral-10; // Used for disabled form control (checkbox, input, radio button, textarea) background.
496
496
  $gl-control-background-color-default: $gl-color-neutral-0; // Used for form control (input, radio button, checkbox, textarea) default background.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "91.5.0",
3
+ "version": "91.7.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,174 @@
1
+ <script>
2
+ import { translate } from '../../../../../../../utils/i18n';
3
+ import GlCard from '../../../../../../base/card/card.vue';
4
+ import { categoriesValidator, contextItemsValidator } from '../utils';
5
+ import GlDuoChatContextItemSelections from '../duo_chat_context_item_selections/duo_chat_context_item_selections.vue';
6
+ import GlDuoChatContextItemMenuCategoryItems from './duo_chat_context_item_menu_category_items.vue';
7
+
8
+ export default {
9
+ name: 'GlDuoChatContextItemMenu',
10
+ components: {
11
+ GlCard,
12
+ GlDuoChatContextItemMenuCategoryItems,
13
+ GlDuoChatContextItemSelections,
14
+ },
15
+ props: {
16
+ /**
17
+ * Whether the menu is open.
18
+ */
19
+ open: {
20
+ type: Boolean,
21
+ required: true,
22
+ },
23
+ /**
24
+ * Array of selected context items.
25
+ */
26
+ selections: {
27
+ type: Array,
28
+ required: true,
29
+ validator: contextItemsValidator,
30
+ },
31
+ /**
32
+ * Whether the menu is in a loading state.
33
+ */
34
+ loading: {
35
+ type: Boolean,
36
+ required: true,
37
+ },
38
+ /**
39
+ * Error message to display, if any.
40
+ */
41
+ error: {
42
+ type: [String, null],
43
+ required: false,
44
+ default: null,
45
+ },
46
+ /**
47
+ * Array of available categories for context items.
48
+ */
49
+ categories: {
50
+ type: Array,
51
+ required: true,
52
+ validator: categoriesValidator,
53
+ },
54
+ /**
55
+ * Array of search results for context items.
56
+ */
57
+ results: {
58
+ type: Array,
59
+ required: true,
60
+ validator: contextItemsValidator,
61
+ },
62
+ },
63
+ data() {
64
+ return {
65
+ activeIndex: 0,
66
+ selectedCategory: null,
67
+ };
68
+ },
69
+ computed: {
70
+ showCategorySelection() {
71
+ return this.open && !this.selectedCategory;
72
+ },
73
+ },
74
+ watch: {
75
+ open(isOpen) {
76
+ if (!isOpen) {
77
+ this.resetSelection();
78
+ }
79
+ },
80
+ },
81
+ methods: {
82
+ selectCategory(category) {
83
+ this.selectedCategory = category;
84
+ this.activeIndex = 0;
85
+
86
+ /**
87
+ * Emitted when a search should be performed.
88
+ * @property {Object} filter
89
+ * @property {string} filter.category - The value of the selected category
90
+ * @property {string} filter.query - The search query
91
+ */
92
+ this.$emit('search', {
93
+ category: category.value,
94
+ query: '',
95
+ });
96
+ },
97
+ selectItem(item) {
98
+ if (!item.isEnabled) {
99
+ return;
100
+ }
101
+
102
+ /**
103
+ * Emitted when a context item is selected.
104
+ * @property {Object} item - The selected context item
105
+ */
106
+ this.$emit(
107
+ 'select',
108
+ this.results.find((result) => result.id === item.id)
109
+ );
110
+
111
+ /**
112
+ * Emitted when the menu should be closed.
113
+ */
114
+ this.$emit('close');
115
+ this.resetSelection();
116
+ },
117
+ removeItem(item) {
118
+ /**
119
+ * Emitted when a context item should be removed.
120
+ * @property {Object} item - The context item to be removed
121
+ */
122
+ this.$emit('remove', item);
123
+ },
124
+ resetSelection() {
125
+ this.selectedCategory = null;
126
+ this.activeIndex = 0;
127
+ },
128
+ },
129
+ i18n: {
130
+ selectedContextItemsTitle: translate(
131
+ 'GlDuoChatContextItemMenu.selectedContextItemsTitle',
132
+ 'Included references'
133
+ ),
134
+ },
135
+ };
136
+ </script>
137
+
138
+ <template>
139
+ <div>
140
+ <gl-duo-chat-context-item-selections
141
+ v-if="selections.length"
142
+ :selections="selections"
143
+ :removable="true"
144
+ :title="$options.i18n.selectedContextItemsTitle"
145
+ :default-collapsed="false"
146
+ class="gl-mb-3"
147
+ @remove="removeItem"
148
+ />
149
+ <gl-card
150
+ v-if="open"
151
+ class="slash-commands !gl-absolute gl-bottom-0 gl-w-full gl-pl-0 gl-shadow-md"
152
+ body-class="!gl-p-2"
153
+ data-testid="context-item-menu"
154
+ >
155
+ <gl-duo-chat-context-item-menu-category-items
156
+ v-if="showCategorySelection"
157
+ :active-index="activeIndex"
158
+ :categories="categories"
159
+ @select="selectCategory"
160
+ @active-index-change="activeIndex = $event"
161
+ />
162
+ <div v-else data-testid="context-menu-search-items">
163
+ <!-- Placeholder for GlDuoChatContextItemMenuSearchItem component coming in a future iteration -->
164
+ <template v-if="loading">Loading...</template>
165
+ <template v-else-if="error">Error: {{ error }}</template>
166
+ <ul v-else>
167
+ <li v-for="result of results" :key="result.id" @click="selectItem(result)">
168
+ {{ result.metadata.name }} {{ result.isEnabled ? '' : '(disabled)' }}
169
+ </li>
170
+ </ul>
171
+ </div>
172
+ </gl-card>
173
+ </div>
174
+ </template>
@@ -0,0 +1,45 @@
1
+ <script>
2
+ import GlDropdownItem from '../../../../../../base/dropdown/dropdown_item.vue';
3
+ import GlIcon from '../../../../../../base/icon/icon.vue';
4
+ import { categoriesValidator } from '../utils';
5
+
6
+ export default {
7
+ name: 'GlDuoChatContextItemMenuCategoryItems',
8
+ components: { GlIcon, GlDropdownItem },
9
+ props: {
10
+ categories: {
11
+ type: Array,
12
+ required: true,
13
+ validator: categoriesValidator,
14
+ },
15
+ activeIndex: {
16
+ type: Number,
17
+ required: true,
18
+ },
19
+ },
20
+ methods: {
21
+ selectCategory(category) {
22
+ this.$emit('select', category);
23
+ },
24
+ setActiveIndex(index) {
25
+ this.$emit('active-index-change', index);
26
+ },
27
+ },
28
+ };
29
+ </script>
30
+ <template>
31
+ <ul class="gl-mb-0 gl-list-none gl-pl-0">
32
+ <gl-dropdown-item
33
+ v-for="(category, index) in categories"
34
+ :key="category.value"
35
+ :class="{ 'active-command': index === activeIndex }"
36
+ data-testid="category-item"
37
+ @click="selectCategory(category)"
38
+ >
39
+ <div class="gl-flex gl-items-center" @mouseenter="setActiveIndex(index)">
40
+ <gl-icon :name="category.icon" class="gl-mr-2" />
41
+ {{ category.label }}
42
+ </div>
43
+ </gl-dropdown-item>
44
+ </ul>
45
+ </template>
@@ -18,14 +18,23 @@ export default {
18
18
  GlPopover,
19
19
  },
20
20
  props: {
21
+ /**
22
+ * The context item to display in the popover.
23
+ */
21
24
  item: {
22
25
  type: Object,
23
26
  required: true,
24
27
  },
28
+ /**
29
+ * The target element ID for the popover.
30
+ */
25
31
  target: {
26
32
  type: String,
27
33
  required: true,
28
34
  },
35
+ /**
36
+ * The placement of the popover relative to the target.
37
+ */
29
38
  placement: {
30
39
  type: String,
31
40
  default: 'bottom',
@@ -8,6 +8,7 @@ import {
8
8
  CONTEXT_ITEM_TYPE_MERGE_REQUEST,
9
9
  CONTEXT_ITEM_TYPE_PROJECT_FILE,
10
10
  } from '../constants';
11
+ import { contextItemsValidator } from '../utils';
11
12
 
12
13
  export default {
13
14
  name: 'GlDuoChatContextItemSelections',
@@ -17,18 +18,36 @@ export default {
17
18
  GlToken,
18
19
  },
19
20
  props: {
21
+ /**
22
+ * Array of selected context items.
23
+ */
20
24
  selections: {
21
25
  type: Array,
22
26
  required: true,
27
+ validator: contextItemsValidator,
23
28
  },
29
+ /**
30
+ * The title to display for the selections.
31
+ */
24
32
  title: {
25
33
  type: String,
26
34
  required: true,
27
35
  },
36
+ /**
37
+ * Whether the selections should be collapsed by default.
38
+ */
28
39
  defaultCollapsed: {
29
40
  type: Boolean,
30
41
  required: true,
31
42
  },
43
+ /**
44
+ * Whether the selections can be removed.
45
+ */
46
+ removable: {
47
+ type: Boolean,
48
+ required: false,
49
+ default: false,
50
+ },
32
51
  },
33
52
  data() {
34
53
  return {
@@ -53,6 +72,13 @@ export default {
53
72
  toggleCollapse() {
54
73
  this.isCollapsed = !this.isCollapsed;
55
74
  },
75
+ onRemoveItem(item) {
76
+ /**
77
+ * Emitted when a context item should be removed.
78
+ * @property {Object} item - The context item to be removed
79
+ */
80
+ this.$emit('remove', item);
81
+ },
56
82
  },
57
83
  };
58
84
  </script>
@@ -75,9 +101,10 @@ export default {
75
101
  <gl-token
76
102
  v-for="item in selections"
77
103
  :key="item.id"
78
- :view-only="true"
104
+ :view-only="!removable"
79
105
  variant="default"
80
106
  class="gl-mb-2 gl-mr-2"
107
+ @close="onRemoveItem(item)"
81
108
  >
82
109
  <div :id="`context-item-${item.id}-${selectionsId}`" class="gl-flex gl-items-center">
83
110
  <gl-icon :name="getIconName(item.type)" :size="12" class="gl-mr-1" />
@@ -1,3 +1,15 @@
1
+ import {
2
+ CONTEXT_ITEM_TYPE_ISSUE,
3
+ CONTEXT_ITEM_TYPE_MERGE_REQUEST,
4
+ CONTEXT_ITEM_TYPE_PROJECT_FILE,
5
+ } from './constants';
6
+
7
+ export const MOCK_CATEGORIES = [
8
+ { label: 'Files', value: CONTEXT_ITEM_TYPE_PROJECT_FILE, icon: 'document' },
9
+ { label: 'Issues', value: CONTEXT_ITEM_TYPE_ISSUE, icon: 'issues' },
10
+ { label: 'Merge Requests', value: CONTEXT_ITEM_TYPE_MERGE_REQUEST, icon: 'merge-request' },
11
+ ];
12
+
1
13
  export const MOCK_CONTEXT_ITEM_FILE = {
2
14
  id: '123e4567-e89b-12d3-a456-426614174000',
3
15
  isEnabled: true,
@@ -8,7 +20,7 @@ export const MOCK_CONTEXT_ITEM_FILE = {
8
20
  relFilePath: 'src/plants/strawberry.ts',
9
21
  },
10
22
  },
11
- type: 'project_file',
23
+ type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
12
24
  };
13
25
 
14
26
  export const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
@@ -21,7 +33,7 @@ export const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
21
33
  relFilePath: '/src/VehicleFoo/motorbike.cs',
22
34
  },
23
35
  },
24
- type: 'project_file',
36
+ type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
25
37
  };
26
38
  const mockFiles = [
27
39
  MOCK_CONTEXT_ITEM_FILE,
@@ -35,7 +47,7 @@ const mockFiles = [
35
47
  relFilePath: '/src/plants/potato.ts',
36
48
  },
37
49
  },
38
- type: 'project_file',
50
+ type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
39
51
  },
40
52
  MOCK_CONTEXT_ITEM_FILE_DISABLED,
41
53
  ];
@@ -50,20 +62,20 @@ export const MOCK_CONTEXT_ITEM_ISSUE = {
50
62
  iid: 1234,
51
63
  },
52
64
  },
53
- type: 'issue',
65
+ type: CONTEXT_ITEM_TYPE_ISSUE,
54
66
  };
55
67
  export const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
56
68
  id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
57
69
  isEnabled: false,
58
70
  metadata: {
59
- name: 'Fix vehicle colours',
71
+ name: `Fix vehicle colours and make them look real nice and colourful won't that be wonderful wow this issue title is really long I sure hope it's gonna wrap OK`,
60
72
  info: {
61
73
  project: 'example/vehicle',
62
74
  iid: 91011,
63
75
  },
64
76
  },
65
77
  disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
66
- type: 'issue',
78
+ type: CONTEXT_ITEM_TYPE_ISSUE,
67
79
  };
68
80
 
69
81
  const mockIssues = [
@@ -78,7 +90,7 @@ const mockIssues = [
78
90
  iid: 5678,
79
91
  },
80
92
  },
81
- type: 'issue',
93
+ type: CONTEXT_ITEM_TYPE_ISSUE,
82
94
  },
83
95
  MOCK_CONTEXT_ITEM_ISSUE_DISABLED,
84
96
  ];
@@ -93,7 +105,7 @@ export const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
93
105
  iid: 1122,
94
106
  },
95
107
  },
96
- type: 'merge_request',
108
+ type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
97
109
  };
98
110
  export const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
99
111
  id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
@@ -106,7 +118,7 @@ export const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
106
118
  },
107
119
  },
108
120
  disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
109
- type: 'merge_request',
121
+ type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
110
122
  };
111
123
 
112
124
  const mockMergeRequests = [
@@ -122,7 +134,7 @@ const mockMergeRequests = [
122
134
  },
123
135
  },
124
136
  disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
125
- type: 'merge_request',
137
+ type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
126
138
  },
127
139
  MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED,
128
140
  ];
@@ -0,0 +1,29 @@
1
+ function categoryValidator(category) {
2
+ return Boolean(category && category.value && category.label && category.icon);
3
+ }
4
+
5
+ export function categoriesValidator(categories) {
6
+ return Array.isArray(categories) && categories.every((category) => categoryValidator(category));
7
+ }
8
+
9
+ function disabledReasonsValidator(disabledReasons) {
10
+ return (
11
+ disabledReasons === undefined ||
12
+ (Array.isArray(disabledReasons) &&
13
+ disabledReasons.every((reason) => typeof reason === 'string'))
14
+ );
15
+ }
16
+
17
+ function contextItemValidator(item) {
18
+ return Boolean(
19
+ item &&
20
+ item.id &&
21
+ item.type &&
22
+ typeof item.isEnabled === 'boolean' &&
23
+ disabledReasonsValidator(item.disabledReasons)
24
+ );
25
+ }
26
+
27
+ export function contextItemsValidator(items) {
28
+ return Array.isArray(items) && items.every((item) => contextItemValidator(item));
29
+ }
@@ -492,7 +492,7 @@
492
492
  --gl-control-background-color-selected-focus: var(--gl-color-blue-700); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
493
493
  --gl-control-background-color-selected-hover: var(--gl-color-blue-700); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
494
494
  --gl-control-background-color-selected-default: var(--gl-color-blue-500); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background. */
495
- --gl-control-background-color-readonly: var(--gl-color-neutral-10); /* Used for the background of static content that prepends or appends a text input. */
495
+ --gl-control-background-color-readonly: var(--gl-color-alpha-dark-2); /* Used for the background of static content that prepends or appends a text input. */
496
496
  --gl-control-background-color-concatenation: var(--gl-color-neutral-10); /* Used for the background of static content that prepends or appends a text input. */
497
497
  --gl-control-background-color-disabled: var(--gl-color-neutral-10); /* Used for disabled form control (checkbox, input, radio button, textarea) background. */
498
498
  --gl-control-background-color-default: var(--gl-color-neutral-0); /* Used for form control (input, radio button, checkbox, textarea) default background. */
@@ -492,7 +492,7 @@
492
492
  --gl-control-background-color-selected-focus: var(--gl-color-blue-200); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
493
493
  --gl-control-background-color-selected-hover: var(--gl-color-blue-200); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover. */
494
494
  --gl-control-background-color-selected-default: var(--gl-color-blue-300); /* Used for checked and indeterminate (selected) form control (checkbox, radio button) background. */
495
- --gl-control-background-color-readonly: var(--gl-color-neutral-900); /* Used for the background of static content that prepends or appends a text input. */
495
+ --gl-control-background-color-readonly: var(--gl-color-alpha-light-8); /* Used for the background of static content that prepends or appends a text input. */
496
496
  --gl-control-background-color-concatenation: var(--gl-color-alpha-light-4); /* Used for the background of static content that prepends or appends a text input. */
497
497
  --gl-control-background-color-disabled: var(--gl-color-alpha-light-4); /* Used for disabled form control (checkbox, input, radio button, textarea) background. */
498
498
  --gl-control-background-color-default: var(--gl-color-alpha-dark-40); /* Used for form control (input, radio button, checkbox, textarea) default background. */
@@ -611,7 +611,7 @@ export const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#428fdc'; // Used for th
611
611
  export const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = 'rgba(05, 05, 06, 0.4)'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  export const GL_CONTROL_BACKGROUND_COLOR_DISABLED = 'rgba(255, 255, 255, 0.04)'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  export const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = 'rgba(255, 255, 255, 0.04)'; // Used for the background of static content that prepends or appends a text input.
614
- export const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#28272d'; // Used for the background of static content that prepends or appends a text input.
614
+ export const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(255, 255, 255, 0.08)'; // Used for the background of static content that prepends or appends a text input.
615
615
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#63a6e9'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#9dc7f1'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -611,7 +611,7 @@ export const GL_TAB_SELECTED_INDICATOR_COLOR_DEFAULT = '#1f75cb'; // Used for th
611
611
  export const GL_CONTROL_BACKGROUND_COLOR_DEFAULT = '#fff'; // Used for form control (input, radio button, checkbox, textarea) default background.
612
612
  export const GL_CONTROL_BACKGROUND_COLOR_DISABLED = '#fbfafd'; // Used for disabled form control (checkbox, input, radio button, textarea) background.
613
613
  export const GL_CONTROL_BACKGROUND_COLOR_CONCATENATION = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
- export const GL_CONTROL_BACKGROUND_COLOR_READONLY = '#fbfafd'; // Used for the background of static content that prepends or appends a text input.
614
+ export const GL_CONTROL_BACKGROUND_COLOR_READONLY = 'rgba(05, 05, 06, 0.02)'; // Used for the background of static content that prepends or appends a text input.
615
615
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_DEFAULT = '#1f75cb'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background.
616
616
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_HOVER = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
617
617
  export const GL_CONTROL_BACKGROUND_COLOR_SELECTED_FOCUS = '#0b5cad'; // Used for checked and indeterminate (selected) form control (checkbox, radio button) background on hover.
@@ -13516,15 +13516,15 @@
13516
13516
  ]
13517
13517
  },
13518
13518
  "readonly": {
13519
- "value": "#28272d",
13519
+ "value": "rgba(255, 255, 255, 0.08)",
13520
13520
  "$type": "color",
13521
13521
  "comment": "Used for the background of static content that prepends or appends a text input.",
13522
13522
  "filePath": "src/tokens/control.tokens.json",
13523
13523
  "isSource": true,
13524
13524
  "original": {
13525
13525
  "value": {
13526
- "default": "{color.neutral.10}",
13527
- "dark": "{color.neutral.900}"
13526
+ "default": "{color.alpha.dark.2}",
13527
+ "dark": "{color.alpha.light.8}"
13528
13528
  },
13529
13529
  "$type": "color",
13530
13530
  "comment": "Used for the background of static content that prepends or appends a text input."