Skip to content

Commit

Permalink
fix(orb-ui): Improve Tooltips json texts (#2766)
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-mendonca-encora authored Oct 19, 2023
1 parent d2d6f76 commit be403b4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h4>All Policies</h4>
let-row="row"
let-value="value"
>
<mat-chip-list>
<mat-chip-list nbTooltip="{{ (row?.tags | json) === '{}' ? 'No tags were created' : row.tags | jsonlist }}">
<mat-chip
*ngFor="let tag of value | keyvalue"
style="background-color: #2B3148;"
Expand All @@ -109,7 +109,6 @@ <h4>All Policies</h4>
<span style="color: #df316f;">No tag were created</span>
</mat-chip>
</mat-chip-list>

</ng-template>

<ng-template #versionTemplateCell let-i="index" let-row="row" let-value="value">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h4>All Agents</h4>
let-row="row"
let-value="value"
>
<mat-chip-list #tablechiplist nbTooltip="{{ row.combined_tags | json }}">
<mat-chip-list #tablechiplist nbTooltip="{{ (row?.combined_tags | json) === '{}' ? 'No tags were created' : row.combined_tags | jsonlist }}">
<mat-chip
*ngFor="let tag of value | keyvalue"
style="background-color: #2B3148;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h4>{{ strings.list.header }}</h4>
<span
(click)="onMatchingAgentsModal(row)"
class="matching-agents"
nbTooltip="{{ row.matching_agents | json }}"
nbTooltip="{{ row.matching_agents | jsonlist }}"
>
{{ row.matching_agents.total }}
</span>
Expand All @@ -99,7 +99,7 @@ <h4>{{ strings.list.header }}</h4>
let-row="row"
let-value="value"
>
<mat-chip-list nbTooltip="{{ value | json }}">
<mat-chip-list nbTooltip="{{ value | jsonlist }}">
<mat-chip
*ngFor="let tag of value | keyvalue"
style="background-color: #2B3148;"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/pages/sinks/list/sink.list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h4>{{ strings.list.header }}</h4>

<ng-template #sinkTagsTemplateCell let-i="index" let-row="row" let-value="value">
<div class="d-block">
<mat-chip-list nbTooltip="{{ value | json }}">
<mat-chip-list nbTooltip="{{ !row?.tags ? 'No tag were created' : value | jsonlist }}">
<mat-chip
*ngFor="let tag of value | keyvalue"
style="background-color: #2B3148;"
Expand Down
14 changes: 14 additions & 0 deletions ui/src/app/shared/pipes/list-json.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({name: 'jsonlist'})
export class JsonListPipe implements PipeTransform {

transform(object: any): string {
if (!object || typeof object !== 'object') {
return '';
}
const entries = Object.entries(object);
const formattedList = entries.map(([key, value]) => `${key}: ${value}`).join(', ');
return formattedList;
}
}
4 changes: 4 additions & 0 deletions ui/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { AgentBackendsComponent } from './components/orb/agent/agent-backends/ag
import { SinkDetailsComponent } from './components/orb/sink/sink-details/sink-details.component';
import { SinkConfigComponent } from './components/orb/sink/sink-config/sink-config.component';
import { TableContextMenu } from './components/tableContexMenu/table-context-menu-component';
import { JsonListPipe } from './pipes/list-json.pipe';

@NgModule({
imports: [
Expand Down Expand Up @@ -109,6 +110,7 @@ import { TableContextMenu } from './components/tableContexMenu/table-context-men
PaginationComponent,
AdvancedOptionsPipe,
TagColorPipe,
JsonListPipe,
TagChipPipe,
TaglistChipPipe,
ValidTagInputDirective,
Expand Down Expand Up @@ -148,6 +150,7 @@ import { TableContextMenu } from './components/tableContexMenu/table-context-men
PaginationComponent,
AdvancedOptionsPipe,
TagColorPipe,
JsonListPipe,
TagChipPipe,
TaglistChipPipe,
ValidTagInputDirective,
Expand Down Expand Up @@ -183,6 +186,7 @@ import { TableContextMenu } from './components/tableContexMenu/table-context-men
ToMillisecsPipe,
AdvancedOptionsPipe,
TagColorPipe,
JsonListPipe,
TagChipPipe,
TaglistChipPipe,
ValidTagInputDirective,
Expand Down

0 comments on commit be403b4

Please sign in to comment.