@gitlab/ui 91.4.0 → 91.6.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 (27) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +162 -0
  3. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +9 -0
  4. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +28 -2
  5. package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +26 -11
  6. package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +17 -0
  7. package/dist/index.css +1 -1
  8. package/dist/index.css.map +1 -1
  9. package/dist/tokens/build/js/tokens.dark.js +5 -5
  10. package/dist/tokens/css/tokens.dark.css +5 -5
  11. package/dist/tokens/js/tokens.dark.js +5 -5
  12. package/dist/tokens/json/tokens.dark.json +10 -25
  13. package/dist/tokens/json/tokens.json +5 -20
  14. package/dist/tokens/scss/_tokens.dark.scss +5 -5
  15. package/package.json +3 -3
  16. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +168 -0
  17. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +9 -0
  18. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +28 -1
  19. package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +22 -10
  20. package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +29 -0
  21. package/src/tokens/build/css/tokens.dark.css +5 -5
  22. package/src/tokens/build/js/tokens.dark.js +5 -5
  23. package/src/tokens/build/json/tokens.dark.json +10 -25
  24. package/src/tokens/build/json/tokens.json +5 -20
  25. package/src/tokens/build/scss/_tokens.dark.scss +5 -5
  26. package/src/tokens/contextual/alert.tokens.json +5 -20
  27. package/translations.js +1 -0
@@ -316,23 +316,23 @@ const DATA_VIZ_ORANGE_950 = '#fae8d1';
316
316
  const GL_ALERT_NEUTRAL_TITLE_COLOR = '#fff'; // Used for the title color of a neutral alert.
317
317
  const GL_ALERT_NEUTRAL_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a neutral alert.
318
318
  const GL_ALERT_NEUTRAL_BORDER_TOP_COLOR = '#89888d'; // Used for the border center color of a neutral alert.
319
- const GL_ALERT_NEUTRAL_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a neutral alert.
319
+ const GL_ALERT_NEUTRAL_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a neutral alert.
320
320
  const GL_ALERT_INFO_TITLE_COLOR = '#63a6e9'; // Used for the title color of an info alert.
321
321
  const GL_ALERT_INFO_BACKGROUND_COLOR = '#28272d'; // Used for the background color of an info alert.
322
322
  const GL_ALERT_INFO_BORDER_TOP_COLOR = '#428fdc'; // Used for the border color of an info alert.
323
- const GL_ALERT_INFO_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of an info alert.
323
+ const GL_ALERT_INFO_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of an info alert.
324
324
  const GL_ALERT_SUCCESS_TITLE_COLOR = '#52b87a'; // Used for the title color of a success alert.
325
325
  const GL_ALERT_SUCCESS_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a success alert.
326
326
  const GL_ALERT_SUCCESS_BORDER_TOP_COLOR = '#2da160'; // Used for the border color of a success alert.
327
- const GL_ALERT_SUCCESS_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a success alert.
327
+ const GL_ALERT_SUCCESS_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a success alert.
328
328
  const GL_ALERT_WARNING_TITLE_COLOR = '#d99530'; // Used for the title color of a warning alert.
329
329
  const GL_ALERT_WARNING_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a warning alert.
330
330
  const GL_ALERT_WARNING_BORDER_TOP_COLOR = '#c17d10'; // Used for the border color of a warning alert.
331
- const GL_ALERT_WARNING_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a warning alert.
331
+ const GL_ALERT_WARNING_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a warning alert.
332
332
  const GL_ALERT_DANGER_TITLE_COLOR = '#f57f6c'; // Used for the title color of a danger alert.
333
333
  const GL_ALERT_DANGER_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a danger alert.
334
334
  const GL_ALERT_DANGER_BORDER_TOP_COLOR = '#ec5941'; // Used for the border color of a danger alert.
335
- const GL_ALERT_DANGER_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a danger alert.
335
+ const GL_ALERT_DANGER_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a danger alert.
336
336
  const GL_AVATAR_BORDER_COLOR_DEFAULT = 'rgba(255, 255, 255, 0.08)'; // Used to define the edge of an avatar.
337
337
  const GL_AVATAR_BORDER_COLOR_HOVER = 'rgba(255, 255, 255, 0.24)'; // Used to increase the edge definition of an avatar in the hover state.
338
338
  const GL_AVATAR_FALLBACK_TEXT_COLOR_RED = '#fcb5aa'; // Red text color for avatar fallback with no particular meaning.
