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

Improve list pages layout #3482

Merged
merged 1 commit into from
Feb 22, 2019
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
18 changes: 0 additions & 18 deletions client/app/assets/less/redash/redash-newstyle.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@ body {
border-left-color: #1b809e;
}

.list-content {
@media (min-width: 992px) {
padding-right: 0;
}
}

.list-control-r-b {
@media (max-width: 992px) {
display: none;
}
}

.list-control-t {
@media (min-width: 992px) {
display: none;
}
}

// Fixed width layout for specific pages
@media (min-width: 768px) {
settings-screen, home-page, page-dashboard-list, page-queries-list, alerts-list-page, alert-page, queries-search-results-page, .fixed-container {
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/groups/DetailsPageSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function DetailsPageSidebar({
{canRemove && (
<React.Fragment>
<Divider dashed className="m-t-10 m-b-10" />
<DeleteGroupButton className="w-100 m-b-15" group={group} onClick={onGroupDeleted}>Delete Group</DeleteGroupButton>
<DeleteGroupButton className="w-100" group={group} onClick={onGroupDeleted}>Delete Group</DeleteGroupButton>
</React.Fragment>
)}
</React.Fragment>
Expand Down
53 changes: 53 additions & 0 deletions client/app/components/layouts/ContentWithSidebar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import './content-with-sidebar.less';

const propTypes = {
className: PropTypes.string,
children: PropTypes.node,
};

const defaultProps = {
className: null,
children: null,
};

// Sidebar

function Sidebar({ className, children, ...props }) {
return (
<div className={classNames('layout-sidebar', className)} {...props}>
<div>{children}</div>
</div>
);
}

Sidebar.propTypes = propTypes;
Sidebar.defaultProps = defaultProps;

// Content

function Content({ className, children, ...props }) {
return (
<div className={classNames('layout-content', className)} {...props}>
<div>{children}</div>
</div>
);
}

Content.propTypes = propTypes;
Content.defaultProps = defaultProps;

// Layout

export default function Layout({ className, children, ...props }) {
return <div className={classNames('layout-with-sidebar', className)} {...props}>{children}</div>;
}

Layout.propTypes = propTypes;
Layout.defaultProps = defaultProps;

Layout.Sidebar = Sidebar;
Layout.Content = Content;
42 changes: 42 additions & 0 deletions client/app/components/layouts/content-with-sidebar.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.layout-with-sidebar {
@spacing: 15px;
position: relative;

display: flex;
align-items: stretch;
justify-content: stretch;
flex-direction: row;
margin: 0;

> .layout-content {
flex: 0 0 auto;
width: 75%;
order: 0;
margin: 0;
}

> .layout-sidebar {
flex: 0 0 auto;
width: 25%;
order: 1;
margin: 0;
padding: 0 0 0 @spacing;
}

@media (max-width: 990px) {
flex-direction: column;

> .layout-content {
width: 100%;
order: 1;
margin: 0;
}

> .layout-sidebar {
width: 100%;
order: 0;
margin: 0 0 @spacing 0;
padding: 0;
}
}
}
47 changes: 20 additions & 27 deletions client/app/pages/dashboards/DashboardList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import LoadingState from '@/components/items-list/components/LoadingState';
import * as Sidebar from '@/components/items-list/components/Sidebar';
import ItemsTable, { Columns } from '@/components/items-list/components/ItemsTable';

import Layout from '@/components/layouts/ContentWithSidebar';

import { Dashboard } from '@/services/dashboard';
import navigateTo from '@/services/navigateTo';
import { routesToAngularRoutes } from '@/lib/utils';
Expand Down Expand Up @@ -68,35 +70,27 @@ class DashboardList extends React.Component {

onTableRowClick = (event, item) => navigateTo('dashboard/' + item.slug);

renderSidebar() {
const { controller } = this.props;
return (
<React.Fragment>
<Sidebar.SearchInput
placeholder="Search Dashboards..."
value={controller.searchTerm}
onChange={controller.updateSearch}
/>
<Sidebar.Menu items={this.sidebarMenu} selected={controller.params.currentPage} />
<Sidebar.Tags url="api/dashboards/tags" onChange={controller.updateSelectedTags} />
<Sidebar.PageSizeSelect
options={controller.pageSizeOptions}
value={controller.itemsPerPage}
onChange={itemsPerPage => controller.updatePagination({ itemsPerPage })}
/>
</React.Fragment>
);
}

render() {
const sidebar = this.renderSidebar();
const { controller } = this.props;
return (
<div className="container">
<PageHeader title={controller.params.title} />
<div className="row">
<div className="col-md-3 list-control-t">{sidebar}</div>
<div className="list-content col-md-9">
<Layout className="m-l-15 m-r-15">
<Layout.Sidebar className="m-b-0">
<Sidebar.SearchInput
placeholder="Search Dashboards..."
value={controller.searchTerm}
onChange={controller.updateSearch}
/>
<Sidebar.Menu items={this.sidebarMenu} selected={controller.params.currentPage} />
<Sidebar.Tags url="api/dashboards/tags" onChange={controller.updateSelectedTags} />
<Sidebar.PageSizeSelect
options={controller.pageSizeOptions}
value={controller.itemsPerPage}
onChange={itemsPerPage => controller.updatePagination({ itemsPerPage })}
/>
</Layout.Sidebar>
<Layout.Content>
{!controller.isLoaded && <LoadingState />}
{
controller.isLoaded && controller.isEmpty && (
Expand Down Expand Up @@ -127,9 +121,8 @@ class DashboardList extends React.Component {
</div>
)
}
</div>
<div className="col-md-3 list-control-r-b">{sidebar}</div>
</div>
</Layout.Content>
</Layout>
</div>
);
}
Expand Down
32 changes: 15 additions & 17 deletions client/app/pages/groups/GroupDataSources.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { DataSourcePreviewCard } from '@/components/PreviewCard';
import GroupName from '@/components/groups/GroupName';
import ListItemAddon from '@/components/groups/ListItemAddon';
import Sidebar from '@/components/groups/DetailsPageSidebar';
import Layout from '@/components/layouts/ContentWithSidebar';

import { toastr } from '@/services/ng';
import { currentUser } from '@/services/auth';
Expand Down Expand Up @@ -164,23 +165,21 @@ class GroupDataSources extends React.Component {

render() {
const { controller } = this.props;
const sidebar = (
<Sidebar
controller={controller}
group={this.group}
items={this.sidebarMenu}
canAddDataSources={currentUser.isAdmin}
onAddDataSourcesClick={this.addDataSources}
onGroupDeleted={() => navigateTo('/groups', true)}
/>
);

return (
<div data-test="Group">
<GroupName className="d-block m-t-0 m-b-15" group={this.group} onChange={() => this.forceUpdate()} />
<div className="row">
<div className="col-md-3 list-control-t">{sidebar}</div>
<div className="list-content col-md-9">
<Layout>
<Layout.Sidebar>
<Sidebar
controller={controller}
group={this.group}
items={this.sidebarMenu}
canAddDataSources={currentUser.isAdmin}
onAddDataSourcesClick={this.addDataSources}
onGroupDeleted={() => navigateTo('/groups', true)}
/>
</Layout.Sidebar>
<Layout.Content>
{!controller.isLoaded && <LoadingState className="" />}
{controller.isLoaded && controller.isEmpty && (
<div className="text-center">
Expand Down Expand Up @@ -215,9 +214,8 @@ class GroupDataSources extends React.Component {
</div>
)
}
</div>
<div className="col-md-3 list-control-r-b">{sidebar}</div>
</div>
</Layout.Content>
</Layout>
</div>
);
}
Expand Down
32 changes: 15 additions & 17 deletions client/app/pages/groups/GroupMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { UserPreviewCard } from '@/components/PreviewCard';
import GroupName from '@/components/groups/GroupName';
import ListItemAddon from '@/components/groups/ListItemAddon';
import Sidebar from '@/components/groups/DetailsPageSidebar';
import Layout from '@/components/layouts/ContentWithSidebar';

import { toastr } from '@/services/ng';
import { currentUser } from '@/services/auth';
Expand Down Expand Up @@ -129,23 +130,21 @@ class GroupMembers extends React.Component {

render() {
const { controller } = this.props;
const sidebar = (
<Sidebar
controller={controller}
group={this.group}
items={this.sidebarMenu}
canAddMembers={currentUser.isAdmin}
onAddMembersClick={this.addMembers}
onGroupDeleted={() => navigateTo('/groups', true)}
/>
);

return (
<div data-test="Group">
<GroupName className="d-block m-t-0 m-b-15" group={this.group} onChange={() => this.forceUpdate()} />
<div className="row">
<div className="col-md-3 list-control-t">{sidebar}</div>
<div className="list-content col-md-9">
<Layout>
<Layout.Sidebar>
<Sidebar
controller={controller}
group={this.group}
items={this.sidebarMenu}
canAddMembers={currentUser.isAdmin}
onAddMembersClick={this.addMembers}
onGroupDeleted={() => navigateTo('/groups', true)}
/>
</Layout.Sidebar>
<Layout.Content>
{!controller.isLoaded && <LoadingState className="" />}
{controller.isLoaded && controller.isEmpty && (
<div className="text-center">
Expand Down Expand Up @@ -180,9 +179,8 @@ class GroupMembers extends React.Component {
</div>
)
}
</div>
<div className="col-md-3 list-control-r-b">{sidebar}</div>
</div>
</Layout.Content>
</Layout>
</div>
);
}
Expand Down
47 changes: 20 additions & 27 deletions client/app/pages/queries-list/QueriesList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import LoadingState from '@/components/items-list/components/LoadingState';
import * as Sidebar from '@/components/items-list/components/Sidebar';
import ItemsTable, { Columns } from '@/components/items-list/components/ItemsTable';

import Layout from '@/components/layouts/ContentWithSidebar';

import { Query } from '@/services/query';
import { currentUser } from '@/services/auth';
import navigateTo from '@/services/navigateTo';
Expand Down Expand Up @@ -84,35 +86,27 @@ class QueriesList extends React.Component {

onTableRowClick = (event, item) => navigateTo('queries/' + item.id);

renderSidebar() {
const { controller } = this.props;
return (
<React.Fragment>
<Sidebar.SearchInput
placeholder="Search Queries..."
value={controller.searchTerm}
onChange={controller.updateSearch}
/>
<Sidebar.Menu items={this.sidebarMenu} selected={controller.params.currentPage} />
<Sidebar.Tags url="api/queries/tags" onChange={controller.updateSelectedTags} />
<Sidebar.PageSizeSelect
options={controller.pageSizeOptions}
value={controller.itemsPerPage}
onChange={itemsPerPage => controller.updatePagination({ itemsPerPage })}
/>
</React.Fragment>
);
}

render() {
const sidebar = this.renderSidebar();
const { controller } = this.props;
return (
<div className="container">
<PageHeader title={controller.params.title} />
<div className="row">
<div className="col-md-3 list-control-t">{sidebar}</div>
<div className="list-content col-md-9">
<Layout className="m-l-15 m-r-15">
<Layout.Sidebar className="m-b-0">
<Sidebar.SearchInput
placeholder="Search Queries..."
value={controller.searchTerm}
onChange={controller.updateSearch}
/>
<Sidebar.Menu items={this.sidebarMenu} selected={controller.params.currentPage} />
<Sidebar.Tags url="api/queries/tags" onChange={controller.updateSelectedTags} />
<Sidebar.PageSizeSelect
options={controller.pageSizeOptions}
value={controller.itemsPerPage}
onChange={itemsPerPage => controller.updatePagination({ itemsPerPage })}
/>
</Layout.Sidebar>
<Layout.Content>
{!controller.isLoaded && <LoadingState />}
{
controller.isLoaded && controller.isEmpty && (
Expand Down Expand Up @@ -143,9 +137,8 @@ class QueriesList extends React.Component {
</div>
)
}
</div>
<div className="col-md-3 list-control-r-b">{sidebar}</div>
</div>
</Layout.Content>
</Layout>
</div>
);
}
Expand Down
Loading