From 351fd47823ba50f71d96edbc39932252c69aef20 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Mon, 7 Oct 2019 12:01:00 -0700 Subject: [PATCH] Fix various master bugs from ember upgrade We fixed a few deprecation for jquery on the cluster page but there were some errors firing when using so I fixed the targeting. There was also a intl error because of a missing api. --- .../components/input-identity/component.js | 6 ++--- .../components/principal-search/component.js | 7 +++--- .../components/searchable-select/component.js | 25 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/shared/addon/components/input-identity/component.js b/lib/shared/addon/components/input-identity/component.js index 9f62840cb..406134f22 100644 --- a/lib/shared/addon/components/input-identity/component.js +++ b/lib/shared/addon/components/input-identity/component.js @@ -148,11 +148,11 @@ export default Component.extend({ let intl = get(this, 'intl'); if ( get(this, 'access.provider') === 'githubconfig' ) { - out = intl.findTranslationByKey('inputIdentity.dropdownLabel.teams'); + out = intl.t('inputIdentity.dropdownLabel.teams'); } else { - out = intl.findTranslationByKey('inputIdentity.dropdownLabel.groups'); + out = intl.t('inputIdentity.dropdownLabel.groups'); } - return intl.formatMessage(out); + return out; }), }); diff --git a/lib/shared/addon/components/principal-search/component.js b/lib/shared/addon/components/principal-search/component.js index 6dc72503d..3b5c70db3 100644 --- a/lib/shared/addon/components/principal-search/component.js +++ b/lib/shared/addon/components/principal-search/component.js @@ -41,7 +41,7 @@ export default SearchableSelect.extend({ didInsertElement() { // Explicitly not calling super here to not show until there's content this._super(...arguments); - $('input').on('focus', () => { + $(this.element).find('input').on('focus', () => { if (this.isDestroyed || this.isDestroying) { return; } @@ -56,7 +56,7 @@ export default SearchableSelect.extend({ } }); - $('input').on('blur', () => { + $(this.element).find('input').on('blur', () => { later(() => { if (this.isDestroyed || this.isDestroying) { return; @@ -102,7 +102,8 @@ export default SearchableSelect.extend({ if (get(this, 'showOptions') === true) { return; } - const toBottom = $('body').height() - $($()[0]).offset().top - 60; // eslint-disable-line + const toBottom = $('body').height() - $(this.element).offset().top - 60; // eslint-disable-line + setProperties(this, { maxHeight: toBottom < get(this, 'maxHeight') ? toBottom : get(this, 'maxHeight'), diff --git a/lib/shared/addon/components/searchable-select/component.js b/lib/shared/addon/components/searchable-select/component.js index ea7b79325..a8ca069ac 100644 --- a/lib/shared/addon/components/searchable-select/component.js +++ b/lib/shared/addon/components/searchable-select/component.js @@ -75,10 +75,9 @@ export default Component.extend({ }, didInsertElement() { - const search = $('.input-search'); + const search = $(this.element).find('.input-search'); - // Stop chrome from showing autocomplete over our options - search.attr('autocomplete', Math.random()); + search.attr('autocomplete', 'off'); search.on('click', () => { this.send('show'); @@ -114,7 +113,7 @@ export default Component.extend({ }, mouseEnter(event) { - $('.searchable-option').removeClass('searchable-option-active'); + $(this.element).find('.searchable-option').removeClass('searchable-option-active'); const $target = $(event.target); @@ -134,14 +133,14 @@ export default Component.extend({ return; } - const toBottom = $('body').height() - $($()[0]).offset().top - 60; // eslint-disable-line + const toBottom = $('body').height() - $(this.element).offset().top - 60; // eslint-disable-line set(this, 'maxHeight', toBottom < MAX_HEIGHT ? toBottom : MAX_HEIGHT) set(this, 'filter', null); next(() => { - const checked = $('.searchable-option .icon-check'); - const options = $('.searchable-options'); + const checked = $(this.element).find('.searchable-option .icon-check'); + const options = $(this.element).find('.searchable-options'); if ( options.length && checked.length ) { options.animate({ scrollTop: `${ checked.parent().offset().top - options.offset().top }px` }); @@ -345,7 +344,7 @@ export default Component.extend({ }, on() { - $().on('keydown.searchable-option', (event) => { + $(this.element).on('keydown.searchable-option', (event) => { const kc = event.keyCode; // Note: keyup event can't be prevented. @@ -372,7 +371,7 @@ export default Component.extend({ if ($activeTarget.hasClass('searchable-prompt')) { this.send('selectPrompt'); } else { - let idx = $('.searchable-option').index($activeTarget); + let idx = $(this.element).find('.searchable-option').index($activeTarget); idx = !!get(this, 'prompt') ? idx - 1 : idx; @@ -395,8 +394,8 @@ export default Component.extend({ }, off() { - if ($()) { - $().off('keydown.searchable-option'); + if ($(this.element)) { + $(this.element).off('keydown.searchable-option'); } }, @@ -414,7 +413,7 @@ export default Component.extend({ // https://stackoverflow.com/questions/39624902/new-input-placeholder-behavior-in-safari-10-no-longer-hides-on-change-via-java next(() => { - const input = $('.input-search'); + const input = $(this.element).find('.input-search'); if ( input ) { input.focus(); @@ -431,7 +430,7 @@ export default Component.extend({ stepThroughOptions(step) { const $activeTarget = get(this, '$activeTarget'); - const $options = $('.searchable-option'); + const $options = $(this.element).find('.searchable-option'); const len = $options.length; let currentIdx = -1;