-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QueryLink migration and some updates
- Loading branch information
1 parent
45ecc82
commit 92a7419
Showing
3 changed files
with
51 additions
and
8 deletions.
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 |
---|---|---|
@@ -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