@@ -666,15 +666,15 @@
666
666
  --gl-avatar-fallback-text-color-red: var(--gl-color-red-200); /* Red text color for avatar fallback with no particular meaning. */
667
667
  --gl-avatar-border-color-hover: var(--gl-color-alpha-light-24); /* Used to increase the edge definition of an avatar in the hover state. */
668
668
  --gl-avatar-border-color-default: var(--gl-color-alpha-light-8); /* Used to define the edge of an avatar. */
669
- --gl-alert-danger-border-bottom-color: var(--gl-color-neutral-800); /* Used for the border bottom color of a danger alert. */
669
+ --gl-alert-danger-border-bottom-color: var(--gl-color-alpha-0); /* Used for the border bottom color of a danger alert. */
670
670
  --gl-alert-danger-border-top-color: var(--gl-color-red-400); /* Used for the border color of a danger alert. */
671
- --gl-alert-warning-border-bottom-color: var(--gl-color-neutral-800); /* Used for the border bottom color of a warning alert. */
671
+ --gl-alert-warning-border-bottom-color: var(--gl-color-alpha-0); /* Used for the border bottom color of a warning alert. */
672
672
  --gl-alert-warning-border-top-color: var(--gl-color-orange-400); /* Used for the border color of a warning alert. */
673
- --gl-alert-success-border-bottom-color: var(--gl-color-neutral-800); /* Used for the border bottom color of a success alert. */
673
+ --gl-alert-success-border-bottom-color: var(--gl-color-alpha-0); /* Used for the border bottom color of a success alert. */
674
674
  --gl-alert-success-border-top-color: var(--gl-color-green-400); /* Used for the border color of a success alert. */
675
- --gl-alert-info-border-bottom-color: var(--gl-color-neutral-800); /* Used for the border bottom color of an info alert. */
675
+ --gl-alert-info-border-bottom-color: var(--gl-color-alpha-0); /* Used for the border bottom color of an info alert. */
676
676
  --gl-alert-info-border-top-color: var(--gl-color-blue-400); /* Used for the border color of an info alert. */
677
- --gl-alert-neutral-border-bottom-color: var(--gl-color-neutral-800); /* Used for the border bottom color of a neutral alert. */
677
+ --gl-alert-neutral-border-bottom-color: var(--gl-color-alpha-0); /* Used for the border bottom color of a neutral alert. */
678
678
  --gl-alert-neutral-border-top-color: var(--gl-color-neutral-400); /* Used for the border center color of a neutral alert. */
679
679
  --gl-border-color-transparent: var(--gl-color-alpha-0); /* Used when a border needs to be present, but not visibly perceived. */
680
680
  --gl-border-color-strong: var(--gl-color-neutral-400); /* Used for a distinct border that emphasizes an edge or boundaries. */
@@ -316,23 +316,23 @@ export const DATA_VIZ_ORANGE_950 = '#fae8d1';
316
316
  export const GL_ALERT_NEUTRAL_TITLE_COLOR = '#fff'; // Used for the title color of a neutral alert.
317
317
  export const GL_ALERT_NEUTRAL_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a neutral alert.
318
318
  export const GL_ALERT_NEUTRAL_BORDER_TOP_COLOR = '#89888d'; // Used for the border center color of a neutral alert.
319
- export const GL_ALERT_NEUTRAL_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a neutral alert.
319
+ export const GL_ALERT_NEUTRAL_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a neutral alert.
320
320
  export const GL_ALERT_INFO_TITLE_COLOR = '#63a6e9'; // Used for the title color of an info alert.
321
321
  export const GL_ALERT_INFO_BACKGROUND_COLOR = '#28272d'; // Used for the background color of an info alert.
322
322
  export const GL_ALERT_INFO_BORDER_TOP_COLOR = '#428fdc'; // Used for the border color of an info alert.
323
- export const GL_ALERT_INFO_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of an info alert.
323
+ export const GL_ALERT_INFO_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of an info alert.
324
324
  export const GL_ALERT_SUCCESS_TITLE_COLOR = '#52b87a'; // Used for the title color of a success alert.
325
325
  export const GL_ALERT_SUCCESS_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a success alert.
326
326
  export const GL_ALERT_SUCCESS_BORDER_TOP_COLOR = '#2da160'; // Used for the border color of a success alert.
