A platform for community discussion. Free, open, simple.
DEV: migrates username-preference to gjs (#27864)
Joffrey JAFFEUX5cdd6d7c37be
diff --git a/app/assets/javascripts/discourse/app/components/username-preference.js b/app/assets/javascripts/discourse/app/components/username-preference.gjssimilarity index 56%rename from app/assets/javascripts/discourse/app/components/username-preference.jsrename to app/assets/javascripts/discourse/app/components/username-preference.gjsindex 2ae47d793a0..e465d3ae9a8 100644--- a/app/assets/javascripts/discourse/app/components/username-preference.js+++ b/app/assets/javascripts/discourse/app/components/username-preference.gjs@@ -1,13 +1,19 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { Input } from "@ember/component";+import { on } from "@ember/modifier";import { action } from "@ember/object";import { empty, or } from "@ember/object/computed";import { service } from "@ember/service";+import { htmlSafe } from "@ember/template";import { isEmpty } from "@ember/utils";+import DButton from "discourse/components/d-button";+import DModalCancel from "discourse/components/d-modal-cancel";import { popupAjaxError } from "discourse/lib/ajax-error";import { setting } from "discourse/lib/computed";import DiscourseURL, { userPath } from "discourse/lib/url";import User from "discourse/models/user";+import i18n from "discourse-common/helpers/i18n";import I18n from "discourse-i18n";export default class UsernamePreference extends Component {@@ -97,4 +103,65 @@ export default class UsernamePreference extends Component {},});}++ <template>+ {{#if this.editing}}+ <form class="form-horizontal">+ <div class="control-group">+ <Input+ {{on "input" this.onInput}}+ @value={{this.newUsername}}+ maxlength={{this.maxLength}}+ class="input-xxlarge username-preference__input"+ />++ <div class="instructions">+ <p>+ {{#if this.taken}}+ {{i18n "user.change_username.taken"}}+ {{/if}}+ <span>{{this.errorMessage}}</span>+ </p>+ </div>+ </div>++ <div class="control-group">+ <DButton+ @action={{this.changeUsername}}+ @disabled={{this.saveDisabled}}+ @translatedLabel={{this.saveButtonText}}+ type="submit"+ class="btn-primary username-preference__submit"+ />++ <DModalCancel @close={{this.toggleEditing}} />++ {{#if this.saved}}{{i18n "saved"}}{{/if}}+ </div>+ </form>+ {{else}}+ <div class="controls">+ <span+ class="static username-preference__current-username"+ >{{@user.username}}</span>++ {{#if @user.can_edit_username}}+ <DButton+ @action={{this.toggleEditing}}+ @icon="pencil-alt"+ @title="user.username.edit"+ class="btn-small username-preference__edit-username"+ />+ {{/if}}+ </div>++ {{#if this.siteSettings.enable_mentions}}+ <div class="instructions">+ {{htmlSafe+ (i18n "user.username.short_instructions" [email protected])+ }}+ </div>+ {{/if}}+ {{/if}}+ </template>}diff --git a/app/assets/javascripts/discourse/app/components/username-preference.hbs b/app/assets/javascripts/discourse/app/components/username-preference.hbsdeleted file mode 100644index f26b5dab93c..00000000000--- a/app/assets/javascripts/discourse/app/components/username-preference.hbs+++ /dev/null@@ -1,58 +0,0 @@-{{#if this.editing}}- <form class="form-horizontal">- <div class="control-group">- <Input- {{on "input" this.onInput}}- @value={{this.newUsername}}- maxlength={{this.maxLength}}- class="input-xxlarge username-preference__input"- />-- <div class="instructions">- <p>- {{#if this.taken}}- {{i18n "user.change_username.taken"}}- {{/if}}- <span>{{this.errorMessage}}</span>- </p>- </div>- </div>-- <div class="control-group">- <DButton- @action={{this.changeUsername}}- @disabled={{this.saveDisabled}}- @translatedLabel={{this.saveButtonText}}- type="submit"- class="btn-primary username-preference__submit"- />-- <DModalCancel @close={{this.toggleEditing}} />-- {{#if this.saved}}{{i18n "saved"}}{{/if}}- </div>- </form>-{{else}}- <div class="controls">- <span- class="static username-preference__current-username"- >{{@user.username}}</span>-- {{#if @user.can_edit_username}}- <DButton- @action={{fn this.toggleEditing @user}}- @icon="pencil-alt"- @title="user.username.edit"- class="btn-small username-preference__edit-username"- />- {{/if}}- </div>-- {{#if this.siteSettings.enable_mentions}}- <div class="instructions">- {{html-safe- (i18n "user.username.short_instructions" [email protected])- }}- </div>- {{/if}}-{{/if}}\ No newline at end of file