Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): activity feed fill the filters on chart bar click #2705

Merged
merged 4 commits into from
Feb 9, 2023

Conversation

LetItRock
Copy link
Contributor

What change does this PR introduce?

Activity Feed Advanced Filters:

  • when clicking on the chart bar - fill in the values in the filter inputs based on the data from that bar/time
  • when any of the filters is selected - show the clear button
  • debounce the filters request to the API when typing in the search and transaction fields

Why was this change needed?

Activity Feed Advanced Filters feature

Other information (Screenshots)

Screenshot 2023-02-08 at 10 50 01

Screen.Recording.2023-02-08.at.10.49.15.mov

@LetItRock LetItRock self-assigned this Feb 8, 2023
@linear
Copy link

linear bot commented Feb 8, 2023

NV-1611 Advanced Filters for activity feed

  • Filters are filled based on clicks on the chart. Possible interactive filter types:
    • Channel Type
    • Status (Errors/ success/pending):
      • The way the filter could work is:
        • Based on the WF status, we want the user to be able to filter based on the WF status.

          • Success - last step (and all before) were successful.
          • Pending - Digest / Delayed / Still running
          • Failed - one or more steps failed.

          I talked with @david Söderberg on October 18, 2022 and we will try this as a stretch.

          • currently when a step fails, the entire WF stops - we need to rethink this and change accordingly.
    • see:
      https://www.figma.com/file/N7A2IxK0JgFN7Xt8elYqNo/Interactive-Activity-Feed?node-id=44%3A630

https://www.notion.so/novuhq/Advanced-Debugging-a6209ba6abd340fc9d5c24182a5c6021#bbfcbfae3e43414f9fd553e21b18287b


Created via Raycast

Comment on lines +12 to +18
templates: string[];

@ApiProperty({
enum: ChannelTypeEnum,
isArray: true,
})
channels: ChannelTypeEnum[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extended the graph stats response with template ids and channels

import { NotificationTemplateEntity, SubscriberRepository } from '@novu/dal';
import { ChannelTypeEnum } from '@novu/shared';

describe('Get activity feed graph stats - /notifications/graph/stats (GET)', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added tests for /notifications/graph/stats endpoint

@@ -54,4 +54,46 @@ describe('Activity Feed Screen', function () {
cy.get('.mantine-MultiSelect-item').contains('SMS').click();
cy.getByTestId('email-step').should('have.length', 0);
});

it('should show the clear filters button when template is selected', function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

e2e tests for the filters clear button

@@ -76,6 +76,7 @@
"less": "^4.1.0",
"lodash.capitalize": "^4.2.1",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using the debounce logic for the search and transaction id inputs... more about it later
the size of this lib is ~1kB gzip

Comment on lines +9 to +10
search: filters?.search !== '' ? filters?.search : undefined,
transactionId: filters?.transactionId !== '' ? filters?.transactionId : undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the search/transaction id fields have empty strings do not include them in query params in the request

Comment on lines +46 to +54
const onClick = (event) => {
const [barItem] = getElementAtEvent(chartRef.current as any, event);
if (barItem) {
const { datasetIndex } = barItem;
const item = data.datasets[datasetIndex].data[barItem.index];

onBarClick(item);
}
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when the chart bar is clicked retrieve it's data item...
it looks like this:

{
_id: '2023-01-01',
count: 4,
templates: [],
channels: []
}

Comment on lines +28 to +31
parsing: {
xAxisKey: 'dateLabel',
yAxisKey: 'count',
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed this to be like this because before the "data item" was the count, now it's the object (shown in the above comment)

Comment on lines +13 to +19
onHover: (event, el) => {
if (el.length > 0) {
event.native.target.style.cursor = 'pointer';
} else {
event.native.target.style.cursor = 'default';
}
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a hover trick, basically, the chart is a canvas, so there is no easy way of saying that on the bar hover it should show the cursor pointer, but we have this callback which is fired when hovering over the chart and if there are elements we do change the cursor style

@@ -114,6 +114,7 @@ export class NotificationRepository extends BaseRepository<EnforceEnvironmentQue
_environmentId: new Types.ObjectId(environmentId),
},
},
{ $unwind: '$channels' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the channels is an array, we should unwind it to be able to pass all items to the set

Comment on lines +126 to +127
templates: { $addToSet: '$_templateId' },
channels: { $addToSet: '$channels' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

templates and channels sets

Copy link
Contributor

@scopsy scopsy left a comment

Choose a reason for hiding this comment

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

Amazing Work!

@scopsy scopsy merged commit eb7d41b into next Feb 9, 2023
@scopsy scopsy deleted the nv-1611-activity-feed-advanced-filters branch February 9, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants