-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Separated Alert to View / Edit / New page components #4183
Conversation
alert: AlertType.isRequired, | ||
queryResult: PropTypes.object, // eslint-disable-line react/forbid-prop-types, | ||
pendingRearm: PropTypes.number, | ||
delete: PropTypes.func.isRequired, |
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 keep breaking Github @kravets-levko :)
{ | ||
path: '/alerts/new', | ||
title: 'New Alert', | ||
mode: MODES.NEW, |
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.
Why not have each path render its own component? What's the purpose of having a single top level page component? To share the callback functions?
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.
Yes. Less code duplication
Also allows alert
, query
and queryResult
to be props instead of state, simplifying the page components.
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.
Also allows this, which imo is more elegant than redirection to view page:
redash/client/app/pages/alert/Alert.jsx
Lines 68 to 71 in 9aeccb4
// force view mode if can't edit | |
if (!canEdit) { | |
this.setState({ mode: MODES.VIEW }); | |
} |
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 could use composition instead:
<AlertPage ...>
<EditAlertPage ...>
</AlertPage>
But the ability to change states without making API request is a win. In the long run, we should find a way to do this without as this pattern isn't always applicable. But here it's fine.
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.
But the ability to change states without making API request is a win.
Are you sure that's happening here? Changing Alert states mandates url changes which causes page to reload (navigateTo
).
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.
Oops, I misunderstood your previous comment. I thought this was what
happens when you switch between view and edit.
I don't think that just rendering the view page when you hit the edit url
is the thing to do. At the very least we should show a message saying you
don't have permission to edit.
But we could do all that with composition as well. No need for a single
component. No need to change it now though, it's not important enough and
better to focus on other aspects of the alert PRs.
…On Thu, Sep 26, 2019, 05:44 Ran Byron ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In client/app/pages/alert/Alert.jsx
<#4183 (comment)>:
> @@ -383,14 +194,20 @@ export default function init(ngModule) {
ngModule.component('alertPage', react2angular(AlertPage));
return routesToAngularRoutes([
+ {
+ path: '/alerts/new',
+ title: 'New Alert',
+ mode: MODES.NEW,
*But* the ability to change states without making API request is a win.
Are you sure that's happening here? Changing Alert states mandates url
changes which causes page to reload (navigateTo).
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#4183?email_source=notifications&email_token=AAAROLD2MWMMLCP7W37JZ5DQLQOZHA5CNFSM4I2CWKM2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCF65D5Y#discussion_r328414709>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAROLFCV2GKQZXYTYTR7FLQLQOZHANCNFSM4I2CWKMQ>
.
|
That's not the case. The edit button doesn't get rendered if the user can't edit the alert. |
I know and still I think it has the potential to confuse people who did expect to edit the alert using this URL. Even showing a notification saying something like "You do not have permission to edit this Alert." is probably enough. Not a huge priority. |
Was also an ez change eecb6d3 As long as you're ok with the prompt being a notification (cause it's easy): And instead of hiding action buttons they're disabled with a tooltip: |
eecb6d3
to
2efcd2c
Compare
Merged. |
Description
By request in comment for separation of mega file, now Alert.jsx renders:
Also, made abstracted the alert name component into: