From c0642f393ff895005a0c8bb4b6a03295866540a7 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 15 Oct 2021 10:25:09 -0700 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20icon=20suppo?= =?UTF-8?q?rt=20to=20input=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/rose/form/input/index.hbs | 28 +++++++++++-------- .../rose/form/input/index.stories.mdx | 5 ++++ .../styles/rose/components/form/_input.scss | 12 ++++++++ .../components/rose/form/input-test.js | 5 ++++ .../templates/scopes/scope/sessions/index.hbs | 1 - 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index 9bf8003e3..e9f1c6ced 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -34,16 +34,22 @@ {{/if}} - - +
+ {{#if @icon}} + + {{/if}} + +
{{yield (hash errors=(component 'rose/form/errors' id=(concat 'errors-' this.id) @@ -51,4 +57,4 @@ )}} -{{/if}} +{{/if}} \ No newline at end of file diff --git a/addons/rose/addon/components/rose/form/input/index.stories.mdx b/addons/rose/addon/components/rose/form/input/index.stories.mdx index 041507976..c9decc5fd 100644 --- a/addons/rose/addon/components/rose/form/input/index.stories.mdx +++ b/addons/rose/addon/components/rose/form/input/index.stories.mdx @@ -18,6 +18,7 @@ Renders a simple form input. @helperText="Enter your email" @error={{false}} @disabled={{false}} + @icon='flight-icons/svg/search-16' readonly={{false}} /> ``` @@ -70,6 +71,10 @@ Or a fully contextual component without a wrapper, for maximum flexibility. helperText: text('helperText', 'Helper text'), disabled: boolean('disabled', false), 'read-only': boolean('readonly', false), + icon: select('icon', { + 'flight-icons/svg/search-16': 'flight-icons/svg/search-16', + }, + ), } }} diff --git a/addons/rose/addon/styles/rose/components/form/_input.scss b/addons/rose/addon/styles/rose/components/form/_input.scss index bdfd5fff9..7a397d484 100644 --- a/addons/rose/addon/styles/rose/components/form/_input.scss +++ b/addons/rose/addon/styles/rose/components/form/_input.scss @@ -5,6 +5,18 @@ margin-bottom: sizing.rems(m); } +.rose-input-icon-wrapper { + position: relative; + .rose-icon.medium { + position: absolute; + left: 10px; + top: 10px; + } + .rose-form-input-field { + padding-left: 30px; + } +} + .rose-form-input-field { @include type.type(m); display: inline-block; diff --git a/addons/rose/tests/integration/components/rose/form/input-test.js b/addons/rose/tests/integration/components/rose/form/input-test.js index 2f6c6cc56..d053698ab 100644 --- a/addons/rose/tests/integration/components/rose/form/input-test.js +++ b/addons/rose/tests/integration/components/rose/form/input-test.js @@ -58,6 +58,11 @@ module('Integration | Component | rose/form/input', function (hooks) { assert.ok(await find('[disabled]')); }); + test('it supports an icon using @icon', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + }); + test('it supports readonly attribute', async function (assert) { await render(hbs``); assert.ok(await find('[readonly]')); diff --git a/ui/admin/app/templates/scopes/scope/sessions/index.hbs b/ui/admin/app/templates/scopes/scope/sessions/index.hbs index 297c68a70..2c1e54891 100644 --- a/ui/admin/app/templates/scopes/scope/sessions/index.hbs +++ b/ui/admin/app/templates/scopes/scope/sessions/index.hbs @@ -15,7 +15,6 @@ {{#if @model}} - From 2a0174505f3f3a2842acae256d03179966b47bf5 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 15 Oct 2021 10:38:39 -0700 Subject: [PATCH 02/10] =?UTF-8?q?chore:=20=F0=9F=A4=96=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/components/rose/form/input/index.hbs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index e9f1c6ced..bb29c2335 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -35,11 +35,11 @@ {{/if}}
- {{#if @icon}} - - {{/if}} + {{#if @icon}} + + {{/if}} Date: Fri, 15 Oct 2021 10:48:56 -0700 Subject: [PATCH 03/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20undod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/templates/scopes/scope/sessions/index.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/admin/app/templates/scopes/scope/sessions/index.hbs b/ui/admin/app/templates/scopes/scope/sessions/index.hbs index 2c1e54891..297c68a70 100644 --- a/ui/admin/app/templates/scopes/scope/sessions/index.hbs +++ b/ui/admin/app/templates/scopes/scope/sessions/index.hbs @@ -15,6 +15,7 @@ {{#if @model}} + From 1dc4c396f8288f55c824c85847f797cdf74c5d56 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 18 Oct 2021 13:45:23 -0700 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20class=20name=20upda?= =?UTF-8?q?te,=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/components/rose/form/input/index.hbs | 2 +- .../rose/addon/components/rose/form/input/index.stories.mdx | 1 + addons/rose/addon/styles/rose/components/form/_input.scss | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index bb29c2335..e31ab046d 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -34,7 +34,7 @@ {{/if}} -
+
{{#if @icon}} diff --git a/addons/rose/addon/styles/rose/components/form/_input.scss b/addons/rose/addon/styles/rose/components/form/_input.scss index 7a397d484..cc9b12904 100644 --- a/addons/rose/addon/styles/rose/components/form/_input.scss +++ b/addons/rose/addon/styles/rose/components/form/_input.scss @@ -5,9 +5,9 @@ margin-bottom: sizing.rems(m); } -.rose-input-icon-wrapper { +.rose-input-wrapper { position: relative; - .rose-icon.medium { + .rose-icon { position: absolute; left: 10px; top: 10px; From 5c091e1b72c4e47a46d89cc916813486a67627db Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 18 Oct 2021 14:55:40 -0700 Subject: [PATCH 05/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20input=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/rose/form/input/index.hbs | 2 +- .../rose/form/input/index.stories.mdx | 54 +++++++++++++++++-- .../styles/rose/components/form/_input.scss | 2 +- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index e31ab046d..efbd55a4e 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -34,7 +34,7 @@ {{/if}} -
+
{{#if @icon}} `, context: { @@ -71,15 +72,60 @@ Or a fully contextual component without a wrapper, for maximum flexibility. helperText: text('helperText', 'Helper text'), disabled: boolean('disabled', false), 'read-only': boolean('readonly', false), - icon: select('icon', { - 'flight-icons/svg/search-16': 'flight-icons/svg/search-16', - }, - 'flight-icons/svg/search-16 + icon: select( + 'icon', + { + 'none': null, + 'flight-icons/svg/search-16': 'flight-icons/svg/search-16', + }, + 'flight-icons/svg/search-16', ), } }} + + {{ + template: hbs` + + `, + context: { + type: select( + 'type', + { + text: 'text', + email: 'email', + number: 'number', + password: 'password', + }, + 'text' + ), + label: text('label', 'Label'), + helperText: text('helperText', 'Helper text'), + disabled: boolean('disabled', false), + 'read-only': boolean('readonly', false), + icon: select( + 'icon', + { + 'none': null, + 'flight-icons/svg/search-16': 'flight-icons/svg/search-16', + }, + null + ), + } + }} + + + {{ template: hbs` diff --git a/addons/rose/addon/styles/rose/components/form/_input.scss b/addons/rose/addon/styles/rose/components/form/_input.scss index cc9b12904..cade58db3 100644 --- a/addons/rose/addon/styles/rose/components/form/_input.scss +++ b/addons/rose/addon/styles/rose/components/form/_input.scss @@ -5,7 +5,7 @@ margin-bottom: sizing.rems(m); } -.rose-input-wrapper { +.rose-input-wrapper.icon { position: relative; .rose-icon { position: absolute; From 18025e749324b65f38b6526fdba5f05aa7d3c2c7 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 18 Oct 2021 15:02:42 -0700 Subject: [PATCH 06/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20undo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rose/form/input/index.stories.mdx | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.stories.mdx b/addons/rose/addon/components/rose/form/input/index.stories.mdx index 45324c820..a0b6080f2 100644 --- a/addons/rose/addon/components/rose/form/input/index.stories.mdx +++ b/addons/rose/addon/components/rose/form/input/index.stories.mdx @@ -84,48 +84,6 @@ Or a fully contextual component without a wrapper, for maximum flexibility. }} - - {{ - template: hbs` - - `, - context: { - type: select( - 'type', - { - text: 'text', - email: 'email', - number: 'number', - password: 'password', - }, - 'text' - ), - label: text('label', 'Label'), - helperText: text('helperText', 'Helper text'), - disabled: boolean('disabled', false), - 'read-only': boolean('readonly', false), - icon: select( - 'icon', - { - 'none': null, - 'flight-icons/svg/search-16': 'flight-icons/svg/search-16', - }, - null - ), - } - }} - - - {{ template: hbs` From f1a3a3bfb20b99cb086c76c786d2dfb6c37ceae7 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Mon, 18 Oct 2021 15:11:28 -0700 Subject: [PATCH 07/10] Update index.hbs --- addons/rose/addon/components/rose/form/input/index.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index efbd55a4e..7f5747ac2 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -57,4 +57,4 @@ )}}
-{{/if}} \ No newline at end of file +{{/if}} From 71108c35099967685b65c8e312943b17e9823656 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 19 Oct 2021 11:23:43 -0400 Subject: [PATCH 08/10] chore: implement initial boolean expression filter for mirage mocks in sessions index --- addons/api/mirage/config.js | 11 +++++++---- addons/api/mirage/helpers/bexpr-filter.js | 17 +++++++++++++++++ addons/api/package.json | 1 + addons/core/package.json | 1 + ui/admin/package.json | 1 + ui/desktop/package.json | 1 + yarn.lock | 18 ++++++++++++++++++ 7 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 addons/api/mirage/helpers/bexpr-filter.js diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 68c7f6b94..5d87801d7 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -4,6 +4,7 @@ import { authHandler, deauthHandler } from './route-handlers/auth'; import { pickRandomStatusString } from './factories/session'; import { Response } from 'miragejs'; import initializeMockIPC from './scenarios/ipc'; +import makeBooleanFilter from './helpers/bexpr-filter'; export default function () { initializeMockIPC(this); @@ -408,7 +409,8 @@ export default function () { this.get( '/sessions', - function ({ sessions }, { queryParams: { scope_id, recursive } }) { + function ({ sessions }, { queryParams: { scope_id, recursive, filter } }) { + let resultSet; // To simulate changes to `session.status` that may occur in the backend, // we quietly randomize the value of the field on GET. // To populate sessions for logged in user, @@ -427,9 +429,9 @@ export default function () { }); } if (recursive && scope_id === 'global') { - return sessions.all(); + resultSet = sessions.all(); } else if (recursive) { - return sessions.where((session) => { + resultSet = sessions.where((session) => { const sessionModel = sessions.find(session.id); return ( session.scopeId === scope_id || @@ -437,7 +439,8 @@ export default function () { ); }); } - return sessions.where((session) => session.scopeId === scope_id); + resultSet = sessions.where((session) => session.scopeId === scope_id); + return resultSet.filter(makeBooleanFilter(filter)); } ); this.get('/sessions/:id', function ({ sessions }, { params: { id } }) { diff --git a/addons/api/mirage/helpers/bexpr-filter.js b/addons/api/mirage/helpers/bexpr-filter.js new file mode 100644 index 000000000..b8e41e63a --- /dev/null +++ b/addons/api/mirage/helpers/bexpr-filter.js @@ -0,0 +1,17 @@ +import { makeEvaluator } from 'js-bexpr'; + +/** + * Creates a filter function that operates on a single object, which itself + * returns the result of evaluating the expression against the object. + */ +export default (expression) => { + if (expression) { + const evaluator = makeEvaluator(expression); + // Since API query selectors begin with `/item`, the instance is wrapped. + return (item) => evaluator({ item }); + } else { + // If no expression was passed, always return true, + // thus filtering out none. + return () => true; + } +}; diff --git a/addons/api/package.json b/addons/api/package.json index 8be07dd77..1012dd943 100644 --- a/addons/api/package.json +++ b/addons/api/package.json @@ -33,6 +33,7 @@ "ember-fetch": "^8.1.1" }, "devDependencies": { + "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "@babel/core": "^7.15.8", "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.4.2", diff --git a/addons/core/package.json b/addons/core/package.json index faf6a1be3..199973f38 100644 --- a/addons/core/package.json +++ b/addons/core/package.json @@ -41,6 +41,7 @@ "rose": "*" }, "devDependencies": { + "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.4.2", "@glimmer/component": "^1.0.4", diff --git a/ui/admin/package.json b/ui/admin/package.json index 43af20716..215991910 100644 --- a/ui/admin/package.json +++ b/ui/admin/package.json @@ -35,6 +35,7 @@ "ember-named-blocks-polyfill": "^0.2.4" }, "devDependencies": { + "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "@babel/core": "^7.15.5", "@ember/optional-features": "^2.0.0", "@ember/render-modifiers": "^1.0.2", diff --git a/ui/desktop/package.json b/ui/desktop/package.json index 6c6c7a3d3..590e92035 100755 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -53,6 +53,7 @@ "ember-named-blocks-polyfill": "^0.2.4" }, "devDependencies": { + "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "@doyensec/electronegativity": "^1.9.1", "@ember/optional-features": "^2.0.0", "@ember/render-modifiers": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index 42ce135bb..d9cd99d55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12051,6 +12051,11 @@ for-in@^1.0.2: resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= +foreach@^2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -14674,6 +14679,12 @@ jquery@^3.5.0: resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470" integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw== +js-bexpr@hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1: + version "0.0.0" + resolved "https://codeload.github.com/hashicorp/js-bexpr/tar.gz/9b4a4b54d85eba67fdfc0990133d1518d890b1e1" + dependencies: + json-pointer "^0.6.1" + js-string-escape@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" @@ -14843,6 +14854,13 @@ json-parse-even-better-errors@^2.3.0: resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== +json-pointer@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/json-pointer/-/json-pointer-0.6.1.tgz#3c6caa6ac139e2599f5a1659d39852154015054d" + integrity sha512-3OvjqKdCBvH41DLpV4iSt6v2XhZXV1bPB4OROuknvUXI7ZQNofieCPkmE26stEJ9zdQuvIxDHCuYhfgxFAAs+Q== + dependencies: + foreach "^2.0.4" + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" From 0c20ccfde0bfb00b5b447bf1f200647960d3d147 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 21 Oct 2021 09:08:50 -0400 Subject: [PATCH 09/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20quick-serialize=20r?= =?UTF-8?q?ecords=20before=20applying=20boolean=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/mirage/config.js | 3 ++- addons/api/mirage/helpers/bexpr-filter.js | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 5d87801d7..b1481adf9 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -438,8 +438,9 @@ export default function () { sessionModel?.scope?.scope?.id === scope_id ); }); + } else { + resultSet = sessions.where((session) => session.scopeId === scope_id); } - resultSet = sessions.where((session) => session.scopeId === scope_id); return resultSet.filter(makeBooleanFilter(filter)); } ); diff --git a/addons/api/mirage/helpers/bexpr-filter.js b/addons/api/mirage/helpers/bexpr-filter.js index b8e41e63a..e2cffef02 100644 --- a/addons/api/mirage/helpers/bexpr-filter.js +++ b/addons/api/mirage/helpers/bexpr-filter.js @@ -1,4 +1,19 @@ import { makeEvaluator } from 'js-bexpr'; +import { underscore } from '@ember/string'; + +/** + * Because Mirage, a record cannot be serialized outside of a route handler + * context. Here is a quick and dirty attempt to serialize attribute names + * to underscore format. This is not entirely realistic, but may suffice. + */ +const quickSerialize = (item) => { + const json = item.toJSON(); + Object.keys(json).forEach((key) => { + const newKey = underscore(key); + json[newKey] = json[key]; + }); + return json; +}; /** * Creates a filter function that operates on a single object, which itself @@ -8,7 +23,10 @@ export default (expression) => { if (expression) { const evaluator = makeEvaluator(expression); // Since API query selectors begin with `/item`, the instance is wrapped. - return (item) => evaluator({ item }); + return (item) => { + const json = quickSerialize(item); + return evaluator({ item: json }); + }; } else { // If no expression was passed, always return true, // thus filtering out none. From 24ffef643f62b9726b222994851710472ce74070 Mon Sep 17 00:00:00 2001 From: dharini Date: Thu, 21 Oct 2021 09:41:03 -0700 Subject: [PATCH 10/10] =?UTF-8?q?fix:=20=F0=9F=90=9B=20specificity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/components/rose/form/input/index.hbs | 2 +- addons/rose/addon/styles/rose/components/form/_input.scss | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/rose/addon/components/rose/form/input/index.hbs b/addons/rose/addon/components/rose/form/input/index.hbs index 7f5747ac2..889ca0639 100644 --- a/addons/rose/addon/components/rose/form/input/index.hbs +++ b/addons/rose/addon/components/rose/form/input/index.hbs @@ -34,7 +34,7 @@ {{/if}} -
+
{{#if @icon}}