327
- export const GL_ALERT_SUCCESS_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a success alert.
327
+ export const GL_ALERT_SUCCESS_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a success alert.
328
328
  export const GL_ALERT_WARNING_TITLE_COLOR = '#d99530'; // Used for the title color of a warning alert.
329
329
  export const GL_ALERT_WARNING_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a warning alert.
330
330
  export const GL_ALERT_WARNING_BORDER_TOP_COLOR = '#c17d10'; // Used for the border color of a warning alert.
331
- export const GL_ALERT_WARNING_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a warning alert.
331
+ export const GL_ALERT_WARNING_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a warning alert.
332
332
  export const GL_ALERT_DANGER_TITLE_COLOR = '#f57f6c'; // Used for the title color of a danger alert.
333
333
  export const GL_ALERT_DANGER_BACKGROUND_COLOR = '#28272d'; // Used for the background color of a danger alert.
334
334
  export const GL_ALERT_DANGER_BORDER_TOP_COLOR = '#ec5941'; // Used for the border color of a danger alert.
335
- export const GL_ALERT_DANGER_BORDER_BOTTOM_COLOR = '#3a383f'; // Used for the border bottom color of a danger alert.
335
+ export const GL_ALERT_DANGER_BORDER_BOTTOM_COLOR = 'transparent'; // Used for the border bottom color of a danger alert.
336
336
  export const GL_AVATAR_BORDER_COLOR_DEFAULT = 'rgba(255, 255, 255, 0.08)'; // Used to define the edge of an avatar.
337
337
  export const GL_AVATAR_BORDER_COLOR_HOVER = 'rgba(255, 255, 255, 0.24)'; // Used to increase the edge definition of an avatar in the hover state.
338
338
  export const GL_AVATAR_FALLBACK_TEXT_COLOR_RED = '#fcb5aa'; // Red text color for avatar fallback with no particular meaning.
@@ -6353,16 +6353,13 @@
6353
6353
  },
