You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2021/10/20 10:37:57 UTC
[GitHub] [brooklyn-ui] jathanasiou opened a new pull request #298: Enhancement/composer persist selector state
jathanasiou opened a new pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298
Adding session persistence for the composer Graphical view's:
- View mode (list, compact list etc.
- query/search term
- item group (entities, policies etc.)
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733646232
##########
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:
Fix verified.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733620167
##########
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 `sessionStorage` across UI components.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733631777
##########
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:
My message here is either we move to `browserStorage` everywhere or at least leave TODO comments in other places indicating migration path. Or, we keep using `sessionStorage` everywhere to keep it all consistent.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733620167
##########
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.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733629158
##########
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:
https://user-images.githubusercontent.com/81319331/138278149-700cbb17-265f-4eff-ac79-d1ad715d5fb8.mov
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] ahgittin commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
ahgittin commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r734342565
##########
File path: ui-modules/utils/browserStorage/index.js
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const KEYS = {
+ COMPOSER_QUERY: 'composerQuery',
+ SECTION: 'composerSection',
+ VIEW_MODE: 'composerViewMode',
+}
+
+const getterFor = (storageType, key) => (parseAsJSON=false) => {
+ let result;
+ try {
+ result = parseAsJSON
+ ? JSON.parse(storageType.getItem(key))
+ : storageType.getItem(key);
+ } catch (err) {
+ result = undefined;
+ }
+ return result;
+}
+
+const setterFor = (storageType, key) => (newValue, isJSON) =>
+ storageType.setItem(key, isJSON ? JSON.stringify(newValue) : newValue)
+
+const storageFor = (storageType) => ({
+ getComposerViewMode: getterFor(storageType, KEYS.VIEW_MODE),
+ setComposerViewMode: setterFor(storageType, KEYS.VIEW_MODE),
+ getComposerSection: getterFor(storageType, KEYS.SECTION),
+ setComposerSection: setterFor(storageType, KEYS.SECTION),
+ getComposerSearch: getterFor(storageType, KEYS.COMPOSER_QUERY),
+ setComposerSearch: setterFor(storageType, KEYS.COMPOSER_QUERY),
+})
+
+export const session = storageFor(sessionStorage);
+export const local = storageFor(localStorage);
Review comment:
sometimes it's nice to see how to do something in future -- but worth a comment eg `// not used, here in case we need this in future`
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733619264
##########
File path: ui-modules/utils/browserStorage/index.js
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const KEYS = {
+ COMPOSER_QUERY: 'composerQuery',
+ SECTION: 'composerSection',
+ VIEW_MODE: 'composerViewMode',
+}
+
+const getterFor = (storageType, key) => (parseAsJSON=false) => {
+ let result;
+ try {
+ result = parseAsJSON
+ ? JSON.parse(storageType.getItem(key))
+ : storageType.getItem(key);
+ } catch (err) {
+ result = undefined;
+ }
+ return result;
+}
+
+const setterFor = (storageType, key) => (newValue, isJSON) =>
+ storageType.setItem(key, isJSON ? JSON.stringify(newValue) : newValue)
+
+const storageFor = (storageType) => ({
+ getComposerViewMode: getterFor(storageType, KEYS.VIEW_MODE),
+ setComposerViewMode: setterFor(storageType, KEYS.VIEW_MODE),
+ getComposerSection: getterFor(storageType, KEYS.SECTION),
+ setComposerSection: setterFor(storageType, KEYS.SECTION),
+ getComposerSearch: getterFor(storageType, KEYS.COMPOSER_QUERY),
+ setComposerSearch: setterFor(storageType, KEYS.COMPOSER_QUERY),
+})
+
+export const session = storageFor(sessionStorage);
+export const local = storageFor(localStorage);
Review comment:
Local storage is not used.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733628349
##########
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.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733644940
##########
File path: ui-modules/utils/browserStorage/index.js
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const KEYS = {
+ COMPOSER_QUERY: 'composerQuery',
+ SECTION: 'composerSection',
+ VIEW_MODE: 'composerViewMode',
+}
+
+const getterFor = (storageType, key) => (parseAsJSON=false) => {
+ let result;
+ try {
+ result = parseAsJSON
+ ? JSON.parse(storageType.getItem(key))
+ : storageType.getItem(key);
+ } catch (err) {
+ result = undefined;
+ }
+ return result;
+}
+
+const setterFor = (storageType, key) => (newValue, isJSON) =>
+ storageType.setItem(key, isJSON ? JSON.stringify(newValue) : newValue)
+
+const storageFor = (storageType) => ({
+ getComposerViewMode: getterFor(storageType, KEYS.VIEW_MODE),
+ setComposerViewMode: setterFor(storageType, KEYS.VIEW_MODE),
+ getComposerSection: getterFor(storageType, KEYS.SECTION),
+ setComposerSection: setterFor(storageType, KEYS.SECTION),
+ getComposerSearch: getterFor(storageType, KEYS.COMPOSER_QUERY),
+ setComposerSearch: setterFor(storageType, KEYS.COMPOSER_QUERY),
+})
+
+export const session = storageFor(sessionStorage);
+export const local = storageFor(localStorage);
Review comment:
No need to keep unused code, unless it's in WIP stage.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] algairim commented on pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
algairim commented on pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#issuecomment-948587763
Looks good, apart from lonely `browserStorage`.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] ahgittin commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
ahgittin commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r734342817
##########
File path: ui-modules/utils/browserStorage/index.js
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const KEYS = {
+ COMPOSER_QUERY: 'composerQuery',
+ SECTION: 'composerSection',
+ VIEW_MODE: 'composerViewMode',
Review comment:
these don't belong here -- they are for composer, not for utils
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] ahgittin commented on pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
ahgittin commented on pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#issuecomment-949409037
I don't feel strongly about `browserSession` being a util module or using the storage api directly. maybe slight preference for the former (what you've done).
but worth a comment that `// some places use browser storage APIs directly; TODO update those to use this`
however as noted, module-specific semantics should _not_ be in the `utils`. so maybe API should be `getSession(KEY)` where `KEY` is defined _locally_ in each module/directive not in `utils/.../xxx.KEYS`
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
jathanasiou commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733624627
##########
File path: ui-modules/utils/browserStorage/index.js
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const KEYS = {
+ COMPOSER_QUERY: 'composerQuery',
+ SECTION: 'composerSection',
+ VIEW_MODE: 'composerViewMode',
+}
+
+const getterFor = (storageType, key) => (parseAsJSON=false) => {
+ let result;
+ try {
+ result = parseAsJSON
+ ? JSON.parse(storageType.getItem(key))
+ : storageType.getItem(key);
+ } catch (err) {
+ result = undefined;
+ }
+ return result;
+}
+
+const setterFor = (storageType, key) => (newValue, isJSON) =>
+ storageType.setItem(key, isJSON ? JSON.stringify(newValue) : newValue)
+
+const storageFor = (storageType) => ({
+ getComposerViewMode: getterFor(storageType, KEYS.VIEW_MODE),
+ setComposerViewMode: setterFor(storageType, KEYS.VIEW_MODE),
+ getComposerSection: getterFor(storageType, KEYS.SECTION),
+ setComposerSection: setterFor(storageType, KEYS.SECTION),
+ getComposerSearch: getterFor(storageType, KEYS.COMPOSER_QUERY),
+ setComposerSearch: setterFor(storageType, KEYS.COMPOSER_QUERY),
+})
+
+export const session = storageFor(sessionStorage);
+export const local = storageFor(localStorage);
Review comment:
True, added here for future-proof convenience. Think it's preferrable to remove it?
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou edited a comment on pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
jathanasiou edited a comment on pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#issuecomment-949497151
Opted to revert to regular `sessionStorage` as having the keys in their respective modules would diminish the benefits of a "storage service" at this scale. Might be worth doing in the future though.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou commented on pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
jathanasiou commented on pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#issuecomment-949497151
Opted to reverted to regular `sessionStorage` as having the keys in their respective modules would diminish the benefits of a "storage service" at this scale. Might be worth doing in the future though.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
jathanasiou commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r734423466
##########
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:
After feedback, I removed the module and reverted to regular `sessionStorage` usage.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] iuliana merged pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
iuliana merged pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [brooklyn-ui] jathanasiou commented on a change in pull request #298: Enhancement/composer persist selector state
Posted by GitBox <gi...@apache.org>.
jathanasiou commented on a change in pull request #298:
URL: https://github.com/apache/brooklyn-ui/pull/298#discussion_r733637507
##########
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:
@algairim Fixed in 57bbd69, `undefined` was being stored to the session storage which was not intended.
--
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-unsubscribe@brooklyn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org