Skip to content

Commit

Permalink
feat: add redirect to chats from ongoing table
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuseduardomedeiros committed Dec 26, 2024
1 parent fe8ce3d commit efcf27a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
},
formattedItems() {
if (!this.formattedHeaders.length || !this.items.length) return [];
if (!this.formattedHeaders?.length || !this.items?.length) return [];
const formattedItems = this.items.map((item) => ({
...item,
Expand Down Expand Up @@ -179,7 +179,7 @@ export default {
:hover.unnnic-table-next__body-row {
cursor: pointer;
background-color: $unnnic-color-neutral-lightest;
text-decoration: underline;
font-weight: $unnnic-font-weight-bold;
}
span[data-testid='arrow-asc-icon'] {
Expand Down
27 changes: 26 additions & 1 deletion src/components/insights/widgets/TableGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
>
<UnnnicTableNext
v-if="activeTable.headers"
:class="`table-group__table-${key}`"
data-testid="table"
:pagination="page + 1"
:headers="activeTable.headers"
Expand All @@ -28,6 +29,7 @@
:paginationInterval="paginationInterval"
:isLoading="isLoading"
@update:pagination="page = $event - 1"
@row-click="rowClick"
/>
</template>
</UnnnicTab>
Expand Down Expand Up @@ -138,7 +140,7 @@ export default {
const content = dynamicHeaders.map((header) =>
formatRowValue(row[header.value]),
);
return { content };
return { ...row, link: undefined, url_link: row.link?.url, content };
});
return {
Expand Down Expand Up @@ -197,12 +199,35 @@ export default {
const { offset, limit } = this.paginationConfig;
this.$emit('request-data', { offset, limit });
},
rowClick(row) {
if (row.url_link) {
const [path, query] = row.url_link.split('?');
window.parent.postMessage(
{
event: 'redirect',
path: path + 'insights?' + query,
},
'*',
);
}
},
},
};
</script>
<style lang="scss" scoped>
.table-group {
overflow-y: auto;
:deep(.table-group__table-in_progress) {
display: flex;
overflow: auto;
:hover.unnnic-table-next__body-row {
cursor: pointer;
background-color: $unnnic-color-neutral-lightest;
font-weight: $unnnic-font-weight-bold;
}
}
}
</style>
6 changes: 4 additions & 2 deletions src/components/insights/widgets/__tests__/TableGroup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe('TableGroup', () => {
expect(table.props('headers')).toEqual([
{ content: 'Field 1', value: 'field1' },
]);
expect(table.props('rows')).toEqual([{ content: ['Value'] }]);
expect(table.props('rows')).toEqual([
{ field1: 'Value', content: ['Value'] },
]);
});

it('returns null when no activeTab is found and no default tab is available', () => {
Expand Down Expand Up @@ -100,7 +102,7 @@ describe('TableGroup', () => {
it('computes dynamic rows from the provided data', () => {
const rows = wrapper.vm.activeTable.rows;

expect(rows).toEqual([{ content: ['Value'] }]);
expect(rows).toEqual([{ field1: 'Value', content: ['Value'] }]);
});

it('formats row values correctly for dates, arrays, and strings', async () => {
Expand Down

0 comments on commit efcf27a

Please sign in to comment.