6354
6354
  "bottom": {
6355
6355
  "color": {
6356
- "value": "#3a383f",
6356
+ "value": "transparent",
6357
6357
  "$type": "color",
6358
6358
  "comment": "Used for the border bottom color of a neutral alert.",
6359
6359
  "filePath": "src/tokens/contextual/alert.tokens.json",
6360
6360
  "isSource": true,
6361
6361
  "original": {
6362
- "value": {
6363
- "default": "{color.alpha.0}",
6364
- "dark": "{color.neutral.800}"
6365
- },
6362
+ "value": "{color.alpha.0}",
6366
6363
  "$type": "color",
6367
6364
  "comment": "Used for the border bottom color of a neutral alert."
6368
6365
  },
@@ -6459,16 +6456,13 @@
6459
6456
  },
6460
6457
  "bottom": {
6461
6458
  "color": {
6462
- "value": "#3a383f",
6459
+ "value": "transparent",
6463
6460
  "$type": "color",
6464
6461
  "comment": "Used for the border bottom color of an info alert.",
6465
6462
  "filePath": "src/tokens/contextual/alert.tokens.json",
6466
6463
  "isSource": true,
6467
6464
  "original": {
6468
- "value": {
6469
- "default": "{color.alpha.0}",
6470
- "dark": "{color.neutral.800}"
6471
- },
6465
+ "value": "{color.alpha.0}",
6472
6466
  "$type": "color",
6473
6467
  "comment": "Used for the border bottom color of an info alert."
6474
6468
  },
@@ -6565,16 +6559,13 @@
6565
6559
  },
6566
6560
  "bottom": {
6567
6561
  "color": {
6568
- "value": "#3a383f",
6562
+ "value": "transparent",
6569
6563
  "$type": "color",
6570
6564
  "comment": "Used for the border bottom color of a success alert.",
6571
6565
  "filePath": "src/tokens/contextual/alert.tokens.json",
6572
6566
  "isSource": true,
6573
6567
  "original": {
6574
- "value": {
6575
- "default": "{color.alpha.0}",
6576
- "dark": "{color.neutral.800}"
6577
- },
6568
+ "value": "{color.alpha.0}",
6578
6569
  "$type": "color",
6579
6570
  "comment": "Used for the border bottom color of a success alert."
6580
6571
  },
@@ -6671,16 +6662,13 @@
6671
6662
  },
6672
6663
  "bottom": {
6673
6664
  "color": {
6674
- "value": "#3a383f",
6665
+ "value": "transparent",
6675
6666
  "$type": "color",
6676
6667
  "comment": "Used for the border bottom color of a warning alert.",
6677
6668
  "filePath": "src/tokens/contextual/alert.tokens.json",
6678
6669
  "isSource": true,
6679
6670
  "original": {
6680
- "value": {
6681
- "default": "{color.alpha.0}",
6682
- "dark": "{color.neutral.800}"
6683
- },
6671
+ "value": "{color.alpha.0}",
6684
6672
  "$type": "color",
6685
6673
  "comment": "Used for the border bottom color of a warning alert."
6686
6674
  },
@@ -6777,16 +6765,13 @@
6777
6765
  },
6778
6766
  "bottom": {
6779
6767
  "color": {
6780
- "value": "#3a383f",
6768
+ "value": "transparent",
6781
6769
  "$type": "color",
6782
6770
  "comment": "Used for the border bottom color of a danger alert.",
6783
6771
  "filePath": "src/tokens/contextual/alert.tokens.json",
6784
6772
  "isSource": true,
6785
6773
  "original": {
6786
- "value": {
6787
- "default": "{color.alpha.0}",
6788
- "dark": "{color.neutral.800}"
6789
- },
6774
+ "value": "{color.alpha.0}",
6790
6775
  "$type": "color",
6791
6776
  "comment": "Used for the border bottom color of a danger alert."
6792
6777
  },
@@ -6359,10 +6359,7 @@
6359
6359
  "filePath": "src/tokens/contextual/alert.tokens.json",
6360
6360
  "isSource": true,
6361
6361
  "original": {
6362
- "value": {
6363
- "default": "{color.alpha.0}",
6364
- "dark": "{color.neutral.800}"
6365
- },
6362
+ "value": "{color.alpha.0}",
6366
6363
  "$type": "color",
6367
6364
  "comment": "Used for the border bottom color of a neutral alert."
6368
6365
  },
@@ -6465,10 +6462,7 @@
6465
6462
  "filePath": "src/tokens/contextual/alert.tokens.json",
6466
6463
  "isSource": true,
6467
6464
  "original": {
6468
- "value": {
6469
- "default": "{color.alpha.0}",
6470
- "dark": "{color.neutral.800}"
6471
- },
6465
+ "value": "{color.alpha.0}",
6472
6466
  "$type": "color",
6473
6467
  "comment": "Used for the border bottom color of an info alert."
6474
6468
  },
@@ -6571,10 +6565,7 @@
6571
6565
  "filePath": "src/tokens/contextual/alert.tokens.json",
6572
6566
  "isSource": true,
6573
6567
  "original": {
6574
- "value": {
6575
- "default": "{color.alpha.0}",
6576
- "dark": "{color.neutral.800}"
6577
- },
6568
+ "value": "{color.alpha.0}",
6578
6569
  "$type": "color",
6579
6570
  "comment": "Used for the border bottom color of a success alert."
6580
6571
  },
@@ -6677,10 +6668,7 @@
6677
6668
  "filePath": "src/tokens/contextual/alert.tokens.json",
6678
6669
  "isSource": true,
6679
6670
  "original": {
6680
- "value": {
6681
- "default": "{color.alpha.0}",
6682
- "dark": "{color.neutral.800}"
6683
- },
6671
+ "value": "{color.alpha.0}",
6684
6672
  "$type": "color",
6685
6673
  "comment": "Used for the border bottom color of a warning alert."
6686
6674
  },
@@ -6783,10 +6771,7 @@
6783
6771
  "filePath": "src/tokens/contextual/alert.tokens.json",
6784
6772
  "isSource": true,
6785
6773
  "original": {
6786
- "value": {
6787
- "default": "{color.alpha.0}",
6788
- "dark": "{color.neutral.800}"
6789
- },
6774
+ "value": "{color.alpha.0}",
6790
6775
  "$type": "color",
6791
6776
  "comment": "Used for the border bottom color of a danger alert."
6792
6777
  },
@@ -664,15 +664,15 @@ $gl-avatar-fallback-text-color-purple: $gl-color-purple-200; // Purple text colo
664
664
  $gl-avatar-fallback-text-color-red: $gl-color-red-200; // Red text color for avatar fallback with no particular meaning.
665
665
  $gl-avatar-border-color-hover: $gl-color-alpha-light-24; // Used to increase the edge definition of an avatar in the hover state.
666
666
  $gl-avatar-border-color-default: $gl-color-alpha-light-8; // Used to define the edge of an avatar.
667
- $gl-alert-danger-border-bottom-color: $gl-color-neutral-800; // Used for the border bottom color of a danger alert.
667
+ $gl-alert-danger-border-bottom-color: $gl-color-alpha-0; // Used for the border bottom color of a danger alert.
668
668
  $gl-alert-danger-border-top-color: $gl-color-red-400; // Used for the border color of a danger alert.
669
- $gl-alert-warning-border-bottom-color: $gl-color-neutral-800; // Used for the border bottom color of a warning alert.
669
+ $gl-alert-warning-border-bottom-color: $gl-color-alpha-0; // Used for the border bottom color of a warning alert.
670
670
  $gl-alert-warning-border-top-color: $gl-color-orange-400; // Used for the border color of a warning alert.
671
- $gl-alert-success-border-bottom-color: $gl-color-neutral-800; // Used for the border bottom color of a success alert.
671
+ $gl-alert-success-border-bottom-color: $gl-color-alpha-0; // Used for the border bottom color of a success alert.
672
672
  $gl-alert-success-border-top-color: $gl-color-green-400; // Used for the border color of a success alert.
673
- $gl-alert-info-border-bottom-color: $gl-color-neutral-800; // Used for the border bottom color of an info alert.
673
+ $gl-alert-info-border-bottom-color: $gl-color-alpha-0; // Used for the border bottom color of an info alert.
674
674
  $gl-alert-info-border-top-color: $gl-color-blue-400; // Used for the border color of an info alert.
675
- $gl-alert-neutral-border-bottom-color: $gl-color-neutral-800; // Used for the border bottom color of a neutral alert.
675
+ $gl-alert-neutral-border-bottom-color: $gl-color-alpha-0; // Used for the border bottom color of a neutral alert.
676
676
  $gl-alert-neutral-border-top-color: $gl-color-neutral-400; // Used for the border center color of a neutral alert.
677
677
  $gl-border-color-transparent: $gl-color-alpha-0; // Used when a border needs to be present, but not visibly perceived.
678
678
  $gl-border-color-strong: $gl-color-neutral-400; // Used for a distinct border that emphasizes an edge or boundaries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "91.4.0",
3
+ "version": "91.6.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -111,7 +111,7 @@
111
111
  "@babel/preset-env": "^7.25.4",
112
112
  "@babel/preset-react": "^7.24.7",
113
113
  "@cypress/grep": "^4.0.1",
114
- "@gitlab/eslint-plugin": "20.0.0",
114
+ "@gitlab/eslint-plugin": "20.1.0",
115
115
  "@gitlab/fonts": "^1.3.0",
116
116
  "@gitlab/stylelint-config": "6.2.1",
117
117
  "@gitlab/svgs": "3.114.0",
@@ -148,7 +148,7 @@
148
148
  "babel-loader": "^8.0.5",
149
149
  "bootstrap": "4.6.2",
150
150
  "cobertura-merge": "^1.0.4",
151
- "cypress": "13.13.3",
151
+ "cypress": "13.14.1",
152
152
  "cypress-axe": "^1.4.0",
153
153
  "cypress-real-events": "^1.11.0",
154
154
  "dompurify": "^3.1.2",
@@ -0,0 +1,168 @@
1
+ <script>
2
+ import { translate } from '../../../../../../../utils/i18n';
3
+ import GlCard from '../../../../../../base/card/card.vue';
4
+ import GlDuoChatContextItemSelections from '../duo_chat_context_item_selections/duo_chat_context_item_selections.vue';
5
+ import { categoriesValidator, contextItemsValidator } from '../utils';
6
+
7
+ export default {
8
+ name: 'GlDuoChatContextItemMenu',
9
+ components: {
10
+ GlCard,
11
+ GlDuoChatContextItemSelections,
12
+ },
13
+ props: {
14
+ /**
15
+ * Whether the menu is open.
16
+ */
17
+ open: {
18
+ type: Boolean,
19
+ required: true,
20
+ },
21
+ /**
22
+ * Array of selected context items.
23
+ */
24
+ selections: {
25
+ type: Array,
26
+ required: true,
27
+ validator: contextItemsValidator,
28
+ },
29
+ /**
30
+ * Whether the menu is in a loading state.
31
+ */
32
+ loading: {
33
+ type: Boolean,
34
+ required: true,
35
+ },
36
+ /**
37
+ * Error message to display, if any.
38
+ */
39
+ error: {
40
+ type: [String, null],
41
+ required: false,
42
+ default: null,
43
+ },
44
+ /**
45
+ * Array of available categories for context items.
46
+ */
47
+ categories: {
48
+ type: Array,
49
+ required: true,
50
+ validator: categoriesValidator,
51
+ },
52
+ /**
53
+ * Array of search results for context items.
54
+ */
55
+ results: {
56
+ type: Array,
57
+ required: true,
58
+ validator: contextItemsValidator,
59
+ },
60
+ },
61
+ data() {
62
+ return {
63
+ selectedCategory: null,
64
+ };
65
+ },
66
+ computed: {
67
+ showCategorySelection() {
68
+ return this.open && !this.selectedCategory;
69
+ },
70
+ },
71
+ watch: {
72
+ open(isOpen) {
73
+ if (!isOpen) {
74
+ this.resetSelection();
75
+ }
76
+ },
77
+ },
78
+ methods: {
79
+ selectCategory(category) {
80
+ this.selectedCategory = category;
81
+
82
+ /**
83
+ * Emitted when a search should be performed.
84
+ * @property {Object} filter
85
+ * @property {string} filter.category - The value of the selected category
86
+ * @property {string} filter.query - The search query
87
+ */
88
+ this.$emit('search', {
89
+ category: category.value,
90
+ query: '',
91
+ });
92
+ },
93
+ selectItem(item) {
94
+ if (!item.isEnabled) {
95
+ return;
96
+ }
97
+
98
+ /**
99
+ * Emitted when a context item is selected.
100
+ * @property {Object} item - The selected context item
101
+ */
102
+ this.$emit(
103
+ 'select',
104
+ this.results.find((result) => result.id === item.id)
105
+ );
106
+
107
+ /**
108
+ * Emitted when the menu should be closed.
109
+ */
110
+ this.$emit('close');
111
+ this.resetSelection();
112
+ },
113
+ removeItem(item) {
114
+ /**
115
+ * Emitted when a context item should be removed.
116
+ * @property {Object} item - The context item to be removed
117
+ */
118
+ this.$emit('remove', item);
119
+ },
120
+ resetSelection() {
121
+ this.selectedCategory = null;
122
+ },
123
+ },
124
+ i18n: {
125
+ selectedContextItemsTitle: translate(
126
+ 'GlDuoChatContextItemMenu.selectedContextItemsTitle',
127
+ 'Included references'
128
+ ),
129
+ },
130
+ };
131
+ </script>
132
+
133
+ <template>
134
+ <div>
135
+ <gl-duo-chat-context-item-selections
136
+ v-if="selections.length"
137
+ :selections="selections"
138
+ :removable="true"
139
+ :title="$options.i18n.selectedContextItemsTitle"
140
+ :default-collapsed="false"
141
+ class="gl-mb-3"
142
+ @remove="removeItem"
143
+ />
144
+ <gl-card
145
+ v-if="open"
146
+ class="slash-commands !gl-absolute gl-bottom-0 gl-w-full gl-pl-0 gl-shadow-md"
147
+ body-class="!gl-p-2"
148
+ data-testid="context-item-menu"
149
+ >
150
+ <ul v-if="showCategorySelection" data-testid="context-menu-category-items">
151
+ <!-- Placeholder for GlDuoChatContextItemMenuCategoryItems component coming in a future iteration -->
152
+ <li v-for="category of categories" :key="category.value" @click="selectCategory(category)">
153
+ {{ category.label }}
154
+ </li>
155
+ </ul>
156
+ <div v-else data-testid="context-menu-search-items">
157
+ <!-- Placeholder for GlDuoChatContextItemMenuSearchItem component coming in a future iteration -->
158
+ <template v-if="loading">Loading...</template>
159
+ <template v-else-if="error">Error: {{ error }}</template>
160
+ <ul v-else>
161
+ <li v-for="result of results" :key="result.id" @click="selectItem(result)">
162
+ {{ result.metadata.name }} {{ result.isEnabled ? '' : '(disabled)' }}
163
+ </li>
164
+ </ul>
165
+ </div>
166
+ </gl-card>
167
+ </div>
168
+ </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
  ];