Skip to content

Commit

Permalink
Merge branch 'master' into namespace-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip authored Mar 2, 2020
2 parents 0e48c0a + 7d9b250 commit e66ce6d
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SECURITY:

IMPROVEMENTS:
* auth/aws: Add aws metadata to identity alias [[GH-7975](https://github.com/hashicorp/vault/pull/7975)]
* auth/kubernetes: Allow both names and namespaces to be set to "*" [[GH-78](https://github.com/hashicorp/vault/pull/78)]
* auth/kubernetes: Allow both names and namespaces to be set to "*" [[GH-78](https://github.com/hashicorp/vault-plugin-auth-kubernetes/pull/78)]

BUG FIXES:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,25 @@ import { run } from '@ember/runloop';
import { task, waitForEvent } from 'ember-concurrency';

/**
* @module HttpRequestsBarChartSmall
* The HttpRequestsBarChartSmall is a simplified version of the HttpRequestsBarChart component.
* @module HttpRequestsBarChartSimple
* The HttpRequestsBarChartSimple is a simplified version of the HttpRequestsBarChart component.
*
*
* @example
* ```js
* <HttpRequestsBarChartSmall @counters={counters}/>
* <HttpRequestsBarChartSimple @counters={counters}/>
* ```
*
* @param counters=null {Array} - A list of objects containing the total number of HTTP Requests for each month. `counters` should be the response from the `/internal/counters/requests`.
* The response is then filtered showing only the 12 most recent months of data. This property is called filteredHttpsRequests, like:
* const FILTERED_HTTPS_REQUESTS = [
* { start_time: '2018-11-01T00:00:00Z', total: 5500 },
* { start_time: '2018-12-01T00:00:00Z', total: 4500 },
* { start_time: '2019-01-01T00:00:00Z', total: 5000 },
* { start_time: '2019-02-01T00:00:00Z', total: 5000 },
* ];
* The response is then filtered showing only the 12 most recent months of data. This property is called filteredHttpsRequests.
*/

const HEIGHT = 125;
const UI_GRAY_300 = '#bac1cc';
const UI_GRAY_100 = '#ebeef2';

export default Component.extend({
classNames: ['http-requests-bar-chart-small'],
classNames: ['http-requests-bar-chart-simple'],
counters: null,
margin: Object.freeze({ top: 24, right: 16, bottom: 24, left: 16 }),
padding: 0.04,
Expand Down Expand Up @@ -94,7 +88,7 @@ export default Component.extend({
renderBarChart() {
const { margin, width, xScale, yScale, parsedCounters, elementId } = this;
const height = this.height();
const barChartSVG = d3.select('.http-requests-bar-chart-small');
const barChartSVG = d3.select('.http-requests-bar-chart-simple');
const barsContainer = d3.select(`#bars-container-${elementId}`);

d3.select('.http-requests-bar-chart')
Expand Down
6 changes: 0 additions & 6 deletions ui/app/components/selectable-card-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import { computed } from '@ember/object';
* ```
* @param counters=null {Object} - Counters is an object that returns total entities, tokens, and an array of objects with the total https request per month.
* @param gridContainer=false {Boolean} - gridContainer is optional. If true, it's telling the container it will have a nested CSS grid.
*
* const MODEL = {
* totalEntities: 0,
* httpsRequests: [{ start_time: '2019-04-01T00:00:00Z', total: 5500 }],
* totalTokens: 1,
* };
*/

export default Component.extend({
Expand Down
9 changes: 4 additions & 5 deletions ui/app/components/selectable-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import Component from '@ember/component';
import { computed } from '@ember/object';
/**
* @module SelectableCard
* SelectableCard components are card-like components that display a title, total, subtotal, and anything after they yield.
* SelectableCard components are card-like components that display a title, total, subtotal, and anything after the yield.
* They are designed to be used in containers that act as flexbox or css grid containers.
*
* @example
* ```js
* <SelectableCard @cardTitle="Tokens" @total={{totalHttpRequests}} @subText="Total" @gridContainer={{gridContainer}}/>
* <SelectableCard @cardTitle="Tokens" @total={{totalHttpRequests}} @subText="Total"/>
* ```
* @param cardTitle='' {String} - cardTitle displays the card title
* @param cardTitle=null {String} - cardTitle displays the card title
* @param total=0 {Number} - the Total number displays like a title, it's the largest text in the component
* @param subText='' {String} - subText describes the total
* @param gridContainer=false {Boolean} - Optional parameter used to display CSS grid item class.
* @param subText=null {String} - subText describes the total
*/

export default Component.extend({
Expand Down
2 changes: 1 addition & 1 deletion ui/app/styles/components/selectable-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
padding-right: $spacing-l;
}

.http-requests-bar-chart-small {
.http-requests-bar-chart-simple {
grid-column: 1 / span 2;
grid-row-start: 2;
align-self: end;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/selectable-card-container.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{{/if}}
<p class="has-text-grey is-size-6 item-c">Since last month</p>
</div>
<HttpRequestsBarChartSmall @counters={{filteredHttpsRequests}}/>
<HttpRequestsBarChartSimple @counters={{filteredHttpsRequests}}/>
{{#link-to "vault.cluster.metrics.http-requests" class="card-details"}} View Details {{/link-to}}
{{/if}}
</SelectableCard>
Expand Down
23 changes: 23 additions & 0 deletions ui/stories/http-requests-bar-chart-simple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--THIS FILE IS AUTO GENERATED. This file is generated from JSDoc comments in app/components/http-requests-bar-chart-simple.js. To make changes, first edit that file and run "yarn gen-story-md http-requests-bar-chart-simple" to re-generate the content.-->

## HttpRequestsBarChartSimple
The HttpRequestsBarChartSimple is a simplified version of the HttpRequestsBarChart component.

**Params**

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| counters | <code>Array</code> | <code></code> | A list of objects containing the total number of HTTP Requests for each month. `counters` should be the response from the `/internal/counters/requests`. The response is then filtered showing only the 12 most recent months of data. This property is called filteredHttpsRequests. |

**Example**

```js
<HttpRequestsBarChartSimple @counters={counters}/>
```

**See**

- [Uses of HttpRequestsBarChartSimple](https://github.com/hashicorp/vault/search?l=Handlebars&q=HttpRequestsBarChartSimple+OR+http-requests-bar-chart-simple)
- [HttpRequestsBarChartSimple Source Code](https://github.com/hashicorp/vault/blob/master/ui/app/components/http-requests-bar-chart-simple.js)

---
28 changes: 28 additions & 0 deletions ui/stories/http-requests-bar-chart-simple.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember';
import { withKnobs, object } from '@storybook/addon-knobs';
import notes from './http-requests-bar-chart-simple.md';

const COUNTERS = [
{ start_time: '2018-11-01T00:00:00Z', total: 5500 },
{ start_time: '2018-12-01T00:00:00Z', total: 4500 },
{ start_time: '2019-01-01T00:00:00Z', total: 5000 },
{ start_time: '2019-02-01T00:00:00Z', total: 5000 },
];

storiesOf('HttpRequests/BarChart/Simple', module)
.addParameters({ options: { showPanel: true } })
.addDecorator(withKnobs())
.add(
`HttpRequestsBarChartSimple`,
() => ({
template: hbs`
<h5 class="title is-5">Http Requests Bar Chart Simple</h5>
<HttpRequestsBarChartSimple @counters={{counters}}/>
`,
context: {
counters: object('counters', COUNTERS),
},
}),
{ notes }
);
25 changes: 12 additions & 13 deletions ui/stories/http-requests-bar-chart.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember';
import { withKnobs, object } from '@storybook/addon-knobs';
Expand All @@ -10,19 +9,19 @@ const COUNTERS = [
{ start_time: '2019-06-01T00:00:00Z', total: 5000 },
];

storiesOf('HttpRequests/BarChart/', module)
storiesOf('HttpRequests/BarChart/Regular', module)
.addParameters({ options: { showPanel: true } })
.addDecorator(
withKnobs()
)
.add(`HttpRequestsBarChart`, () => ({
template: hbs`
.addDecorator(withKnobs())
.add(
`HttpRequestsBarChart`,
() => ({
template: hbs`
<h5 class="title is-5">Http Requests Bar Chart</h5>
<HttpRequestsBarChart @counters={{counters}}/>
`,
context: {
counters: object('counters', COUNTERS)
},
}),
{notes}
);
context: {
counters: object('counters', COUNTERS),
},
}),
{ notes }
);
24 changes: 24 additions & 0 deletions ui/stories/selectable-card-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--THIS FILE IS AUTO GENERATED. This file is generated from JSDoc comments in app/components/selectable-card-container.js. To make changes, first edit that file and run "yarn gen-story-md selectable-card-container" to re-generate the content.-->

## SelectableCardContainer
SelectableCardContainer components are used to hold SelectableCard components. They act as a CSS grid container, and change grid configurations based on the boolean of @gridContainer.

**Params**

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| counters | <code>Object</code> | <code></code> | Counters is an object that returns total entities, tokens, and an array of objects with the total https request per month. |
| gridContainer | <code>Boolean</code> | <code>false</code> | gridContainer is optional. If true, it's telling the container it will have a nested CSS grid. |

**Example**

```js
<SelectableCardContainer @counters={{model}} @gridContainer="true" />
```

**See**

- [Uses of SelectableCardContainer](https://github.com/hashicorp/vault/search?l=Handlebars&q=SelectableCardContainer+OR+selectable-card-container)
- [SelectableCardContainer Source Code](https://github.com/hashicorp/vault/blob/master/ui/app/components/selectable-card-container.js)

---
34 changes: 34 additions & 0 deletions ui/stories/selectable-card-container.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember';
import { withKnobs, boolean, object } from '@storybook/addon-knobs';
import notes from './selectable-card-container.md';

const MODEL = {
totalEntities: 0,
httpsRequests: [
{ start_time: '2018-12-01T00:00:00Z', total: 5500 },
{ start_time: '2019-01-01T00:00:00Z', total: 4500 },
{ start_time: '2019-02-01T00:00:00Z', total: 5000 },
{ start_time: '2019-03-01T00:00:00Z', total: 5000 },
],
totalTokens: 1,
};
const GRID_CONTAINER = true;

storiesOf('SelectableCard/SelectableCardContainer', module)
.addParameters({ options: { showPanel: true } })
.addDecorator(withKnobs())
.add(
`SelectableCardContainer`,
() => ({
template: hbs`
<SelectableCardContainer @counters={{model}} @gridContainer={{gridContainer}} />
`,
context: {
model: object('model', MODEL),
gridContainer: boolean('gridContainer', GRID_CONTAINER),
},
}),
{ notes }
);
26 changes: 26 additions & 0 deletions ui/stories/selectable-card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--THIS FILE IS AUTO GENERATED. This file is generated from JSDoc comments in app/components/selectable-card.js. To make changes, first edit that file and run "yarn gen-story-md selectable-card" to re-generate the content.-->

## SelectableCard
SelectableCard components are card-like components that display a title, total, subtotal, and anything after the yield.
They are designed to be used in containers that act as flexbox or css grid containers.

**Params**

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| cardTitle | <code>String</code> | <code></code> | cardTitle displays the card title |
| total | <code>Number</code> | <code>0</code> | the Total number displays like a title, it's the largest text in the component |
| subText | <code>String</code> | <code></code> | subText describes the total |

**Example**

```js
<SelectableCard @cardTitle="Tokens" @total={{totalHttpRequests}} @subText="Total"/>
```

**See**

- [Uses of SelectableCard](https://github.com/hashicorp/vault/search?l=Handlebars&q=SelectableCard+OR+selectable-card)
- [SelectableCard Source Code](https://github.com/hashicorp/vault/blob/master/ui/app/components/selectable-card.js)

---
27 changes: 27 additions & 0 deletions ui/stories/selectable-card.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember';
import { withKnobs, boolean, number, text } from '@storybook/addon-knobs';
import notes from './selectable-card.md';

const CARD_TITLE = 'Tokens';
const SUB_TEXT = 'Total';
const TOTAL_HTTP_REQUESTS = 100;

storiesOf('SelectableCard/SelectableCard', module)
.addParameters({ options: { showPanel: true } })
.addDecorator(withKnobs())
.add(
`SelectableCard`,
() => ({
template: hbs`
<h5 class="title is-5">Selectable Card</h5>
<SelectableCard @cardTitle={{cardTitle}} @total={{totalHttpRequests}} @subText={{subText}} />
`,
context: {
cardTitle: text('cardTitle', CARD_TITLE),
totalHttpRequests: number('totalHttpRequests', TOTAL_HTTP_REQUESTS),
subText: text('subText', SUB_TEXT),
},
}),
{ notes }
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const FILTERED_HTTPS_REQUESTS = [
{ start_time: '2019-02-01T00:00:00Z', total: 5000 },
];

module('Integration | Component | http-requests-bar-chart-small', function(hooks) {
module('Integration | Component | http-requests-bar-chart-simple', function(hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function() {
this.set('filteredHttpsRequests', FILTERED_HTTPS_REQUESTS);
});

test('it renders and the correct number of bars are showing', async function(assert) {
await render(hbs`<HttpRequestsBarChartSmall @counters={{filteredHttpsRequests}}/>`);
await render(hbs`<HttpRequestsBarChartSimple @counters={{filteredHttpsRequests}}/>`);

assert.dom('rect').exists({ count: FILTERED_HTTPS_REQUESTS.length });
assert.dom('.http-requests-bar-chart-small').exists();
assert.dom('.http-requests-bar-chart-simple').exists();
});
});

0 comments on commit e66ce6d

Please sign in to comment.