Skip to content

Commit

Permalink
Update SERVICE_KIND to include all service kinds (#61)
Browse files Browse the repository at this point in the history
* Update SERVICE_KIND to include all service kinds

* Update docs example
  • Loading branch information
WenInCode committed Sep 6, 2023
1 parent bbff69e commit e191fb8
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-ants-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/consul-ui-toolkit': patch
---

Update SERVICE_KIND to include all service kinds
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default class ServiceListItem extends Controller {
critical: 0,
},
},
kind: 'typical',
instanceCount: 8,
isImported: true,
samenessGroup: 'group-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
critical: 0,
},
},
kind: 'typical',
instanceCount: 8,
isImported: true,
samenessGroup: 'group-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,40 @@ module('Integration | Component | cut/list-item/service', function (hooks) {
'renders tags values to metadata'
);
});

test('it does render the kind if it does not find a kindName', async function (assert) {
const service = {
name: 'Service 1',
metadata: {
healthCheck: {
instance: {
success: 4,
critical: 2,
warning: 1,
},
},
kind: 'typical',
instanceCount: 7,
linkedServiceCount: 4,
upstreamCount: 4,
isImported: true,
isPermissiveMTls: true,
samenessGroup: 'sameness-group-1',
connectedWithGateway: true,
externalSource: 'vault',
tags: ['tag', 'service'],
},
};
this.set('service', service);

await render(
hbs`
<Cut::ListItem::Service @service={{this.service}}/>`
);

assert.false(cutService.metadata.kind.renders, 'kind');
});

test('it renders Cut::ListItem::Service without metadata', async function (assert) {
const service = {
name: 'Service 1',
Expand Down
2 changes: 1 addition & 1 deletion toolkit/src/components/cut/list-item/service/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@warningCount={{@service.metadata.healthCheck.instance.warning}}
@criticalCount={{@service.metadata.healthCheck.instance.critical}}
/>
{{#if @service.metadata.kind}}
{{#if this.kindName}}
<Cut::TextWithIcon
@icon='gateway'
@text={{this.kindName}}
Expand Down
11 changes: 10 additions & 1 deletion toolkit/src/components/cut/list-item/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export default class ServiceListItemComponent extends Component<ServiceListItemS

get kindName() {
const { kind } = this.args.service.metadata;
return kind ? this.NormalizedGatewayLabels[kind] : undefined;
return kind &&
Object.prototype.hasOwnProperty.call(this.NormalizedGatewayLabels, kind)
? this.NormalizedGatewayLabels[
kind as
| 'api-gateway'
| 'mesh-gateway'
| 'ingress-gateway'
| 'terminating-gateway'
]
: undefined;
}
}
4 changes: 4 additions & 0 deletions toolkit/src/components/cut/list-item/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export type ExternalSource =
| 'lambda';

export type SERVICE_KIND =
| ''
| 'typical'
| 'destination'
| 'connect-proxy'
| 'api-gateway'
| 'mesh-gateway'
| 'ingress-gateway'
Expand Down

1 comment on commit e191fb8

@vercel
Copy link

@vercel vercel bot commented on e191fb8 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.