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: add status filters on overview page #840

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

arnaudvalle
Copy link
Contributor

Following the discussion on #742, I added some simple links to the StatusLegend so it's now possible to filter queues based on a given status. This can be useful to direct link to a list of failed queues from some alerting system for example:

image

I've tried to reuse as much as I could from existing components but I'm unsure whether you tend to duplicate similar things or not to future-proof them (for example I've reused css vars from status-menu in the StatusLegend module css but maybe that's an anti-pattern for you?).

Also, a current known limitation to this is that there is no ALL link (but we can click on the logo for example to go back to the initial state) as I wasn't sure on how best to handle this (I'm a first-time contributor to this project so I'm not comfortable with the architecture of it all just yet). Would adding a new status and associated translation for this make sense?

@felixmosh
Copy link
Owner

Hi @arnaudvalle, thank u for this PR.
Is it better to just filter queues in the client side? (and show all statuses of the queue)?

content: '';
background-color: var(--item-bg);
border-radius: 50%;
width: 0.5rem;
height: 0.5rem;
display: inline-block;
display: flex;
Copy link
Owner

Choose a reason for hiding this comment

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

why flex is here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, this is not necessary anymore. I think I added it before changing the markup of the filters.


export const OverviewPage = () => {
const { actions, queues } = useQueues();
actions.pollQueues();

const selectedStatus = useSelectedStatuses();
const overviewPageStatus = selectedStatus[''];
Copy link
Owner

Choose a reason for hiding this comment

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

selectedStatus['']- can u explain this statment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was my understanding that this would be the queue value for the overview page, see in the useActiveQueueName hook?

But I guess this is probably not a good idea to rely on this since the overview page isn't really a queue?

})}>
<NavLink
to={`/?status=${status}`}
className={s[toCamelCase(status)]}
Copy link
Owner

Choose a reason for hiding this comment

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

There is status on the parent li, why do we need here?

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 believe that can go as well - that was before I moved the logic out to the <li> so it's redundant indeed 👍


export const StatusLegend = () => {
const { t } = useTranslation();
const { search } = useLocation();
Copy link
Owner

Choose a reason for hiding this comment

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

useQuery instead

@arnaudvalle
Copy link
Contributor Author

Is it better to just filter queues in the client side? (and show all statuses of the queue)?

So you mean if I only ever have queues with FAILED jobs (like in my screenshot) then I would only ever show the FAILED tab filter in the list and not the other ones? Something like:

image

I'm not sure about how other people use this page tbh but if you say that's ok then it's fine by me 👍

@felixmosh
Copy link
Owner

Is it better to just filter queues in the client side? (and show all statuses of the queue)?

So you mean if I only ever have queues with FAILED jobs (like in my screenshot) then I would only ever show the FAILED tab filter in the list and not the other ones? Something like:

image I'm not sure about how other people use this page tbh but if you say that's ok then it's fine by me 👍

No, i ment filter queues only in client side, "show me queues that have count on selected status that is greater than 0"

@arnaudvalle
Copy link
Contributor Author

No, i ment filter queues only in client side, "show me queues that have count on selected status that is greater than 0"

I see - I believe that's how I got started on this but somehow got lost along the way... I'll fix the condition on the queues.filter in OverviewPage and that should be it. That's what you mean, right?

@felixmosh
Copy link
Owner

felixmosh commented Oct 21, 2024

Instead of making a request with the "selected status", we can filter out all queues which has count of "selected status" > 0.
This way, we can show all other statuses of the queue but focus only on queues that has at lease one failed job.
Current implementation, whenever you filter, shows that the queue has only failed jobs (but it is not true).

@arnaudvalle
Copy link
Contributor Author

Oh so you mean move the queues.filters I added to the OverviewPage into the useQueues hook, right before the setState for instance?

@felixmosh
Copy link
Owner

No, I mean that instead of filter queues with an API call, filter it only in client side.

@arnaudvalle
Copy link
Contributor Author

No, I mean that instead of filter queues with an API call, filter it only in client side.

Ok sorry, I must be misunderstanding something here. I thought that's already what my change was doing in the OverviewPage?

The overviewPageStatus === 'latest' bit in the condition is because the overview page (aka '' in the queues coming from the useQueues hook) defaults to a value of latest when no status is selected (see in useSelectedStatus hook).

Maybe it's my fault and my screenshot was misleading to star with (since I was only showing queues with failed jobs), but when I have a queue with both completed AND failed jobs for example, I can either see the queue when I select the completed status OR the failed status:

completed is selected:
image

failed is selected:
image

no status selected:
image

status with no job in any queues is selected:
image

Thanks for your patience and feedbacks btw!

@felixmosh
Copy link
Owner

Ha, OK... I'll merge it as soon as I will be near a keyboard (I'm on vacation right now)
Thank for this awesome feature 🙂

@arnaudvalle
Copy link
Contributor Author

Oh, no rush, don't worry! I'll stop bothering you now, enjoy your time off 👍

@felixmosh felixmosh merged commit 4d0ae3d into felixmosh:master Oct 23, 2024
4 checks passed
@felixmosh
Copy link
Owner

I've refactor a bit the code...
Added a message when ever the filter is 0...
It will be released in the next version
Thank you 🙏🏽

@arnaudvalle arnaudvalle deleted the feat/add-queues-filters branch October 24, 2024 09:01
@arnaudvalle
Copy link
Contributor Author

Great stuff, thanks for the cleanup 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants