diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 007950f69..008ed2743 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -13,7 +13,7 @@ export default function () { // make this `/api`, for example, if your API is namespaced this.namespace = config.api.namespace; // delay for each request, automatically set to 0 during testing - this.timing = 350; + this.timing = 1; // Allow any configured API host to passthrough, which is useful in // development for testing against a locally running backend. diff --git a/addons/core/public/app-icons/credential.svg b/addons/core/public/app-icons/credential.svg new file mode 100644 index 000000000..fb9bc8a1d --- /dev/null +++ b/addons/core/public/app-icons/credential.svg @@ -0,0 +1,4 @@ + + + + diff --git a/addons/core/public/app-icons/credentials.svg b/addons/core/public/app-icons/credentials.svg new file mode 100644 index 000000000..72c15d48a --- /dev/null +++ b/addons/core/public/app-icons/credentials.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/addons/rose/addon/components/rose/dropdown/index.hbs b/addons/rose/addon/components/rose/dropdown/index.hbs index 587b8c369..5d02e87e8 100644 --- a/addons/rose/addon/components/rose/dropdown/index.hbs +++ b/addons/rose/addon/components/rose/dropdown/index.hbs @@ -1,6 +1,6 @@
@@ -22,14 +22,28 @@ -
- {{yield (hash - link=(component "rose/dropdown/link" style=this.style) - button=(component "rose/dropdown/button" style=this.style) - item=(component "rose/anonymous" class="rose-dropdown-item") - separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator") - section=(component "rose/dropdown/section" style=this.style) - )}} -
+ {{#if @ignoreClickInside}} +
+ {{yield (hash + link=(component "rose/dropdown/link" style=this.style) + button=(component "rose/dropdown/button" style=this.style) + item=(component "rose/anonymous" class="rose-dropdown-item") + separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator") + section=(component "rose/dropdown/section" style=this.style) + key-value=(component "rose/dropdown/key-value") + )}} +
+ {{else}} +
+ {{yield (hash + link=(component "rose/dropdown/link" style=this.style) + button=(component "rose/dropdown/button" style=this.style) + item=(component "rose/anonymous" class="rose-dropdown-item") + separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator") + section=(component "rose/dropdown/section" style=this.style) + key-value=(component "rose/dropdown/key-value") + )}} +
+ {{/if}}
diff --git a/addons/rose/addon/components/rose/dropdown/index.stories.mdx b/addons/rose/addon/components/rose/dropdown/index.stories.mdx index a6b7a1b52..58a0575bf 100644 --- a/addons/rose/addon/components/rose/dropdown/index.stories.mdx +++ b/addons/rose/addon/components/rose/dropdown/index.stories.mdx @@ -63,6 +63,24 @@ A simple dropdown component with support for links and buttons. }} + + {{ + template: hbs` + + + <:key>Name + <:value>Key/Value + + + + <:key>Description + <:value>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda illo ratione libero ducimus magnam, porro sed provident repellat mollitia a, repellendus placeat. Magni consequuntur cumque, debitis obcaecati dolores quasi natus? + + + `, + }} + + ```html @@ -125,3 +143,14 @@ form field. ``` + +Closing dropdown after clicking inside it's content can be ignored using `ignoreClickInside`. This is useful when dropdown contains keyvalue items that users need to select/copy/interact with. + +```html + + + <:key>ID + <:value>cl_nbv9375hLHs + + +``` diff --git a/addons/rose/addon/components/rose/dropdown/key-value/index.hbs b/addons/rose/addon/components/rose/dropdown/key-value/index.hbs new file mode 100644 index 000000000..a160906c5 --- /dev/null +++ b/addons/rose/addon/components/rose/dropdown/key-value/index.hbs @@ -0,0 +1,9 @@ +
+
+ {{yield to='key'}} +
+ +
+ {{yield to='value'}} +
+
diff --git a/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss b/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss index 4b75b3ad5..96717ebc1 100644 --- a/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss +++ b/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss @@ -5,6 +5,7 @@ $xs: sizing.rems(xs); // 8 $xxs: sizing.rems(xxs); // 4 $chevron: url("data:image/svg+xml;utf-8,"); $chevronWhite: url("data:image/svg+xml;utf-8,"); +$chevronGrey: url("data:image/svg+xml;utf-8,"); .rose-dropdown { --background-image-light: #{$chevron}; @@ -121,4 +122,26 @@ $chevronWhite: url("data:image/svg+xml;utf-8,Condensed Table - - - - Address - Host Set - Name - Description - - - - - 1.1.1.1 - host-set-1, host-set-2 - optional name - description - - - - - Footer - - - +

KeyValue Dropdown

+ + + <:key>ID + <:value>cl_nbv9375hLHs + -

Condensed Table with Shrink Cells

- - - - Address - Host Set - Name - Description - - - - - 1.1.1.1 - host-set-1, host-set-2 - - Remove - - description - - - - - Footer - - - + -

Condensed Table with Right and Center aligned cells

- - - - Address - Host Set - Name - Description - - - - - 1.1.1.1 - host-set-1, host-set-2 - optional name - description - - - - - Footer - - - + + <:key>Name + <:value>Key/Value + -

Condensed Table Key/Value Lookalike (edit mode)

- - - - Key - Value - - - - - Key - - - - - - - Remove - - - - Key - - - - Choose an option - Value 1 - Value 2 - Value 3 - - - - - Add - - - - Key - - - - - - - Add - - - - Key - - - - - Add - - - - - - Footer - - - + -

Condensed Table With Visually Hidden Header & Footer

- - - - Address - Host Set - Name - Description - - - - - 1.1.1.1 - host-set-1, host-set-2 - optional name - description - - - - - Footer - - - + + <:key>Description + <:value>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda illo ratione libero ducimus magnam, porro sed provident repellat mollitia a, repellendus placeat. Magni consequuntur cumque, debitis obcaecati dolores quasi natus? + -

Table

- - - - Address - Host Set - Name - Description - - - - - 1.1.1.1 - host-set-1, host-set-2 - optional name - description - - - - - Footer - - - \ No newline at end of file +
+ +

Condensed dropdown

+ + + cl_nbv9375hLHs + + + + + + Key/Value + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet sem sodales neque ultrices sollicitudin vel sed justo. Vivamus vitae sollicitudin turpis. + + + +

Normal Dropdown

+ + + cl_nbv9375hLHs + + + + + Key/Value + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet sem sodales neque ultrices sollicitudin vel sed justo. Vivamus vitae sollicitudin turpis. + + + +

Normal Dropdown

+ +Menu item +Menu item 2 + diff --git a/addons/rose/tests/integration/components/rose/dropdown/key-value-test.js b/addons/rose/tests/integration/components/rose/dropdown/key-value-test.js new file mode 100644 index 000000000..7381e9560 --- /dev/null +++ b/addons/rose/tests/integration/components/rose/dropdown/key-value-test.js @@ -0,0 +1,20 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | rose/dropdown/key-value', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs` + + <:key>key + <:value>value + + `); + + assert.equal(find('.rose-dropdown-key').textContent.trim(), 'key'); + assert.equal(find('.rose-dropdown-value').textContent.trim(), 'value'); + }); +}); diff --git a/ui/desktop/.stylelintrc.json b/ui/desktop/.stylelintrc.json index b20f46ce4..d28c485da 100644 --- a/ui/desktop/.stylelintrc.json +++ b/ui/desktop/.stylelintrc.json @@ -6,6 +6,7 @@ "scss/at-extend-no-missing-placeholder": null, "function-parentheses-space-inside": null, "property-no-vendor-prefix": null, - "at-rule-no-vendor-prefix": null + "at-rule-no-vendor-prefix": null, + "order/properties-alphabetical-order": null } } diff --git a/ui/desktop/app/components/card/index.hbs b/ui/desktop/app/components/card/index.hbs new file mode 100644 index 000000000..1516a7bcf --- /dev/null +++ b/ui/desktop/app/components/card/index.hbs @@ -0,0 +1,27 @@ +
+ {{#if (if (has-block 'header') true @heading)}} +
+ {{#if @heading}} +

+ {{#if @icon}} + + {{/if}} + {{@heading}} +

+ {{/if}} + + {{yield to='header'}} + +
+ {{/if}} + +
+ {{yield to='body'}} +
+ + {{#if (has-block 'footer')}} +
+ {{yield to='footer'}} +
+ {{/if}} +
\ No newline at end of file diff --git a/ui/desktop/app/components/reveal/index.hbs b/ui/desktop/app/components/reveal/index.hbs new file mode 100644 index 000000000..8e15785dd --- /dev/null +++ b/ui/desktop/app/components/reveal/index.hbs @@ -0,0 +1,14 @@ +
+ + + {{@textWhenClose}} + + + {{@textWhenOpen}} + + + + + {{yield}} + +
\ No newline at end of file diff --git a/ui/desktop/app/components/reveal/index.js b/ui/desktop/app/components/reveal/index.js new file mode 100644 index 000000000..a4db866c4 --- /dev/null +++ b/ui/desktop/app/components/reveal/index.js @@ -0,0 +1,3 @@ +import RoseDropdownComponent from 'rose/components/rose/dropdown'; + +export default class RevealComponent extends RoseDropdownComponent {} diff --git a/ui/desktop/app/styles/app.scss b/ui/desktop/app/styles/app.scss index cc21ec36f..00313f9ea 100644 --- a/ui/desktop/app/styles/app.scss +++ b/ui/desktop/app/styles/app.scss @@ -346,7 +346,6 @@ .rose-dialog-footer { align-items: center; - display: flex; div:nth-child(1) { display: flex; @@ -360,35 +359,90 @@ width: 50%; } } - - // .credentials-card { - // display: flex; - // flex-direction: column; - // margin-bottom: 12px; - - // &:last-child { margin-bottom: 0; } - - // .credentials-card-header { - // display: flex; - // flex-direction: row; - - // div { - // display: flex; - // width: 50%; - - // &:last-child { - // justify-content: flex-end; - // } - // } - // // border-bottom: 1px solid grey; - // } - - // .credentials-card-body { - // // background: yellow; - // } - - // .credentials-card-footer { - // // background: pink; - // } - // } +} + +// Reveal component (app/components/reveal) +$chevron-up: url("data:image/svg+xml;utf-8,"); +$chevron-down: url("data:image/svg+xml;utf-8,"); + +.reveal { + --trigger-color: var(--action); + + .reveal-trigger { + background: url($chevron-down) no-repeat right center; + color: var(--trigger-color); + cursor: default; + display: inline-block; + overflow: hidden; + padding-right: sizing.rems(l); + white-space: nowrap; + + // Hide default twistie triangle + // Firefox + list-style-type: none; + // Webkit / Chromium + &::-webkit-details-marker { + display: none; + } + + &::marker { + display: none; + } + + &:hover { + --trigger-color: var(--action-starker-1); + } + } + + &:not([open]) { + .reveal-trigger-text-open { + display: none; + } + } + + &[open] { + .reveal-trigger { + background: url($chevron-up) no-repeat right center; + } + + .reveal-trigger-text-close { + display: none; + } + } +} + +// Card component (app/components/card) +.card { + border: sizing.rems(xxxxs) solid var(--ui-gray-subtler-3); + display: flex; + flex-direction: column; + margin-bottom: sizing.rems(m); + + .card-header { + align-items: center; + border-bottom: sizing.rems(xxxxs) solid var(--ui-gray-subtler-3); + display: flex; + justify-content: flex-start; + padding: sizing.rems(s) sizing.rems(m); + + h2 { + @include type.type(s, normal); + color: var(--ui-gray-starker-1); + margin: 0; + padding: sizing.rems(xxs) + sizing.rems(xxxs) 0; + } + + .rose-icon { + margin-right: sizing.rems(xxxs); + } + } + + .card-body { + padding: sizing.rems(s); + } + + .card-footer { + border-top: sizing.rems(xxxxs) solid var(--ui-gray-subtler-3); + padding: sizing.rems(s); + } } diff --git a/ui/desktop/app/templates/scopes/scope/projects/targets.hbs b/ui/desktop/app/templates/scopes/scope/projects/targets.hbs index 3fee051d6..fb0d61f56 100644 --- a/ui/desktop/app/templates/scopes/scope/projects/targets.hbs +++ b/ui/desktop/app/templates/scopes/scope/projects/targets.hbs @@ -20,17 +20,68 @@ <:body>

{{t 'resources.target.messages.proxy_url.title'}} ({{t 'resources.target.types.tcp'}})

- - {{session.proxy_address}}:{{session.proxy_port}} - +

+ + {{session.proxy_address}}:{{session.proxy_port}} + +

- {{! + {{!-- -

Credentials

}} +

Credentials

+ + + <:header> + + + + <:body> + + + + Key + Value + + + + + foo + Value + + + ttl + Test + + + + + <:footer> + +
+                    
+  {
+    "auth": null,
+    "lease_duration": 3600,
+    "lease_id": "",
+    "renewable": false
+  }
+                    
+                  
+
+ +
--}} <:footer> diff --git a/ui/desktop/tests/integration/components/card-test.js b/ui/desktop/tests/integration/components/card-test.js new file mode 100644 index 000000000..fdb37919b --- /dev/null +++ b/ui/desktop/tests/integration/components/card-test.js @@ -0,0 +1,45 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | card', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + assert.ok(find('.card')); + }); + + test('it renders with content', async function (assert) { + await render(hbs` + + <:header> + <:body> + <:footer> + + `); + + assert.ok(find('.card')); + assert.ok(find('.card-header')); + assert.ok(find('.card-body')); + assert.ok(find('.card-footer')); + }); + + test('header renders an icon when defined', async function (assert) { + await render(hbs` + + <:header> + <:body> + <:footer> + + `); + + assert.ok(find('.card')); + assert.ok(find('.card-header')); + assert.ok(find('.card-header .rose-icon')); + assert.equal(this.element.textContent.trim(), 'This is a heading test'); + }); +}); diff --git a/ui/desktop/tests/integration/components/reveal-test.js b/ui/desktop/tests/integration/components/reveal-test.js new file mode 100644 index 000000000..4d63473f5 --- /dev/null +++ b/ui/desktop/tests/integration/components/reveal-test.js @@ -0,0 +1,48 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | reveal', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + assert.expect(3); + await render(hbs` + + `); + assert.ok(find('.reveal')); + assert.ok(find('.reveal-trigger')); + assert.ok(find('.reveal-trigger').textContent.trim(), 'View content'); + }); + + test('it renders with content, opens, show the content, close and hide the content', async function (assert) { + assert.expect(3); + await render(hbs` + +
+          
+            {
+              "auth": null,
+              "lease_duration": 3600,
+              "lease_id": "",
+              "renewable": false
+            }
+          
+        
+
+ `); + + assert.notOk(find('details').open); + await click('summary'); + assert.ok(find('details').open); + await click('summary'); + assert.notOk(find('details').open); + }); +});