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

Add Notification Providers #2677

Merged
merged 13 commits into from
Sep 6, 2022
Merged

Add Notification Providers #2677

merged 13 commits into from
Sep 6, 2022

Conversation

joshri
Copy link
Contributor

@joshri joshri commented Aug 31, 2022

Closes #2564

As always, it was a little more complicated than just adding providers as a resource. Channel is an optional value of the Provider spec, and if it wasn't set, I would expect users to be able to filter by undefined, or -. Allowing for undefined values in the DataTable and filtering by - led me to discover that searching by text was not working as expected in Sources and the new Notifications tables (possibly due to the restructuring of objects in the ListObjects request). When I dove into that code...it didn't click with me - we were checking every field before even checking if the textSearchable boolean was true! I rewrote it in a way that clicks with my brain. The tests for text search also were testing for OR values in filtering rather than AND, as in all text filters didn't have to apply for a row to be included, so I rewrote that test to match as well.

Also - a couple props were removed from the Page component as they were unused

image

@joshri joshri added the area/ui Issues that require front-end work label Aug 31, 2022
@@ -17,6 +17,7 @@ function ChipGroup({ className, chips = [], onChipRemove, onClearAll }: Props) {
return (
<Flex className={className} wide align start>
{_.map(chips, (chip, index) => {
if (chip.slice(-1) === ":") chip += " -";
Copy link
Contributor

@opudrovs opudrovs Sep 1, 2022

Choose a reason for hiding this comment

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

Why is this line required? Does it add - to any chip text ending with :?

@opudrovs
Copy link
Contributor

opudrovs commented Sep 1, 2022

  • What is required to see notifications data when testing this branch locally? I see no data.

  • When going to the Notifications page, the first sidebar item (Applications) stays selected, unlike the screenshot. Is it expected?

Screenshot 2022-09-01 at 22 35 26

@opudrovs
Copy link
Contributor

opudrovs commented Sep 1, 2022

@joshri so, we do not have a Settings page at the settings route yet, only only the Notifications page at the notifications route? (I see your comment in the ticket, just want to confirm the route.)

if (typeof f.value === "string") {
return f.value === colName;
fields.forEach((field) => {
if (field.textSearchable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could try adding

if (!field.textSearchable) {
  return;
}

at the beginning to remove this large if wrapping the whole code. It should make forEach move to the next element, but please check it. 🙂

return f.value === colName;
fields.forEach((field) => {
if (field.textSearchable) {
let value;
Copy link
Contributor

Choose a reason for hiding this comment

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

An empty line before this line might make the code more readable.


if (f.sortValue) {
return f.sortValue(row) === value;
for (let i = 0; i < textFilters.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

And an empty line before this line would make reading the code easier.

@@ -78,20 +78,19 @@ const FilterSection = ({
</Text>
</ListItem>
{options.sort().map((option: string, index: number) => {
Copy link
Contributor

@opudrovs opudrovs Sep 1, 2022

Choose a reason for hiding this comment

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

You can use a shorter form here, because you are only returning the ListItem without using any local variables:

{options.sort().map((option: string, index: number) => (
          <ListItem key={index}>
            <ListItemIcon>
              <FormCheckbox
                label=""
                name={`${header}${filterSeparator}${option}`}
              />
            </ListItemIcon>
            <Text color="neutral40" size="small">
              {_.toString(option) || "-"}
            </Text>
          </ListItem>
        ))}

@joshri
Copy link
Contributor Author

joshri commented Sep 2, 2022

@opudrovs try using this yaml to get some providers going. Ripped it from the flux docs here https://fluxcd.io/flux/components/notification/provider

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Provider
metadata:
  name: slack
  namespace: default
spec:
  type: slack
  channel: general
  address: https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
  proxy: https://proxy.corp:8080
  secretRef:
    name: webhook-url
apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Provider
metadata:
  name: msteams
  namespace: flux-system
spec:
  type: msteams
  address: <webhook-url>

@joshri
Copy link
Contributor Author

joshri commented Sep 2, 2022

@opudrovs in regards to the applications tab still being highlighted - the mui tabs component must always have a valid active tab value otherwise you get long console errors. I can look into overriding this more if it's a big issue

@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

@joshri

try using this yaml

Thanks, will try it.

in regards to the applications tab still being highlighted - the mui tabs component must always have a valid active tab value otherwise you get long console errors. I can look into overriding this more if it's a big issue

I would prefer nothing to be selected/highlighted in the sidebar if there is no Notifications item there, because it might look misleading to the user (like they are still in the Applications page). But if it's hard to do it's not a big issue, we can wait until someone actually complains. @ozamosi do you agree or would you prefer to have all sidebar items deselected while we are at the Notifications page?

@ozamosi
Copy link
Contributor

ozamosi commented Sep 2, 2022

But if it's hard to do it's not a big issue, we can wait until someone actually complains. @ozamosi do you agree

Yeah, sounds good. All else being equal I'd not highlight it, but I can also make up excuses for why this behaviour is technically correct (the notifications relates to your flux resources e.g. applications/sources, so we highlight that section header).

@joshri joshri force-pushed the settings-page branch 3 times, most recently from 67aa0f0 to f03dee9 Compare September 2, 2022 18:44
@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

@joshri clicking on an added chip with - does not remove it. Clicking on any other added chip removes it, as expected. Maybe it does not properly detect which chip to remove? The same issue with the hyphen/undefined values in other tables.

@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

When filtering by this hard to read channel, the table is empty:

Screenshot 2022-09-02 at 21 47 34

Screenshot 2022-09-02 at 21 47 47

@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

And when selecting all channels only the general channel is displayed:

Screenshot 2022-09-02 at 21 53 40

@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

Please consider adding tests for filtering with chips with hyphens/undefined values, if it's technically possible.

@opudrovs
Copy link
Contributor

opudrovs commented Sep 2, 2022

I don't think that it is related to this PR directly but the chips when they appear slightly push content down (no matter if FilterDialog pushes content to the left or is displayed over it). I think some space should be reserved for chips:

chips.mov

@joshri
Copy link
Contributor Author

joshri commented Sep 2, 2022

Inability to remove chips with '-' was bc I changed the value of the actual chip in ChipGroup. Added the filterSeparator.

The long channel string included the filterSeparator which was :. Changed it to something that no one will have in there stuff: ---

I also added the filterSeparator variable to all the tests so we can actually change it without breaking everything.

@ozamosi
Copy link
Contributor

ozamosi commented Sep 6, 2022

Could we please pause and take a step back.

We should be able to filter by empty value. This is a really good change. However, this seems like a separate enhancement, so we can make sure it works well together with e.g. tenants.

Among these filtering fixes there's also an important regression fix. This would also be good to have outside of this PR, so we can call it out in our changelog (i.e. "filtering fixes" as a bug fix PR that calls out the regression - not several bug fix PRs).

As for how to filter by empty value, it seems to me that the quick solution didn't work, and we need to solve the problem by structuring the data, so that the representation doesn't matter - as in, if a chip had a property "field" and a property "value", then whether it's rendered as "field:value" or "value@field" or even "I'm feeling lucky" wouldn't matter, because when determining what filter to remove we'd be able to just read the properties.

@joshri
Copy link
Contributor Author

joshri commented Sep 6, 2022

As discussed in standup:

Filtering changes removed from this branch - this leaves some bugs with search and filtering remaining (searching does not work due to ListObjects object restructuring in Sources and Notifications tables, filterDialog displays nothing for undefined values but has a working(?) checkbox). I moved the work I had done on these into the branch filter-undefined in case we want to use it later.

The Applications tab being highlighted on Notifications is also something I don't want to address in this PR. The only ways I can see to override the required value prop are either creating a tab in the nav for notifications and overriding all the styling on it to make it invisible (ew), or to not use the Tabs component from Mui, both of which are large changes.

@opudrovs @ozamosi take another look at the code and the notifications table locally for me and make sure I didn't break it with my lovely interactive rebase THANKS

@joshri joshri requested a review from opudrovs September 6, 2022 15:15
@opudrovs
Copy link
Contributor

opudrovs commented Sep 6, 2022

Can we add delays to the tooltip in UserSettings to prevent tooltip from blinking when the user knows well what they are doing and clicks on the icon fast. Smth. like:

<Tooltip title="Account settings" enterDelay={500} enterNextDelay={500}>

Copy link
Contributor

@opudrovs opudrovs left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

@opudrovs
Copy link
Contributor

opudrovs commented Sep 6, 2022

Tested it, works fine, I didn't test filtering because it will be added in the another PR.

@joshri
Copy link
Contributor Author

joshri commented Sep 6, 2022

Can we add delays to the tooltip in UserSettings to prevent tooltip from blinking when the user knows well what they are doing and clicks on the icon fast. Smth. like:

<Tooltip title="Account settings" enterDelay={500} enterNextDelay={500}>

Yep that exists as a prop in the mui component as enterDelay

@opudrovs
Copy link
Contributor

opudrovs commented Sep 6, 2022

@joshri I guess enterNextDelay is required too. Otherwise it will appear too fast if it already appeared once.

@joshri joshri merged commit f35dbe7 into main Sep 6, 2022
@joshri joshri deleted the settings-page branch September 6, 2022 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui Issues that require front-end work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notifications UI table view
3 participants