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

Implement "Silence List" Feature as a Modal #539

Merged

Conversation

bai1024
Copy link
Contributor

@bai1024 bai1024 commented Aug 20, 2024

  1. Change the current list interface to a modal design.
  2. Within the modal, Provide table about Silence list
  3. Introduce filter feature within the modal interface.

@bai1024 bai1024 requested a review from a team as a code owner August 20, 2024 02:55
@bai1024 bai1024 force-pushed the implement-silence-list-modal branch from 2c5946e to 0404de6 Compare August 20, 2024 03:05
Copy link
Collaborator

@kfdm kfdm left a comment

Choose a reason for hiding this comment

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

First review pass, but mostly some questions about implementation due to my own ignorance.

promgen/templates/base.html Outdated Show resolved Hide resolved
Comment on lines 393 to 428
hideModal() {
const modal = $('#silenceTableModal');
if (modal.length) {
globalStore.setMessages([]);
this.form.labels = [];
modal.modal('hide');
}
},
showModal() {
const modal = $('#silenceTableModal');
if (modal.length) {
modal.on('hidden.bs.modal', () => {
silenceTableStore.hideModal();
});
modal.modal('show');
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a question asked out of ignorance, but is $ in this case a jQuery object or something built into Vue?
I know we're eventually planning on removing jquery. Typically I thought we were using native javascript object queries for things like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, $ is indeed jQuery, not something built into Vue. We're using it here because our Modal is still using Bootstrap 3, which relies on jQuery for DOM manipulation and event triggering.

promgen/static/js/promgen.vue.js Outdated Show resolved Hide resolved
Comment on lines +374 to +372
activeSilences() {
return this.$root.activeSilences || [];
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we can get a list from activeSilences() it seems like we could do a quick filter on that, to provide a list of suggestions for the matcher label field, and then do something similar for the matcher value based on which label is selected 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, I see. I will look into it.

@bai1024 bai1024 force-pushed the implement-silence-list-modal branch 2 times, most recently from 815a953 to f317ba2 Compare August 23, 2024 02:38
Copy link
Contributor

@vincent-olivert-riera vincent-olivert-riera left a comment

Choose a reason for hiding this comment

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

So now instead of being able to write a custom matcher, we offer the user a selection of existing labels and values. That makes it easier since the user does not even need to type, but removes the possibility to write a regex.
Anyway, for the sake of simplicity I am fine with it. If we want, in the future, we can improve that area to support regex. No problem at all 👍

  • I have made one code suggestion related to the behavior of the filtering, which acts like a logical OR: it returns all silences that match with any of the matchers.
    We want that filtering mechanism to work in the same way as Alertmanager, which is like a logical AND.
    The rest of the code is fine by me.

  • Regarding Git stuff, please put in separate commit all the changes related to the renaming of silence-modal into silence-create-modal.

Good job :)

}

return this.activeSilences.filter(silence => {
return this.state.labels.some(filterLabel => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return this.state.labels.some(filterLabel => {
return this.state.labels.every(filterLabel => {

If we have multiple filters, we want all of them to match. This is the same behavior that Alertmanager has.

Copy link
Contributor Author

@bai1024 bai1024 Sep 9, 2024

Choose a reason for hiding this comment

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

Thank you.
And for this one

Regarding Git stuff, please put in separate commit all the changes related to the renaming of silence-modal into silence-create-modal.

Is it better to make a different PR for that?

Copy link
Contributor

@vincent-olivert-riera vincent-olivert-riera Sep 9, 2024

Choose a reason for hiding this comment

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

Is it better to make a different PR for that?

It is not necessary. Even if they are unrelated changes, it is totally fine to start PRs with refactor commits to better accommodate your actual changes.

So, having one commit for the rename, and another commit for all the changes related to the new silence list modal is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. Updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have tested it in my local environment and works well 👍

Nice job :)

@vincent-olivert-riera vincent-olivert-riera merged commit c0c5a2a into line:master Sep 10, 2024
5 checks passed
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.

3 participants