PLT-3841/PLT-3883 Fixed detection of local storage, persist system console team list after logout (#3849)
* PLT-3841 Fixed check to see if local/session storage is available * PLT-3883 Saved selected teams in the admin console across a logout * Clarified the code that checks if local storage is available
Этот коммит содержится в:
коммит произвёл
enahum
родитель
ca351b617f
Коммит
3c50442d04
@@ -140,7 +140,7 @@ class AdminStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSelectedTeams() {
|
getSelectedTeams() {
|
||||||
const result = BrowserStore.getItem('seleted_teams');
|
const result = BrowserStore.getItem('selected_teams');
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ class AdminStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveSelectedTeams(teams) {
|
saveSelectedTeams(teams) {
|
||||||
BrowserStore.setItem('seleted_teams', teams);
|
BrowserStore.setItem('selected_teams', teams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ function getPrefix() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BrowserStoreClass {
|
class BrowserStoreClass {
|
||||||
|
constructor() {
|
||||||
|
this.hasCheckedLocalStorage = false;
|
||||||
|
this.localStorageSupported = false;
|
||||||
|
}
|
||||||
|
|
||||||
setItem(name, value) {
|
setItem(name, value) {
|
||||||
this.setGlobalItem(getPrefix() + name, value);
|
this.setGlobalItem(getPrefix() + name, value);
|
||||||
}
|
}
|
||||||
@@ -145,6 +150,7 @@ class BrowserStoreClass {
|
|||||||
const logoutId = sessionStorage.getItem('__logout__');
|
const logoutId = sessionStorage.getItem('__logout__');
|
||||||
const serverVersion = this.getLastServerVersion();
|
const serverVersion = this.getLastServerVersion();
|
||||||
const landingPageSeen = this.hasSeenLandingPage();
|
const landingPageSeen = this.hasSeenLandingPage();
|
||||||
|
const selectedTeams = this.getItem('selected_teams');
|
||||||
|
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -160,23 +166,27 @@ class BrowserStoreClass {
|
|||||||
if (landingPageSeen) {
|
if (landingPageSeen) {
|
||||||
this.setLandingPageSeen(landingPageSeen);
|
this.setLandingPageSeen(landingPageSeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedTeams) {
|
||||||
|
this.setItem('selected_teams', selectedTeams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isLocalStorageSupported() {
|
isLocalStorageSupported() {
|
||||||
if (this.checkedLocalStorageSupported !== '') {
|
if (this.hasCheckedLocalStorage) {
|
||||||
return this.checkedLocalStorageSupported;
|
return this.localStorageSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.localStorageSupported = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
localStorage.setItem('__testLocal__', '1');
|
localStorage.setItem('__testLocal__', '1');
|
||||||
if (localStorage.getItem('__testLocal__') !== '1') {
|
if (localStorage.getItem('__testLocal__') === '1') {
|
||||||
this.checkedLocalStorageSupported = false;
|
this.localStorageSupported = true;
|
||||||
}
|
}
|
||||||
localStorage.removeItem('__testLocal__', '1');
|
localStorage.removeItem('__testLocal__', '1');
|
||||||
|
|
||||||
this.checkedLocalStorageSupported = true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.checkedLocalStorageSupported = false;
|
this.localStorageSupported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -187,7 +197,9 @@ class BrowserStoreClass {
|
|||||||
browserHistory.push(window.location.origin + '/error?title=' + notSupportedParams.title + '&message=' + notSupportedParams.message);
|
browserHistory.push(window.location.origin + '/error?title=' + notSupportedParams.title + '&message=' + notSupportedParams.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.checkedLocalStorageSupported;
|
this.hasCheckedLocalStorage = true;
|
||||||
|
|
||||||
|
return this.localStorageSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasSeenLandingPage() {
|
hasSeenLandingPage() {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user