Merge "gr-dropdown-list: Fix text on mobile"
diff --git a/polygerrit-ui/app/constants/reporting.ts b/polygerrit-ui/app/constants/reporting.ts
index 9db6ab6..a60f960 100644
--- a/polygerrit-ui/app/constants/reporting.ts
+++ b/polygerrit-ui/app/constants/reporting.ts
@@ -166,4 +166,6 @@
COMMENT_COMPLETION_SUGGESTION_ACCEPTED = 'comment-completion-suggestion-accepted',
COMMENT_COMPLETION_SAVE_DRAFT = 'comment-completion-save-draft',
COMMENT_COMPLETION_SUGGESTION_FETCHED = 'comment-completion-suggestion-fetched',
+ GENERATE_SUGGESTION_THUMB_UP = 'ai_suggestion_thumb_up',
+ GENERATE_SUGGESTION_THUMB_DOWN = 'ai_suggestion_thumb_down',
}
diff --git a/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts b/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
index 0df19f9..b5ba204 100644
--- a/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
+++ b/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
@@ -21,6 +21,7 @@
import {pluginLoaderToken} from '../gr-js-api-interface/gr-plugin-loader';
import {SuggestionsProvider} from '../../../api/suggestions';
import {PROVIDED_FIX_ID} from '../../../utils/comment-util';
+import {KnownExperimentId} from '../../../services/flags/flags';
import {when} from 'lit/directives/when.js';
import {storageServiceToken} from '../../../services/storage/gr-storage_impl';
import {getAppContext} from '../../../services/app-context';
@@ -67,6 +68,10 @@
@state() isChangeAbandoned = false;
+ @state() private thumbUpSelected = false;
+
+ @state() private thumbDownSelected = false;
+
private readonly getConfigModel = resolve(this, configModelToken);
private readonly getChangeModel = resolve(this, changeModelToken);
@@ -77,6 +82,8 @@
private readonly reporting = getAppContext().reportingService;
+ private readonly flagsService = getAppContext().flagsService;
+
@state() private previewLoaded = false;
constructor() {
@@ -165,6 +172,8 @@
}
.header .title {
flex: 1;
+ display: flex;
+ align-items: center;
}
.headerMiddle {
display: flex;
@@ -173,6 +182,17 @@
.copyButton {
margin-right: var(--spacing-l);
}
+ .feedback-button[aria-label='Thumb up'] {
+ margin-left: var(--spacing-l);
+ margin-right: 0;
+ }
+ .feedback-button[aria-label='Thumb down'] {
+ margin-left: 0;
+ }
+ .selected {
+ color: var(--selected-foreground);
+ background-color: var(--selected-background);
+ }
`,
];
}
@@ -198,11 +218,44 @@
name="suggestion"
.value=${fix_suggestions}
></gr-endpoint-param
- ><gr-icon
- icon="help"
- title="read documentation"
- ></gr-icon></gr-endpoint-decorator
- ></a>
+ ><gr-icon icon="help" title="read documentation"></gr-icon
+ ></gr-endpoint-decorator>
+ </a>
+ ${when(
+ this.flagsService.isEnabled(
+ KnownExperimentId.ML_SUGGESTED_EDIT_FEEDBACK
+ ),
+ () => html`
+ <gr-button
+ secondary
+ flatten
+ class="action feedback-button ${this.thumbUpSelected
+ ? 'selected'
+ : ''}"
+ aria-label="Thumb up"
+ @click=${this.handleThumbUpClick}
+ >
+ <gr-icon
+ icon="thumb_up"
+ ?filled=${this.thumbUpSelected}
+ ></gr-icon>
+ </gr-button>
+ <gr-button
+ secondary
+ flatten
+ class="action feedback-button ${this.thumbDownSelected
+ ? 'selected'
+ : ''}"
+ aria-label="Thumb down"
+ @click=${this.handleThumbDownClick}
+ >
+ <gr-icon
+ icon="thumb_down"
+ ?filled=${this.thumbDownSelected}
+ ></gr-icon>
+ </gr-button>
+ `
+ )}
</div>
<div class="headerMiddle">
<gr-button
@@ -318,6 +371,24 @@
}
}
+ private handleThumbUpClick() {
+ this.thumbUpSelected = !this.thumbUpSelected;
+ if (this.thumbUpSelected) {
+ this.thumbDownSelected = false;
+ }
+ this.reporting.reportInteraction(Interaction.GENERATE_SUGGESTION_THUMB_UP);
+ }
+
+ private handleThumbDownClick() {
+ this.thumbDownSelected = !this.thumbDownSelected;
+ if (this.thumbDownSelected) {
+ this.thumbUpSelected = false;
+ }
+ this.reporting.reportInteraction(
+ Interaction.GENERATE_SUGGESTION_THUMB_DOWN
+ );
+ }
+
private isApplyEditDisabled() {
if (this.comment?.patch_set === undefined) return true;
if (this.isChangeMerged) return true;
diff --git a/polygerrit-ui/app/services/flags/flags.ts b/polygerrit-ui/app/services/flags/flags.ts
index 1486def..eecb898 100644
--- a/polygerrit-ui/app/services/flags/flags.ts
+++ b/polygerrit-ui/app/services/flags/flags.ts
@@ -26,4 +26,5 @@
GET_AI_FIX = 'UiFeature__get_ai_fix',
GET_AI_PROMPT = 'UiFeature__get_ai_prompt',
ML_SUGGESTED_EDIT_UNCHECK_BY_DEFAULT = 'UiFeature__ml_suggested_edit_uncheck_by_default',
+ ML_SUGGESTED_EDIT_FEEDBACK = 'UiFeature__ml_suggested_edit_feedback',
}