feat(explore): Implement data panel redesign (#19751)

* feat(explore): Redesign of data panel

* Auto calculate chart panel height and width

* Add tests

* Fix e2e tests

* Increase collapsed data panel height
This commit is contained in:
Kamil Gabryjelski
2022-04-19 10:10:40 +02:00
committed by GitHub
parent 34323f9b5f
commit 594523e895
6 changed files with 496 additions and 361 deletions

View File

@@ -63,8 +63,6 @@ import ConnectedExploreChartHeader from '../ExploreChartHeader';
const propTypes = {
...ExploreChartPanel.propTypes,
height: PropTypes.string,
width: PropTypes.string,
actions: PropTypes.object.isRequired,
datasource_type: PropTypes.string.isRequired,
dashboardId: PropTypes.number,
@@ -135,6 +133,7 @@ const ExplorePanelContainer = styled.div`
flex: 1;
min-width: ${theme.gridUnit * 128}px;
border-left: 1px solid ${theme.colors.grayscale.light2};
padding: 0 ${theme.gridUnit * 4}px;
.panel {
margin-bottom: 0;
}
@@ -172,23 +171,6 @@ const ExplorePanelContainer = styled.div`
`};
`;
const getWindowSize = () => ({
height: window.innerHeight,
width: window.innerWidth,
});
function useWindowSize({ delayMs = 250 } = {}) {
const [size, setSize] = useState(getWindowSize());
useEffect(() => {
const onWindowResize = debounce(() => setSize(getWindowSize()), delayMs);
window.addEventListener('resize', onWindowResize);
return () => window.removeEventListener('resize', onWindowResize);
}, []);
return size;
}
const updateHistory = debounce(
async (formData, datasetId, isReplace, standalone, force, title, tabId) => {
const payload = { ...formData };
@@ -246,7 +228,6 @@ function ExploreViewContainer(props) {
const [lastQueriedControls, setLastQueriedControls] = useState(
props.controls,
);
const windowSize = useWindowSize();
const [showingModal, setShowingModal] = useState(false);
const [isCollapsed, setIsCollapsed] = useState(false);
@@ -254,11 +235,6 @@ function ExploreViewContainer(props) {
const tabId = useTabId();
const theme = useTheme();
const width = `${windowSize.width}px`;
const navHeight = props.standalone ? 0 : 120;
const height = props.forcedHeight
? `${props.forcedHeight}px`
: `${windowSize.height - navHeight}px`;
const defaultSidebarsWidth = {
controls_width: 320,
@@ -515,8 +491,6 @@ function ExploreViewContainer(props) {
function renderChartContainer() {
return (
<ExploreChartPanel
width={width}
height={height}
{...props}
errorMessage={errorMessage}
refreshOverlayVisible={chartIsStale}