Skip to content

Commit

Permalink
1628 Move Toolbar & Admin View is Dashboard (#1723)
Browse files Browse the repository at this point in the history
* Moving toolbars

Moved Admin toolbar (vertical one) to the left
Moved DashboardHeader template region to top
Moved ProductDetailsSimple toolbar into own component ( ProductToolbar )
Moved ProductToolbar to DashboardHeader template region in registry

* Adding react switch control

Updating button component to allow for better toggling
Update product toolbar and publish bar

* Improve layout and styles for switch component

* Clean up styles related to publish bar

* Toolbar reorg (#1713)

* Move dashboard to admin controls drawer

* admin links in account dropdown to open action view

* Added navigation stack to action view

Added back button to settings panel

* Added package list component for dashboard package list

Added List and ListItem components

* Code cleanup
Added basic styles for lists

* Adding react ActionView component

* Added blaze react package

Fixing imports for actionView

* Added admin context provider

AdminContextProvider provides context props to all components wrapped
as Admin() components.

* CSS-IN-JS styles for admin view header with animations

* Added add product button

Added icon button with Reaction logo to open actionView

* Package list re-org

* Filter entries with a template

* Added detail view to action view

* cleanup

* Fix for missing grid settings view in action view

* Split generic toolbar and publish bar functionality

* Fix action view close on orders view

Remove legacy functionality in orders template that interferes with the
action view close.

* Cleanup

* Cleanup

Remove filter controls from orders list

* Open shipping details in action detail view

* Moved add product functionality to generic admin toolbar

Moving add product callback function from the publish controls into the
admin toolbar.

* Only show vertical divider if there is a dashboardHeaderTemplate

Cleanup of propTypes

* Allow for no loading templates

Fixes issue where the publish controls would display a large loading
spinner causing the toolbar to resize briefly.

* Clear action view on close to prevent odd behavior. Will revisit.

Other various cleanup of source

* Fixed broken preview toggle

Fix eslint issues

* Fix archive product. Should pass full product object, not _id
  • Loading branch information
mikemurray authored and kieckhafer committed Jan 19, 2017
1 parent 06a2fbe commit 886ab2f
Show file tree
Hide file tree
Showing 57 changed files with 1,743 additions and 254 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ johanbrook:publication-collector


# Custom Packages
gadicc:blaze-react-component
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
gadicc:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down
5 changes: 4 additions & 1 deletion client/modules/accounts/templates/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ Template.loginDropdown.events({
});
}
});
} else if (this.route || this.name) {
} else if (this.name !== "account/profile") {
event.preventDefault();
/** TMP **/
Reaction.showActionView(this);
} else if (this.route || this.name) {
const route = this.name || this.route;
Reaction.Router.go(route);
}
Expand Down
92 changes: 88 additions & 4 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default {

setActionView(viewData) {
if (viewData) {
Session.set("admin/actionView", viewData);
Session.set("admin/actionView", [viewData]);
} else {
const registryItem = this.getRegistryForCurrentRoute(
"settings");
Expand All @@ -266,19 +266,103 @@ export default {
}
},

pushActionView(viewData) {
Session.set("admin/showActionView", true);

const actionViewStack = Session.get("admin/actionView");

if (viewData) {
actionViewStack.push(viewData);
Session.set("admin/actionView", actionViewStack);
} else {
const registryItem = this.getRegistryForCurrentRoute(
"settings");

if (registryItem) {
this.pushActionView(registryItem);
} else {
this.pushActionView({ template: "blankControls" });
}
}
},

isActionViewAtRootView() {
const actionViewStack = Session.get("admin/actionView");

if (Array.isArray(actionViewStack) && actionViewStack.length === 1) {
return true;
}

return false;
},

popActionView() {
const actionViewStack = Session.get("admin/actionView");
actionViewStack.pop();

Session.set("admin/actionView", actionViewStack);

this.setActionViewDetail({});
},

setActionViewDetail(viewData) {
if (viewData) {
Session.set("admin/detailView", [viewData]);
}
},

pushActionViewDetail(viewData) {
Session.set("admin/showActionView", true);

const detailViewStack = Session.get("admin/detailView");

if (viewData) {
detailViewStack.push(viewData);
Session.set("admin/detailView", detailViewStack);
}
},

popActionViewDetail() {
const detailViewStack = Session.get("admin/detailView");
detailViewStack.pop();

Session.set("admin/detailView", detailViewStack);
},

getActionView() {
return Session.get("admin/actionView") || {};
const actionViewStack = Session.get("admin/actionView");

if (Array.isArray(actionViewStack) && actionViewStack.length) {
return actionViewStack.pop();
}

return {};
},

getActionViewDetail() {
const detailViewStack = Session.get("admin/detailView");

if (Array.isArray(detailViewStack) && detailViewStack.length) {
return detailViewStack.pop();
}

return {};
},

hideActionView() {
Session.set("admin/showActionView", false);
this.clearActionView();
},

clearActionView() {
Session.set("admin/actionView", {
Session.set("admin/actionView", [{
label: "",
i18nKeyLabel: ""
});
}]);
Session.set("admin/detailView", [{
label: "",
i18nKeyLabel: ""
}]);
},

getCurrentTag() {
Expand Down
232 changes: 232 additions & 0 deletions imports/plugins/core/dashboard/client/components/actionView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
import React, { Component, PropTypes } from "react";
import classnames from "classnames";
import Blaze from "meteor/gadicc:blaze-react-component";
import {
IconButton,
Translation
} from "/imports/plugins/core/ui/client/components";
import { Admin } from "/imports/plugins/core/ui/client/providers";
import Radium from "radium";
import Velocity from "velocity-animate";
import "velocity-animate/velocity.ui";
import { VelocityTransitionGroup } from "velocity-react";

const getStyles = (props) => {
let viewSize = 400;
// if (props.actionView && props.actionView.priority === 1 && props.actionView.provides === "dashboard") {
if (props.actionView && props.actionView.provides === "dashboard") {
viewSize = "90vw";
}

if (props.actionViewIsOpen === false) {
viewSize = 0;
}

return {
base: {
display: "flex",
flexDirection: "column",
height: "100vh",
position: "relative",
width: viewSize
},
header: {
display: "flex",
alignItems: "center",
position: "relative",
height: "56px",
padding: "0 20px",
margin: 0
},
heading: {
display: "flex",
alignItems: "center",
flex: "1 1 auto",
position: "relative",
margin: 0,
height: "100%"
},
body: {
display: "flex",
webkitOverflowScrolling: "touch"
},
masterView: {
flex: "1 1 auto",
height: "100%",
overflow: "auto",
webkitOverflowScrolling: "touch"
},
detailView: {
width: "400px",
height: "100%",
overflow: "auto",
webkitOverflowScrolling: "touch"
},
title: {
margin: 0,
transition: "200ms all"
},
titleWithBackButton: {
paddingLeft: 40
},
backButton: {
height: "100%",
position: "absolute",
top: 0,
zIndex: 1
},
backButtonContainers: {
display: "flex",
alignItems: "center",
height: "100%"
}
};
};

class ActionView extends Component {
static propTypes = {
actionView: PropTypes.object,
actionViewIsOpen: PropTypes.bool,
buttons: PropTypes.array,
isActionViewAtRootView: PropTypes.bool
}

renderControlComponent() {
if (this.props.actionView && typeof this.props.actionView.template === "string") {
return (
<div style={this.styles.masterView} className="master">
<Blaze
{...this.props.actionView.data}
template={this.props.actionView.template}
/>
</div>
);
}

return null;
}

renderDetailComponent() {
if (this.props.detailView && typeof this.props.detailView.template === "string") {
return (
<div style={this.styles.detailView} className="detail">
<Blaze
{...this.props.detailView.data}
template={this.props.detailView.template}
/>
</div>
);
}

return null;
}

renderFooter() {
// if (this.props.footerTemplate) {
// return (
// <Blaze template={this.props.footerTemplate} />
// );
// }
}

renderBackButton() {
if (this.props.isActionViewAtRootView === false) {
return (
<div style={this.styles.backButton}>
<div style={this.styles.backButtonContainers}>
<IconButton
icon="fa fa-arrow-left"
onClick={this.props.handleActionViewBack}
/>
</div>
</div>
);
}
}

get styles() {
return getStyles(this.props);
}

get backButtonEnterAnimation() {
return {
animation: {
display: "flex",
position: "absolute",
left: 20,
opaticy: 1
},
duration: 200
};
}

get backButtonLeaveAnimaton() {
return {
animation: {
display: "flex",
position: "absolute",
left: -30,
opaticy: 0
},
duration: 200

};
}

render() {
const { actionView } = this.props;
const baseClassName = classnames({
"admin-controls": true,
"show-settings": this.props.actionViewIsOpen
});


return (
<div style={this.styles.base} className={baseClassName}>
<div style={this.styles.header} className="admin-controls-heading--">
<VelocityTransitionGroup
enter={this.backButtonEnterAnimation}
leave={this.backButtonLeaveAnimaton}
>
{this.renderBackButton()}
</VelocityTransitionGroup>

<div style={this.styles.heading} className="nav-settings-heading--">
<h3
className="nav-settings-title--"
style={[
this.styles.title,
!this.props.isActionViewAtRootView ? this.styles.titleWithBackButton : {}
]}
>
<Translation
defaultValue={actionView.label || "Dashboard"}
i18nKey={actionView.i18nKeyLabel || "dashboard.coreTitle"}
/>
</h3>
</div>

<div className="nav-settings-controls--">
<IconButton
icon="fa fa-times"
onClick={this.props.handleActionViewClose}
/>
</div>
</div>
<div style={this.styles.body} className="admin-controls-content action-view-body">

{this.renderControlComponent()}
{this.renderDetailComponent()}
</div>
<div className="admin-controls-footer">
<div className="admin-controls-container">
{this.renderFooter()}
</div>
</div>

</div>
);
}
}

export default Admin()(Radium(ActionView));
3 changes: 3 additions & 0 deletions imports/plugins/core/dashboard/client/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as ActionView } from "./actionView";
export { default as PackageList } from "./packageList";
export { default as Toolbar } from "./toolbar";
Loading

0 comments on commit 886ab2f

Please sign in to comment.