Add date picker to silence form views#2262
Conversation
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
Thanks for tackling this one! It seems that the CI isn't happy with your changes yet :) |
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
This looks really good. I guess it would be good to support time too but probably it isn't that easy (at least the component supports only dates)? |
|
should we pick up a component that support both? can we reuse Prometheus' component? |
|
After a brief research I found this component: https://package.elm-lang.org/packages/mercurymedia/elm-datetime-picker/latest/ It supports both date and time, it also supports selecting the duration, which is what we need. I didn't look in depth and what the integration would look like. @m-masataka I wonder if you have checked this one? |
|
Thank you for your comments. |
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
@w0rm Please give me some advice. |
|
@m-masataka feel free to just move this module into Utils! I also think we should get rid of the type alias and just use Posix instead of our DateTime type. |
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
I checked some datetime picker components, but I didn't find the perfect one. |
|
@m-masataka why did you have to inline the third party lib, can you please summarise what was not working in the original? I also wonder whether there might be a copyright issue by inlining the code like this. |
|
@w0rm the original one mostly work fine, it’s just a matter of preference.
That is true for sure. I'll implement full scratch code as needed. |
|
@m-masataka Oh, I see. Sorry, you actually wrote about this before!
|
|
|
Ah sorry, we can avoid any conflict. |
|
@m-masataka I think picking a duration is better, this way a user won't have to open the dialog twice for each date time. This looks pretty good, just the colours need to be tweaked to match what we have so far. @m-masataka I also don't mind if we implement our own datepicker inside alertmanager codebase from scratch. I am just a bit worried that we shouldn't copy paste somebody else's code and sign it off as our own. |
|
Thank you @w0rm. We have some choice
I think 3 (or 4) is better than others. |
|
@m-masataka I fully agree with you that 3 or 4 is better. Will you be willing to contribute a custom date picker (option 4)? Long term I would prefer this option, because it is easier to migrate our own code if a new version of Elm comes up. |
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
Hi @w0rm |
|
cc @juliusv |
|
Looks pretty IMO! I can't review Elm stuff though, I have never touched it :( @w0rm or @simonpasquier? |
|
|
||
|
|
||
| type alias PickerConfig msg = | ||
| { zone : Zone |
There was a problem hiding this comment.
I think it is safe to assume that this is always going to be in utc. You can simplify a lot of code and just use utc everywhere.
| [ text "x" ] | ||
| ] | ||
| , div [ class "modal-body" ] | ||
| [ viewDateTimePicker dateTimePickerConfig form.dateTimePicker ] |
There was a problem hiding this comment.
If we change to use utc everywhere, then viewDateTimePicker could take UpdateDateTimePicker and the dateTimePickerConfig would not be needed.
There was a problem hiding this comment.
Thank's. I removed ...Config.
| fromSilence { id, createdBy, comment, startsAt, endsAt, matchers } = | ||
| let | ||
| startsPosix = | ||
| case Utils.Date.timeFromString (DateTime.toString startsAt) of |
| Nothing | ||
|
|
||
| endsPosix = | ||
| case Utils.Date.timeFromString (DateTime.toString endsAt) of |
| form.pickedStart | ||
|
|
||
| endsAtTime = | ||
| case timeFromString form.endsAt.value of |
|
@m-masataka looks great, thank you for implementing this non trivial feature! I left a few comments that may simplify things a bit. But I am fine if this goes as is. |
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
|
Thanks a lot @m-masataka for the hard work! I'm not really qualified to review the Elm code but I'll trust @w0rm :) |





Added date picker to silence form views to select date easier.

see #2226