in src/app/app.component.ts [116:193]
showUpdatePath() {
this.beforeRecommendations = [];
this.duringRecommendations = [];
this.afterRecommendations = [];
// Refuse to generate recommendations for downgrades
if (this.to.number < this.from.number) {
alert('We do not support downgrading versions of Angular.');
return;
}
const labelTitle = this.i18Service.transform('Angular Update Guide');
const labelBasic = this.i18Service.transform('Basic Apps');
const labelMedium = this.i18Service.transform('Medium Apps');
const labelAdvanced = this.i18Service.transform('Advanced Apps');
this.title =
`${labelTitle} | ${this.from.name} -> ${this.to.name}
${this.i18Service.transform('for')}
${
this.level < 2 ?
labelBasic : this.level < 3 ?
labelMedium : labelAdvanced
}`;
// Find applicable steps and organize them into before, during, and after upgrade
for (const step of this.steps) {
if (step.level <= this.level && step.necessaryAsOf > this.from.number) {
// Check Options
// Only show steps that don't have a required option
// Or when the user has a matching option selected
let skip = false;
for (const option of this.optionList) {
// Skip steps which require an option not set by the user.
if (step[option.id] && !this.options[option.id]) {
skip = true;
}
// Skip steps which require **not** using an option which **is** set
// by the user.
if (step[option.id] === false && this.options[option.id]) {
skip = true;
}
}
if (skip) {
continue;
}
// Render and replace variables
step.renderedStep = snarkdown(this.replaceVariables(getLocalizedAction(currentLocale.locale, step)));
// If you could do it before now, but didn't have to finish it before now
if (step.possibleIn <= this.from.number && step.necessaryAsOf >= this.from.number) {
this.beforeRecommendations.push(step);
// If you couldn't do it before now, and you must do it now
} else if (step.possibleIn > this.from.number && step.necessaryAsOf <= this.to.number) {
this.duringRecommendations.push(step);
} else if (step.possibleIn <= this.to.number) {
this.afterRecommendations.push(step);
} else {
}
}
}
// Update the URL so users can link to this transition
const searchParams = new URLSearchParams();
if (currentLocale.locale && this.saveLocale) {
searchParams.set('locale', currentLocale.locale);
}
if (this.level >= 2) {
searchParams.set('l', `${this.level}`);
}
searchParams.set('v', `${this.from.name}-${this.to.name}`);
this.location.replaceState('', searchParams.toString());
// Tell everyone how to upgrade for v6 or earlier
this.renderPreV6Instructions();
}