Skip to content
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

Relative positioning for Table view tables #3066

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions client/app/scripts/charts/nodes-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { shownNodesSelector } from '../selectors/node-filters';
import { trackAnalyticsEvent } from '../utils/tracking-utils';
import { TABLE_VIEW_MODE } from '../constants/naming';

import { canvasMarginsSelector, canvasHeightSelector } from '../selectors/canvas';
import { windowHeightSelector } from '../selectors/canvas';
import { searchNodeMatchesSelector } from '../selectors/search';
import { getNodeColor } from '../utils/color-utils';

Expand Down Expand Up @@ -86,6 +86,7 @@ class NodesGrid extends React.Component {

this.onClickRow = this.onClickRow.bind(this);
this.onSortChange = this.onSortChange.bind(this);
this.saveTableRef = this.saveTableRef.bind(this);
}

onClickRow(ev, node) {
Expand All @@ -101,16 +102,20 @@ class NodesGrid extends React.Component {
this.props.sortOrderChanged(sortedBy, sortedDesc);
}

saveTableRef(ref) {
this.tableRef = ref;
}

render() {
const {
nodes, height, gridSortedBy, gridSortedDesc, canvasMargins,
searchNodeMatches, searchQuery
nodes, gridSortedBy, gridSortedDesc, searchNodeMatches, searchQuery, windowHeight
} = this.props;
const height =
this.tableRef ? windowHeight - this.tableRef.getBoundingClientRect().top - 30 : 0;
const cmpStyle = {
height,
marginTop: canvasMargins.top,
paddingLeft: canvasMargins.left,
paddingRight: canvasMargins.right,
paddingLeft: 40,
paddingRight: 40,
};
// TODO: What are 24 and 18? Use a comment or extract into constants.
const tbodyHeight = height - 24 - 18;
Expand All @@ -130,7 +135,7 @@ class NodesGrid extends React.Component {
};

return (
<div className="nodes-grid">
<div className="nodes-grid" ref={this.saveTableRef}>
{nodes.size > 0 && <NodeDetailsTable
style={cmpStyle}
className={className}
Expand All @@ -154,15 +159,14 @@ class NodesGrid extends React.Component {
function mapStateToProps(state) {
return {
nodes: shownNodesSelector(state),
canvasMargins: canvasMarginsSelector(state),
height: canvasHeightSelector(state),
gridSortedBy: state.get('gridSortedBy'),
gridSortedDesc: state.get('gridSortedDesc'),
currentTopology: state.get('currentTopology'),
currentTopologyId: state.get('currentTopologyId'),
searchNodeMatches: searchNodeMatchesSelector(state),
searchQuery: state.get('searchQuery'),
selectedNodeId: state.get('selectedNodeId'),
windowHeight: windowHeightSelector(state),
};
}

Expand Down
5 changes: 1 addition & 4 deletions client/app/scripts/constants/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GRAPH_VIEW_MODE, TABLE_VIEW_MODE, RESOURCE_VIEW_MODE } from './naming';
import { GRAPH_VIEW_MODE, RESOURCE_VIEW_MODE } from './naming';


export const DETAILS_PANEL_WIDTH = 420;
Expand Down Expand Up @@ -41,9 +41,6 @@ export const CANVAS_MARGINS = {
[GRAPH_VIEW_MODE]: {
top: 220, left: 80, right: 80, bottom: 150
},
[TABLE_VIEW_MODE]: {
top: 220, left: 40, right: 40, bottom: 30
},
[RESOURCE_VIEW_MODE]: {
top: 200, left: 210, right: 40, bottom: 150
},
Expand Down
11 changes: 11 additions & 0 deletions client/app/scripts/selectors/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import {
} from '../constants/styles';


// Listens in on viewport height state for window height updates.
// Window height is useful as it includes the whole app viewport,
// including e.g. top nav bar in Weave Cloud which is outside of
// Scope app viewport.
export const windowHeightSelector = createSelector(
[
state => state.getIn(['viewport', 'height']),
],
() => window.innerHeight,
);

export const canvasMarginsSelector = createSelector(
[
state => state.get('topologyViewMode'),
Expand Down
6 changes: 1 addition & 5 deletions client/app/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ a {
font-size: 0.7rem;
justify-content: center;
padding: 5px;
position: absolute;
position: fixed;
bottom: 11px;

button {
Expand Down Expand Up @@ -2001,10 +2001,6 @@ a {
//

.nodes-grid {
// TODO: Would be good to have relative positioning here.
position: absolute;
top: 0;

tr {
border-radius: 6px;
}
Expand Down