-
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
Migrate Widget component to React #4020
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a02ce8f
Improve sizing for Number inputs
gabrieldutra 97bfcd3
Migrate WidgetDialog
gabrieldutra d415c5e
Start migrating Widget
gabrieldutra b7cbf80
Update textbox to use HtmlContent
gabrieldutra 4413063
QueryLink migration and some updates
gabrieldutra 1b9d002
Add visualization rendering
gabrieldutra 673f6c8
Render widget
gabrieldutra 0d95996
Add delete button
gabrieldutra dd9fd35
Update AutoHeight
gabrieldutra ca01216
Add widget bottom
gabrieldutra 7738c9e
Add Drodpown button
gabrieldutra ffcb419
Split Widget component
gabrieldutra 45618c3
Update with #4056 and trigger netlify
gabrieldutra 3ba42c0
In progress: use composition
gabrieldutra a7f6d41
Add header and footer
gabrieldutra 5021b44
Update widget actions positioning
gabrieldutra a34ad85
Re-render when refreshing from widget
gabrieldutra 71f6e8f
Add workaround to force DashboardGrid re-render
gabrieldutra 1622f84
VisualizationWidgetFooter component
gabrieldutra a5ab07d
VisualizationWidget menu
gabrieldutra 5f66382
Separate RestrictedWidget
gabrieldutra 8838e97
Update tests
gabrieldutra 584200c
Update margin for Parameters
gabrieldutra daf21ac
Merge branch 'master' into react-widget
gabrieldutra 9f269c1
Remove widget files
gabrieldutra 7f6bcd7
Revert "Improve sizing for Number inputs"
gabrieldutra 111b68e
Some cleanup
gabrieldutra b81a555
Merge branch 'master' into react-widget
gabrieldutra 6d6f81a
Move refresh logic to the Dashboard
gabrieldutra 83e7149
Add loadingWidgets logic to the public dashboard
gabrieldutra ade0b48
Merge branch 'master' into react-widget
gabrieldutra da6e93e
Add onLoadWidget
gabrieldutra 5b3e9b9
Remove parameter from URL when empty
gabrieldutra 7f24c27
Recreate widget array instead of loadingWidgets
gabrieldutra 4716d4b
Add comment about re-rendering + whitespace missing
gabrieldutra 72da894
Merge branch 'master' into react-widget
gabrieldutra cd69e16
CR changes
gabrieldutra 80897e4
Use plain html instead of string syntax
gabrieldutra 3f49b59
Merge branch 'master' into react-widget
gabrieldutra 97f402a
Merge branch 'react-widget' of github.com:getredash/redash into react…
gabrieldutra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
visualization-renderer { | ||
.visualization-renderer { | ||
display: block; | ||
|
||
.pagination, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.pivot-table-renderer > table, | ||
visualization-renderer > .visualization-renderer-wrapper { | ||
.visualization-renderer > .visualization-renderer-wrapper { | ||
overflow: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { VisualizationType } from '@/visualizations'; | ||
import { VisualizationName } from '@/visualizations/VisualizationName'; | ||
|
||
function QueryLink({ query, visualization, readOnly }) { | ||
const getUrl = () => { | ||
let hash = null; | ||
if (visualization) { | ||
if (visualization.type === 'TABLE') { | ||
// link to hard-coded table tab instead of the (hidden) visualization tab | ||
hash = 'table'; | ||
} else { | ||
hash = visualization.id; | ||
} | ||
} | ||
|
||
return query.getUrl(false, hash); | ||
}; | ||
|
||
return ( | ||
<a href={readOnly ? null : getUrl()} className="query-link"> | ||
<VisualizationName visualization={visualization} />{' '} | ||
<span>{query.name}</span> | ||
</a> | ||
); | ||
} | ||
|
||
QueryLink.propTypes = { | ||
query: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types | ||
visualization: VisualizationType, | ||
readOnly: PropTypes.bool, | ||
}; | ||
|
||
QueryLink.defaultProps = { | ||
visualization: null, | ||
readOnly: false, | ||
}; | ||
|
||
export default QueryLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Button from 'antd/lib/button'; | ||
import Modal from 'antd/lib/modal'; | ||
import { VisualizationRenderer } from '@/visualizations/VisualizationRenderer'; | ||
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper'; | ||
import { VisualizationName } from '@/visualizations/VisualizationName'; | ||
|
||
function ExpandedWidgetDialog({ dialog, widget }) { | ||
return ( | ||
<Modal | ||
{...dialog.props} | ||
title={( | ||
<> | ||
<VisualizationName visualization={widget.visualization} />{' '} | ||
<span>{widget.getQuery().name}</span> | ||
</> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. He-he, GitHub has issues with parsing |
||
)} | ||
width="95%" | ||
footer={(<Button onClick={dialog.dismiss}>Close</Button>)} | ||
> | ||
<VisualizationRenderer | ||
visualization={widget.visualization} | ||
queryResult={widget.getQueryResult()} | ||
context="widget" | ||
/> | ||
</Modal> | ||
); | ||
} | ||
|
||
ExpandedWidgetDialog.propTypes = { | ||
dialog: DialogPropType.isRequired, | ||
widget: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types | ||
}; | ||
|
||
export default wrapDialog(ExpandedWidgetDialog); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
client/app/components/dashboards/dashboard-widget/RestrictedWidget.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import Widget from './Widget'; | ||
|
||
function RestrictedWidget(props) { | ||
return ( | ||
<Widget {...props} className="d-flex justify-content-center align-items-center widget-restricted"> | ||
<div className="t-body scrollbox"> | ||
<div className="text-center"> | ||
<h1><span className="zmdi zmdi-lock" /></h1> | ||
<p className="text-muted"> | ||
This widget requires access to a data source you don't have access to. | ||
</p> | ||
</div> | ||
</div> | ||
</Widget> | ||
); | ||
} | ||
|
||
export default RestrictedWidget; |
50 changes: 50 additions & 0 deletions
50
client/app/components/dashboards/dashboard-widget/TextboxWidget.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { markdown } from 'markdown'; | ||
import Menu from 'antd/lib/menu'; | ||
import HtmlContent from '@/components/HtmlContent'; | ||
import TextboxDialog from '@/components/dashboards/TextboxDialog'; | ||
import Widget from './Widget'; | ||
|
||
function TextboxWidget(props) { | ||
const { widget, canEdit } = props; | ||
const [text, setText] = useState(widget.text); | ||
|
||
const editTextBox = () => { | ||
TextboxDialog.showModal({ | ||
text: widget.text, | ||
onConfirm: (newText) => { | ||
widget.text = newText; | ||
setText(newText); | ||
return widget.save(); | ||
}, | ||
}); | ||
}; | ||
|
||
const TextboxMenuOptions = [ | ||
<Menu.Item key="edit" onClick={editTextBox}>Edit</Menu.Item>, | ||
]; | ||
|
||
if (!widget.width) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Widget {...props} menuOptions={canEdit ? TextboxMenuOptions : null} className="widget-text"> | ||
<HtmlContent className="body-row-auto scrollbox t-body p-15 markdown"> | ||
{markdown.toHTML(text || '')} | ||
</HtmlContent> | ||
</Widget> | ||
); | ||
} | ||
|
||
TextboxWidget.propTypes = { | ||
widget: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types | ||
canEdit: PropTypes.bool, | ||
}; | ||
|
||
TextboxWidget.defaultProps = { | ||
canEdit: false, | ||
}; | ||
|
||
export default TextboxWidget; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
On the Dashboard context it needs to have the url updated before triggering
onValuesChange