-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 date picker to silence form views #2262
Add date picker to silence form views #2262
Conversation
Signed-off-by: m-masataka <[email protected]>
Signed-off-by: m-masataka <[email protected]>
Thanks for tackling this one! It seems that the CI isn't happy with your changes yet :) |
Signed-off-by: m-masataka <[email protected]>
Signed-off-by: m-masataka <[email protected]>
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 <[email protected]>
@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 <[email protected]>
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 <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank's. I removed ...Config.
@@ -124,25 +136,50 @@ toSilence { id, comment, matchers, createdBy, startsAt, endsAt } = | |||
|
|||
fromSilence : GettableSilence -> SilenceForm | |||
fromSilence { id, createdBy, comment, startsAt, endsAt, matchers } = | |||
let | |||
startsPosix = | |||
case Utils.Date.timeFromString (DateTime.toString startsAt) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Result.toMaybe
Nothing | ||
|
||
endsPosix = | ||
case Utils.Date.timeFromString (DateTime.toString endsAt) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Result.toMaybe
form.pickedStart | ||
|
||
endsAtTime = | ||
case timeFromString form.endsAt.value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pipe to Result.toMaybe
@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 <[email protected]>
Signed-off-by: m-masataka <[email protected]>
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