Skip to content

Commit

Permalink
Remove the Take me to the area I last visited option from the login…
Browse files Browse the repository at this point in the history
… landing page preference

Removing this option because it's been broken for multiple releases and we haven't received complaints.

fixes #11268
  • Loading branch information
codyrancher committed Jan 30, 2025
1 parent 6eaaa6a commit 12f5167
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 112 deletions.
2 changes: 1 addition & 1 deletion cypress/support/commands/rancher-api-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Cypress.Commands.add('userPreferences', (preferences: Partial<UserPreferences> =
'group-by': 'none',
'home-page-cards': '',
'last-namespace': 'default',
'last-visited': '',
home: '',
'ns-by-cluster': '',
provisioner: '',
'read-whatsnew': '',
Expand Down
1 change: 0 additions & 1 deletion shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,6 @@ landing:
body: "You can change where you land when you login"
options:
homePage: Take me to the home page
lastVisited: Take me to the area I last visited
custom: "Take me to cluster:"
welcomeToRancher: 'Welcome to {vendor}'

Expand Down
15 changes: 9 additions & 6 deletions shell/components/LandingPagePreference.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export default {
async fetch() {
this.clusters = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER });
// 'last-visited' is no longer a supported option as of 2.11. I'm setting the value to home if it's set to last-visited. This block can be removed after 2.11.
const afterLoginRoute = this.$store.getters['prefs/get'](AFTER_LOGIN_ROUTE);
if (afterLoginRoute === 'last-visited') {
await this.$store.dispatch('prefs/set', { key: AFTER_LOGIN_ROUTE, value: 'home' });
}
},
data() {
Expand Down Expand Up @@ -48,10 +55,6 @@ export default {
label: this.t('landing.landingPrefs.options.homePage'),
value: 'home'
},
{
label: this.t('landing.landingPrefs.options.lastVisited'),
value: 'last-visited'
},
{
label: this.t('landing.landingPrefs.options.custom'),
value: 'dropdown'
Expand Down Expand Up @@ -118,14 +121,14 @@ export default {
<RadioButton
:label="option.label"
:val="false"
:value="afterLoginRoute=== 'home' || afterLoginRoute === 'last-visited'"
:value="afterLoginRoute=== 'home'"
:v-bind="$attrs"
@update:value="afterLoginRoute = false"
/>
<Select
v-model:value="routeFromDropdown"
:searchable="true"
:disabled="afterLoginRoute === 'home' || afterLoginRoute === 'last-visited'"
:disabled="afterLoginRoute === 'home'"
:clearable="false"
:options="routeDropdownOptions"
class="custom-page-options"
Expand Down
46 changes: 0 additions & 46 deletions shell/components/templates/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import AwsComplianceBanner from '@shell/components/AwsComplianceBanner';
import AzureWarning from '@shell/components/auth/AzureWarning';
import DraggableZone from '@shell/components/DraggableZone';
import { MANAGEMENT } from '@shell/config/types';
import isEqual from 'lodash/isEqual';
import { markSeenReleaseNotes } from '@shell/utils/version';
import PageHeaderActions from '@shell/mixins/page-actions';
import BrowserTabVisibility from '@shell/mixins/browser-tab-visibility';
import { getClusterFromRoute, getProductFromRoute } from '@shell/utils/router';
import { BOTTOM } from '@shell/utils/position';
import SideNav from '@shell/components/SideNav';
import { BLANK_CLUSTER } from '@shell/store/store-types.js';
const SET_LOGIN_ACTION = 'set-as-login';
Expand Down Expand Up @@ -115,35 +113,6 @@ export default {
},
watch: {
clusterId(a, b) {
if ( !isEqual(a, b) ) {
// Store the last visited route when the cluster changes
this.setClusterAsLastRoute();
}
},
async currentProduct(a, b) {
if ( !isEqual(a, b) ) {
if ((a.inStore !== b.inStore || a.inStore !== 'cluster') && this.clusterId && a.name) {
const route = {
name: 'c-cluster-product',
params: {
cluster: this.clusterId,
product: a.name,
}
};
await this.$store.dispatch('prefs/setLastVisited', route);
}
}
},
},
async created() {
await this.$store.dispatch('prefs/setLastVisited', this.$route);
},
mounted() {
this.wmPin = window.localStorage.getItem('wm-pin') || BOTTOM;
Expand All @@ -159,21 +128,6 @@ export default {
},
methods: {
async setClusterAsLastRoute() {
if (!this.clusterId || this.clusterId === BLANK_CLUSTER) {
return;
}
const route = {
name: this.$route.name,
params: {
...this.$route.params,
cluster: this.clusterId,
}
};
await this.$store.dispatch('prefs/setLastVisited', route);
},
handlePageAction(action) {
if (action.action === SET_LOGIN_ACTION) {
this.afterLoginRoute = this.getLoginRoute();
Expand Down
2 changes: 0 additions & 2 deletions shell/pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ export default defineComponent({
},
async created() {
// Update last visited on load
await this.$store.dispatch('prefs/setLastVisited', { name: 'home' });
markSeenReleaseNotes(this.$store);
},
Expand Down
57 changes: 2 additions & 55 deletions shell/store/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export const DEV = create('dev', false, { parseJSON });
export const VIEW_IN_API = create('view-in-api', false, { parseJSON, inheritFrom: DEV });
export const ALL_NAMESPACES = create('all-namespaces', false, { parseJSON, inheritFrom: DEV });
export const THEME_SHORTCUT = create('theme-shortcut', false, { parseJSON, inheritFrom: DEV });
export const LAST_VISITED = create('last-visited', 'home', { parseJSON });
export const SEEN_WHATS_NEW = create('seen-whatsnew', '', { parseJSON });
export const READ_WHATS_NEW = create('read-whatsnew', '', { parseJSON });
export const AFTER_LOGIN_ROUTE = create('after-login-route', 'home', { parseJSON } );
Expand Down Expand Up @@ -212,18 +211,9 @@ export const getters = {
}

switch (true) {
case (afterLoginRoutePref === 'home'):
// 'last-visited' was a former value that has been removed in 2.11. After 2.11 it's safe to remove if you come across this.
case (afterLoginRoutePref === 'home' || afterLoginRoutePref === 'last-visited'):
return { name: 'home' };
case (afterLoginRoutePref === 'last-visited'): {
const lastVisitedPref = getters['get'](LAST_VISITED);

if (lastVisitedPref) {
return lastVisitedPref;
}
const clusterPref = getters['get'](CLUSTER);

return { name: 'c-cluster-explorer', params: { product: 'explorer', cluster: clusterPref } };
}
case (!!afterLoginRoutePref.match(/.+-dashboard$/)):
{
const clusterId = afterLoginRoutePref.split('-dashboard')[0];
Expand Down Expand Up @@ -478,24 +468,6 @@ export const actions = {
return server;
},

setLastVisited({ state, dispatch, getters }, route) {
if (!route) {
return;
}

// Only save the last visited page if the user has that set as the login route preference
const afterLoginRoutePref = getters['get'](AFTER_LOGIN_ROUTE);
const doNotTrackLastVisited = typeof afterLoginRoutePref !== 'string' || afterLoginRoutePref !== 'last-visited';

if (doNotTrackLastVisited) {
return;
}

const toSave = getLoginRoute(route);

return dispatch('set', { key: LAST_VISITED, value: toSave });
},

toggleTheme({ getters, dispatch }) {
const value = getters[THEME] === 'light' ? 'dark' : 'light';

Expand Down Expand Up @@ -523,28 +495,3 @@ export const actions = {
}
}
};

function getLoginRoute(route) {
let parts = route.name?.split('-') || [];
const params = {};
const routeParams = route.params || {};

// Find the 'resource' part of the route, if it is there
const index = parts.findIndex((p) => p === 'resource');

if (index >= 0) {
parts = parts.slice(0, index);
}

// Just keep the params that are needed
parts.forEach((param) => {
if (routeParams[param]) {
params[param] = routeParams[param];
}
});

return {
name: parts.join('-'),
params
};
}
1 change: 0 additions & 1 deletion shell/types/resources/userPreferences.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface UserPreferences {
'group-by': string,
'home-page-cards': string,
'last-namespace': string,
'last-visited': string,
'ns-by-cluster': string,
provisioner: string,
'read-whatsnew': string,
Expand Down

0 comments on commit 12f5167

Please sign in to comment.