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
Этот коммит содержится в:
Harrison Healey
2016-08-22 20:07:37 -04:00
коммит произвёл enahum
родитель ca351b617f
Коммит 3c50442d04
2 изменённых файлов: 22 добавлений и 10 удалений

Просмотреть файл

@@ -140,7 +140,7 @@ class AdminStoreClass extends EventEmitter {
}
getSelectedTeams() {
const result = BrowserStore.getItem('seleted_teams');
const result = BrowserStore.getItem('selected_teams');
if (!result) {
return {};
}
@@ -148,7 +148,7 @@ class AdminStoreClass extends EventEmitter {
}
saveSelectedTeams(teams) {
BrowserStore.setItem('seleted_teams', teams);
BrowserStore.setItem('selected_teams', teams);
}
}

Просмотреть файл

@@ -20,6 +20,11 @@ function getPrefix() {
}
class BrowserStoreClass {
constructor() {
this.hasCheckedLocalStorage = false;
this.localStorageSupported = false;
}
setItem(name, value) {
this.setGlobalItem(getPrefix() + name, value);
}
@@ -145,6 +150,7 @@ class BrowserStoreClass {
const logoutId = sessionStorage.getItem('__logout__');
const serverVersion = this.getLastServerVersion();
const landingPageSeen = this.hasSeenLandingPage();
const selectedTeams = this.getItem('selected_teams');
sessionStorage.clear();
localStorage.clear();
@@ -160,23 +166,27 @@ class BrowserStoreClass {
if (landingPageSeen) {
this.setLandingPageSeen(landingPageSeen);
}
if (selectedTeams) {
this.setItem('selected_teams', selectedTeams);
}
}
isLocalStorageSupported() {
if (this.checkedLocalStorageSupported !== '') {
return this.checkedLocalStorageSupported;
if (this.hasCheckedLocalStorage) {
return this.localStorageSupported;
}
this.localStorageSupported = false;
try {
localStorage.setItem('__testLocal__', '1');
if (localStorage.getItem('__testLocal__') !== '1') {
this.checkedLocalStorageSupported = false;
if (localStorage.getItem('__testLocal__') === '1') {
this.localStorageSupported = true;
}
localStorage.removeItem('__testLocal__', '1');
this.checkedLocalStorageSupported = true;
} catch (e) {
this.checkedLocalStorageSupported = false;
this.localStorageSupported = false;
}
try {
@@ -187,7 +197,9 @@ class BrowserStoreClass {
browserHistory.push(window.location.origin + '/error?title=' + notSupportedParams.title + '&message=' + notSupportedParams.message);
}
return this.checkedLocalStorageSupported;
this.hasCheckedLocalStorage = true;
return this.localStorageSupported;
}
hasSeenLandingPage() {