fix(editor): Trial banner does not disappear after sign out (no-changelog) (#6930)

to test in staging use version
`PR-6930-ado-990-trial-banner-does-not-disappear-after-sign-out`

<img width="875" alt="image"
src="https://github.com/n8n-io/n8n/assets/16496553/dfffe60f-bec3-4c48-bd9c-5990c68afa52">
This commit is contained in:
Ricardo Espinoza
2023-08-17 07:57:40 -04:00
committed by GitHub
parent ad15d3eae9
commit d3f01270c7
10 changed files with 181 additions and 37 deletions

View File

@@ -39,7 +39,7 @@ import BannerStack from '@/components/banners/BannerStack.vue';
import Modals from '@/components/Modals.vue';
import LoadingView from '@/views/LoadingView.vue';
import Telemetry from '@/components/Telemetry.vue';
import { CLOUD_TRIAL_CHECK_INTERVAL, HIRING_BANNER, LOCAL_STORAGE_THEME, VIEWS } from '@/constants';
import { HIRING_BANNER, LOCAL_STORAGE_THEME, VIEWS } from '@/constants';
import { userHelpers } from '@/mixins/userHelpers';
import { loadLanguage } from '@/plugins/i18n';
@@ -143,6 +143,12 @@ export default defineComponent({
console.log(HIRING_BANNER);
}
},
async initBanners() {
return this.uiStore.initBanners();
},
async checkForCloudPlanData() {
return this.cloudPlanStore.checkForCloudPlanData();
},
async initialize(): Promise<void> {
await this.initSettings();
await Promise.all([this.loginWithCookie(), this.initTemplates()]);
@@ -209,35 +215,6 @@ export default defineComponent({
window.document.body.classList.add(`theme-${theme}`);
}
},
async checkForCloudPlanData(): Promise<void> {
try {
await this.cloudPlanStore.getOwnerCurrentPlan();
if (!this.cloudPlanStore.userIsTrialing) return;
await this.cloudPlanStore.getInstanceCurrentUsage();
this.startPollingInstanceUsageData();
} catch {}
},
startPollingInstanceUsageData() {
const interval = setInterval(async () => {
try {
await this.cloudPlanStore.getInstanceCurrentUsage();
if (this.cloudPlanStore.trialExpired || this.cloudPlanStore.allExecutionsUsed) {
clearTimeout(interval);
return;
}
} catch {}
}, CLOUD_TRIAL_CHECK_INTERVAL);
},
async initBanners(): Promise<void> {
if (this.cloudPlanStore.userIsTrialing) {
await this.uiStore.dismissBanner('V1', 'temporary');
if (this.cloudPlanStore.trialExpired) {
this.uiStore.showBanner('TRIAL_OVER');
} else {
this.uiStore.showBanner('TRIAL');
}
}
},
async postAuthenticate() {
if (this.postAuthenticateDone) {
return;
@@ -262,9 +239,7 @@ export default defineComponent({
await this.redirectIfNecessary();
void this.checkForNewVersions();
await this.checkForCloudPlanData();
await this.initBanners();
void this.checkForCloudPlanData();
void this.initBanners();
void this.postAuthenticate();
this.loading = false;