jathanasiou commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733629574



##########
File path: 
ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
##########
@@ -98,7 +104,17 @@ export function catalogSelectorDirective() {
         $scope.viewModes = PALETTE_VIEW_MODES;
         $scope.viewOrders = PALETTE_VIEW_ORDERS;
         if (!$scope.state) $scope.state = {};
-        if (!$scope.state.viewMode) $scope.state.viewMode = 
PALETTE_VIEW_MODES.normal;
+        if (!$scope.state.viewMode) {
+            const savedViewMode = sessionStore.getComposerViewMode(true);
+            $scope.state.viewMode = ((typeof savedViewMode === 'object') && 
(savedViewMode !== null))
+                ? savedViewMode
+                : PALETTE_VIEW_MODES.normal
+        };
+
+        if(!$scope.search) {
+            const savedSearch = sessionStore.getComposerSearch();
+            if (typeof savedSearch === 'string' && savedSearch.length) 
$scope.search = savedSearch;

Review comment:
       > 
   > 
   > Add `else` condition to initialise it with an empty string, otherwise 
there is "undefined" displayed when switching between catalog sections.
   
   Good catch. Thought that the placeholder text would take over with 
`undefined` but it seems not, will address.

##########
File path: 
ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
##########
@@ -21,6 +21,7 @@ import {EntityFamily} from '../util/model/entity.model';
 import template from './catalog-selector.template.html';
 import footerTemplate from './catalog-selector-palette-footer.html';
 import { distanceInWordsToNow } from 'date-fns';
+import { session as sessionStore } from 'brooklyn-ui-utils/browserStorage';

Review comment:
       > There is a `sessionStorage` used across UI components.
   
   AFAIK `sessionStorage` is the [native browser 
interface](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)
 for that cache. I added the `browserStorage` module as an abstraction for it 
in order to provide a centralized way of interacting with it via restricted 
operations that have managed keys for that store, including (de)serializing of 
JSON objects.
   
   If preferred, we could use the regular `sessionStorage` though that would 
add out-of-scope logic to modules like the composer and be more error-prone.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to