Refactor PersistentUserCallout instantiations

Uses a new factory method to DRY instantiation.
This commit is contained in:
Luke Bennett 2019-02-21 06:05:09 +00:00
parent f100c9ba15
commit e107ebc331
No known key found for this signature in database
GPG key ID: 402ED51FB5D306C2
5 changed files with 5 additions and 9 deletions

View file

@ -119,8 +119,7 @@ export default class Clusters {
static initDismissableCallout() {
const callout = document.querySelector('.js-cluster-security-warning');
if (callout) new PersistentUserCallout(callout); // eslint-disable-line no-new
PersistentUserCallout.factory(callout);
}
addListeners() {

View file

@ -2,6 +2,5 @@ import PersistentUserCallout from '~/persistent_user_callout';
document.addEventListener('DOMContentLoaded', () => {
const callout = document.querySelector('.gcp-signup-offer');
if (callout) new PersistentUserCallout(callout); // eslint-disable-line no-new
PersistentUserCallout.factory(callout);
});

View file

@ -3,8 +3,7 @@ import initGkeDropdowns from '~/projects/gke_cluster_dropdowns';
function initGcpSignupCallout() {
const callout = document.querySelector('.gcp-signup-offer');
if (callout) new PersistentUserCallout(callout); // eslint-disable-line no-new
PersistentUserCallout.factory(callout);
}
document.addEventListener('DOMContentLoaded', () => {

View file

@ -2,6 +2,5 @@ import PersistentUserCallout from '~/persistent_user_callout';
document.addEventListener('DOMContentLoaded', () => {
const callout = document.querySelector('.gcp-signup-offer');
if (callout) new PersistentUserCallout(callout); // eslint-disable-line no-new
PersistentUserCallout.factory(callout);
});

View file

@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (newClusterViews.indexOf(page) > -1) {
const callout = document.querySelector('.gcp-signup-offer');
if (callout) new PersistentUserCallout(callout); // eslint-disable-line no-new
PersistentUserCallout.factory(callout);
initGkeDropdowns();
}