Merge changes I4a3c4512,Ie77f941f * changes: Remove obsolete flag `render_markdown` Clean up `mentioned_users` flag
diff --git a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts index 84bdffb..b726292 100644 --- a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts +++ b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
@@ -55,7 +55,6 @@ import {SummaryChipStyles} from './gr-summary-chip'; import {when} from 'lit/directives/when.js'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {combineLatest} from 'rxjs'; import {userModelToken} from '../../../models/user/user-model'; @@ -120,8 +119,6 @@ private readonly reporting = getAppContext().reportingService; - private readonly flagsService = getAppContext().flagsService; - constructor() { super(); subscribe( @@ -174,24 +171,22 @@ () => this.getUserModel().account$, x => (this.selfAccount = x) ); - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - subscribe( - this, - () => - combineLatest([ - this.getUserModel().account$, - this.getCommentsModel().threads$, - ]), - ([selfAccount, threads]) => { - if (!selfAccount || !selfAccount.email) return; - const unresolvedThreadsMentioningSelf = getMentionedThreads( - threads, - selfAccount - ).filter(isUnresolved); - this.mentionCount = unresolvedThreadsMentioningSelf.length; - } - ); - } + subscribe( + this, + () => + combineLatest([ + this.getUserModel().account$, + this.getCommentsModel().threads$, + ]), + ([selfAccount, threads]) => { + if (!selfAccount || !selfAccount.email) return; + const unresolvedThreadsMentioningSelf = getMentionedThreads( + threads, + selfAccount + ).filter(isUnresolved); + this.mentionCount = unresolvedThreadsMentioningSelf.length; + } + ); } static override get styles() { @@ -575,8 +570,6 @@ } private renderMentionChip() { - if (!this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) - return nothing; if (!this.mentionCount) return nothing; return html` <gr-summary-chip class="mentionSummary"
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts index d4cff78..218594b 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -121,7 +121,6 @@ import {subscribe} from '../../lit/subscription-controller'; import {configModelToken} from '../../../models/config/config-model'; import {hasHumanReviewer, isOwner} from '../../../utils/change-util'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {commentsModelToken} from '../../../models/comments/comments-model'; import { CommentEditingChangedDetail, @@ -384,8 +383,6 @@ private readonly restApiService: RestApiService = getAppContext().restApiService; - private readonly flagsService = getAppContext().flagsService; - private readonly getPluginLoader = resolve(this, pluginLoaderToken); private readonly getConfigModel = resolve(this, configModelToken); @@ -671,9 +668,6 @@ this, () => this.getCommentsModel().mentionedUsersInUnresolvedDrafts$, x => { - if (!this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - return; - } this.mentionedUsersInUnresolvedDrafts = x.filter( v => !this.isAlreadyReviewerOrCC(v) ); @@ -1441,18 +1435,13 @@ ).filter(isDefined); for (const user of newAttentionSetUsers) { - let reason; - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - reason = - getMentionedReason( - this.draftCommentThreads, - this.account, - user, - this.serverConfig - ) ?? ''; - } else { - reason = getReplyByReason(this.account, this.serverConfig); - } + const reason = + getMentionedReason( + this.draftCommentThreads, + this.account, + user, + this.serverConfig + ) ?? ''; reviewInput.add_to_attention_set.push({user: getUserId(user), reason}); } reviewInput.remove_from_attention_set = [];
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts index 12b1c40..f7b3aec 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
@@ -13,7 +13,6 @@ query, queryAll, queryAndAssert, - stubFlags, stubRestApi, waitUntilVisible, } from '../../../test/test-utils'; @@ -59,7 +58,6 @@ import {accountKey} from '../../../utils/account-util'; import {GrButton} from '../../shared/gr-button/gr-button'; import {GrAccountLabel} from '../../shared/gr-account-label/gr-account-label'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {Key, Modifier} from '../../../utils/dom-util'; import {GrComment} from '../../shared/gr-comment/gr-comment'; import {testResolver} from '../../../test/common-test-setup'; @@ -2527,9 +2525,6 @@ suite('mention users', () => { setup(async () => { - stubFlags('isEnabled') - .withArgs(KnownExperimentId.MENTION_USERS) - .returns(true); element.account = createAccountWithId(1); element.requestUpdate(); await element.updateComplete;
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts index 80a1a9a..c09d2a2 100644 --- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts +++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
@@ -42,7 +42,6 @@ import {resolve} from '../../../models/dependency'; import {changeModelToken} from '../../../models/change/change-model'; import {Interaction} from '../../../constants/reporting'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {HtmlPatched} from '../../../utils/lit-util'; import {userModelToken} from '../../../models/user/user-model'; import {specialFilePathCompare} from '../../../utils/path-list-util'; @@ -205,8 +204,6 @@ private readonly reporting = getAppContext().reportingService; - private readonly flagsService = getAppContext().flagsService; - private readonly getUserModel = resolve(this, userModelToken); private readonly patched = new HtmlPatched(key => { @@ -495,14 +492,10 @@ value: CommentTabState.UNRESOLVED, }); if (this.account) { - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - items.push({ - text: `Mentions (${ - getMentionedThreads(threads, this.account).length - })`, - value: CommentTabState.MENTIONS, - }); - } + items.push({ + text: `Mentions (${getMentionedThreads(threads, this.account).length})`, + value: CommentTabState.MENTIONS, + }); items.push({ text: `Drafts (${threads.filter(isDraftThread).length})`, value: CommentTabState.DRAFTS,
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts index 66beaf1..c1cc863 100644 --- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts +++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -275,9 +275,7 @@ this.save(); }); } - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - this.messagePlaceholder = 'Mention others with @'; - } + this.messagePlaceholder = 'Mention others with @'; subscribe( this, () => this.getUserModel().account$,
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts index 627ea27..45eca40 100644 --- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts +++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
@@ -18,8 +18,6 @@ import {CommentLinks, EmailAddress} from '../../../api/rest-api'; import {linkifyUrlsAndApplyRewrite} from '../../../utils/link-util'; import '../gr-account-chip/gr-account-chip'; -import {KnownExperimentId} from '../../../services/flags/flags'; -import {getAppContext} from '../../../services/app-context'; /** * This element optionally renders markdown and also applies some regex @@ -36,8 +34,6 @@ @state() private repoCommentLinks: CommentLinks = {}; - private readonly flagsService = getAppContext().flagsService; - private readonly getConfigModel = resolve(this, configModelToken); // Private const but used in tests. @@ -214,9 +210,7 @@ override updated() { // Look for @mentions and replace them with an account-label chip. - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - this.convertEmailsToAccountChips(); - } + this.convertEmailsToAccountChips(); } private convertEmailsToAccountChips() {
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts index 3881c62..3187ada 100644 --- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts +++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts
@@ -15,14 +15,9 @@ import './gr-formatted-text'; import {GrFormattedText} from './gr-formatted-text'; import {createConfig} from '../../../test/test-data-generators'; -import { - queryAndAssert, - stubFlags, - waitUntilObserved, -} from '../../../test/test-utils'; +import {queryAndAssert, waitUntilObserved} from '../../../test/test-utils'; import {CommentLinks, EmailAddress} from '../../../api/rest-api'; import {testResolver} from '../../../test/common-test-setup'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {GrAccountChip} from '../gr-account-chip/gr-account-chip'; suite('gr-formatted-text tests', () => { @@ -412,38 +407,7 @@ ); }); - test('does not handle @mentions if not enabled', async () => { - stubFlags('isEnabled') - .withArgs(KnownExperimentId.MENTION_USERS) - .returns(false); - element.content = '@someone@google.com'; - await element.updateComplete; - - assert.shadowDom.equal( - element, - /* HTML */ ` - <marked-element> - <div slot="markdown-html" class="markdown-html"> - <p> - @ - <a - href="mailto:someone@google.com" - rel="noopener" - target="_blank" - > - someone@google.com - </a> - </p> - </div> - </marked-element> - ` - ); - }); - - test('handles @mentions if enabled', async () => { - stubFlags('isEnabled') - .withArgs(KnownExperimentId.MENTION_USERS) - .returns(true); + test('handles @mentions', async () => { element.content = '@someone@google.com'; await element.updateComplete; @@ -470,9 +434,6 @@ }); test('does not handle @mentions that is part of a code block', async () => { - stubFlags('isEnabled') - .withArgs(KnownExperimentId.MENTION_USERS) - .returns(true); element.content = '`@`someone@google.com'; await element.updateComplete;
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts index a1a1e84..e1e4ca5 100644 --- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts +++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
@@ -17,12 +17,11 @@ import {Key} from '../../../utils/dom-util'; import {ValueChangedEvent} from '../../../types/events'; import {fire} from '../../../utils/event-util'; -import {LitElement, css, html, nothing} from 'lit'; +import {LitElement, css, html} from 'lit'; import {customElement, property, query, state} from 'lit/decorators.js'; import {sharedStyles} from '../../../styles/shared-styles'; import {PropertyValues} from 'lit'; import {classMap} from 'lit/directives/class-map.js'; -import {KnownExperimentId} from '../../../services/flags/flags'; import {NumericChangeId, ServerInfo} from '../../../api/rest-api'; import {subscribe} from '../../lit/subscription-controller'; import {resolve} from '../../../models/dependency'; @@ -115,8 +114,6 @@ private readonly getChangeModel = resolve(this, changeModelToken); - private readonly flagsService = getAppContext().flagsService; - private readonly restApiService = getAppContext().restApiService; private readonly getConfigModel = resolve(this, configModelToken); @@ -265,8 +262,6 @@ } private renderMentionsDropdown() { - if (!this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) - return nothing; return html` <gr-autocomplete-dropdown id="mentionsSuggestions" .suggestions=${this.suggestions} @@ -524,8 +519,6 @@ } private isMentionsDropdownActive() { - if (!this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) - return false; return ( this.specialCharIndex !== -1 && this.text[this.specialCharIndex] === '@' ); @@ -540,10 +533,8 @@ private computeSpecialCharIndex() { const charAtCursor = this.text[this.textarea!.selectionStart - 1]; - if (this.flagsService.isEnabled(KnownExperimentId.MENTION_USERS)) { - if (charAtCursor === '@' && this.specialCharIndex === -1) { - this.specialCharIndex = this.getSpecialCharIndex(this.text); - } + if (charAtCursor === '@' && this.specialCharIndex === -1) { + this.specialCharIndex = this.getSpecialCharIndex(this.text); } if (charAtCursor === ':' && this.specialCharIndex === -1) { this.specialCharIndex = this.getSpecialCharIndex(this.text);
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts index f8ae38c..0400e85 100644 --- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts +++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts
@@ -7,12 +7,7 @@ import './gr-textarea'; import {GrTextarea} from './gr-textarea'; import {ItemSelectedEvent} from '../gr-autocomplete-dropdown/gr-autocomplete-dropdown'; -import { - pressKey, - stubFlags, - stubRestApi, - waitUntil, -} from '../../../test/test-utils'; +import {pressKey, stubRestApi, waitUntil} from '../../../test/test-utils'; import {fixture, html, assert} from '@open-wc/testing'; import {createAccountWithEmail} from '../../../test/test-data-generators'; import {Key} from '../../../utils/dom-util'; @@ -31,14 +26,16 @@ element, /* HTML */ `<div id="hiddenText"></div> <span id="caratSpan"> </span> + <gr-autocomplete-dropdown id="emojiSuggestions" is-hidden=""> + </gr-autocomplete-dropdown> <gr-autocomplete-dropdown - id="emojiSuggestions" + id="mentionsSuggestions" is-hidden="" - style="position: fixed; top: 150px; left: 392.5px; box-sizing: border-box; max-height: 300px; max-width: 785px;" + role="listbox" > </gr-autocomplete-dropdown> <iron-autogrow-textarea aria-disabled="false" focused="" id="textarea"> - </iron-autogrow-textarea> `, + </iron-autogrow-textarea>`, { // gr-autocomplete-dropdown sizing seems to vary between local & CI ignoreAttributes: [ @@ -49,47 +46,6 @@ }); suite('mention users', () => { - setup(async () => { - stubFlags('isEnabled').returns(true); - element.requestUpdate(); - await element.updateComplete; - }); - - test('renders', () => { - assert.shadowDom.equal( - element, - /* HTML */ ` - <div id="hiddenText"></div> - <span id="caratSpan"> </span> - <gr-autocomplete-dropdown - id="emojiSuggestions" - is-hidden="" - style="position: fixed; top: 478px; left: 321px; box-sizing: border-box; max-height: 956px; max-width: 642px;" - > - </gr-autocomplete-dropdown> - <gr-autocomplete-dropdown - id="mentionsSuggestions" - is-hidden="" - role="listbox" - style="position: fixed; top: 478px; left: 321px; box-sizing: border-box; max-height: 956px; max-width: 642px;" - > - </gr-autocomplete-dropdown> - <iron-autogrow-textarea - focused="" - aria-disabled="false" - id="textarea" - > - </iron-autogrow-textarea> - `, - { - // gr-autocomplete-dropdown sizing seems to vary between local & CI - ignoreAttributes: [ - {tags: ['gr-autocomplete-dropdown'], attributes: ['style']}, - ], - } - ); - }); - test('mentions selector is open when @ is typed & the textarea has focus', async () => { // Needed for Safari tests. selectionStart is not updated when text is // updated.
diff --git a/polygerrit-ui/app/services/flags/flags.ts b/polygerrit-ui/app/services/flags/flags.ts index 2a5dff2..93a82697d 100644 --- a/polygerrit-ui/app/services/flags/flags.ts +++ b/polygerrit-ui/app/services/flags/flags.ts
@@ -20,7 +20,5 @@ DIFF_RENDERING_LIT = 'UiFeature__diff_rendering_lit', PUSH_NOTIFICATIONS = 'UiFeature__push_notifications', SUGGEST_EDIT = 'UiFeature__suggest_edit', - MENTION_USERS = 'UiFeature__mention_users', - RENDER_MARKDOWN = 'UiFeature__render_markdown', REBASE_CHAIN = 'UiFeature__rebase_chain', }