-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Migrate Dashboards/Queries/Users list pages to React #3381
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
Merged
arikfr
merged 40 commits into
getredash:master
from
kravets-levko:feature/react-list-controllers
Feb 5, 2019
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
8e6d6b6
Refine existing implementation of dashboards/queries/users lists and …
kravets-levko 0dff4a5
Migrate common list page controller to React and refactor it's logic
kravets-levko ec5d46f
Migrate Dashboard list page to React
kravets-levko 77ce09d
Migrate Queries list page to React
kravets-levko 88297f7
Migrate Users list page to React
kravets-levko efed0e0
Merge branch 'master' into feature/react-list-controllers
kravets-levko 7c82ab4
Merge branch 'master' into feature/react-list-controllers
kravets-levko 02bd99d
Merge branch 'master' into feature/react-list-controllers
kravets-levko fb8f624
Remove react-timeago dependency
kravets-levko 834f942
Use composition instead of inheritance
kravets-levko d92df5c
Refine implementation
kravets-levko a75d63c
Merge sidebar into single component
kravets-levko 683e75a
Refine column definitions
kravets-levko 72c0099
Merge branch 'master' into feature/react-list-controllers
kravets-levko 78ebb21
Use simple controller instead of React context
kravets-levko 1b013d3
Refine implementation
kravets-levko ccf3deb
Merge branch 'master' into feature/react-list-controllers
kravets-levko 5171317
Restore changes from getredash/redash#2888
kravets-levko 01e999a
Tweak Users list page
kravets-levko 2d3aed6
Ability to render dynamically defined components
kravets-levko ef7436d
Tweak users list page
kravets-levko aaaf894
User list page for non-admins
kravets-levko 8a57ded
Fix: ItemsTable ignores isAvailable field
kravets-levko 6412859
Refine implementation
kravets-levko c419340
Refine implementation
kravets-levko e40b266
Merge branch 'master' into feature/react-list-controllers
kravets-levko 1785a8c
Implement LiveItemsList as higher order component
kravets-levko f8445f3
Some fixes
kravets-levko dcf22cd
Move some definitions to a better place
kravets-levko e56d2f6
Some fixes
kravets-levko b0b1873
Refine components
kravets-levko fcdd864
Refine UsersList page
kravets-levko 706e4bc
Merge branch 'master' into feature/react-list-controllers
kravets-levko 26bff4a
More comments for a god of comments
kravets-levko b9fb9d0
Merge branch 'master' into feature/react-list-controllers
kravets-levko 3b1055c
Fix wrong tables size on smaller screens
kravets-levko 73bbeab
Merge branch 'master' into feature/react-list-controllers
kravets-levko 64bc61f
Tweak tables
kravets-levko 3fef4ad
Merge branch 'master' into feature/react-list-controllers
arikfr 7e9eea9
Merge branch 'master' into feature/react-list-controllers
kravets-levko 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 { isFunction, isString } from 'lodash'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const componentsRegistry = new Map(); | ||
const activeInstances = new Set(); | ||
|
||
export function registerComponent(name, component) { | ||
if (isString(name) && (name !== '')) { | ||
componentsRegistry[name] = isFunction(component) ? component : null; | ||
// Refresh active DynamicComponent instances which use this component | ||
activeInstances.forEach((dynamicComponent) => { | ||
if (dynamicComponent.props.name === name) { | ||
dynamicComponent.forceUpdate(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export function unregisterComponent(name) { | ||
registerComponent(name, null); | ||
} | ||
|
||
export default class DynamicComponent extends React.Component { | ||
static propTypes = { | ||
name: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
}; | ||
|
||
static defaultProps = { | ||
children: null, | ||
}; | ||
|
||
componentDidMount() { | ||
activeInstances.add(this); | ||
} | ||
|
||
componentWillUnmount() { | ||
activeInstances.delete(this); | ||
} | ||
|
||
render() { | ||
const { name, children, ...props } = this.props; | ||
const RealComponent = componentsRegistry.get(name); | ||
if (!RealComponent) { | ||
return null; | ||
} | ||
return <RealComponent {...props}>{children}</RealComponent>; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.