Skip to content

Commit

Permalink
Importing Reaction and making functions part of class
Browse files Browse the repository at this point in the history
  • Loading branch information
Akarshit committed Sep 29, 2017
1 parent 02a713f commit cc7e293
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions imports/plugins/core/ui/client/components/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ToolbarContainer from "/imports/plugins/core/dashboard/client/containers/
import Toolbar from "/imports/plugins/core/dashboard/client/components/toolbar";
import { ActionViewContainer, PackageListContainer } from "/imports/plugins/core/dashboard/client/containers";
import { ActionView, ShortcutBar } from "/imports/plugins/core/dashboard/client/components";
import { Reaction } from "/client/api";

const ConnectedToolbarComponent = ToolbarContainer(Toolbar);
const ConnectedAdminViewComponent = ActionViewContainer(ActionView);
Expand Down Expand Up @@ -34,28 +35,6 @@ const styles = {
}
};


const handleViewContextChange = (event, value) => {
Reaction.setUserPreferences("reaction-dashboard", "viewAs", value);

if (Reaction.isPreview() === true) {
// Save last action view state
const saveActionViewState = Reaction.getActionView();
Reaction.setUserPreferences("reaction-dashboard", "savedActionViewState", saveActionViewState);

// hideActionView during isPreview === true
Reaction.hideActionView();
}
};

const handleKeyDown = (event) => {
if (event.altKey && event.keyCode === 69) { // Switch edit mode
const userWas = Reaction.getUserPreferences("reaction-dashboard", "viewAs", "customer");
const userIs = userWas === "customer" ? "administrator" : "customer";
handleViewContextChange(event, userIs);
}
};

class App extends Component {
static propTypes = {
children: PropTypes.node,
Expand All @@ -68,6 +47,27 @@ class App extends Component {
return this.props.hasDashboardAccess;
}

handleViewContextChange = (event, value) => {
Reaction.setUserPreferences("reaction-dashboard", "viewAs", value);

if (Reaction.isPreview() === true) {
// Save last action view state
const saveActionViewState = Reaction.getActionView();
Reaction.setUserPreferences("reaction-dashboard", "savedActionViewState", saveActionViewState);

// hideActionView during isPreview === true
Reaction.hideActionView();
}
}

handleKeyDown = (event) => {
if (event.altKey && event.keyCode === 69) { // Switch edit mode
const userWas = Reaction.getUserPreferences("reaction-dashboard", "viewAs", "customer");
const userIs = userWas === "customer" ? "administrator" : "customer";
this.handleViewContextChange(event, userIs);
}
}

renderAdminApp() {
const pageClassName = classnames({
"admin": true,
Expand All @@ -83,11 +83,11 @@ class App extends Component {
<div
style={styles.adminApp}
tabIndex={0}
onKeyDown={handleKeyDown}
onKeyDown={this.handleKeyDown}
>
<div className={pageClassName} id="reactionAppContainer" style={styles.adminContentContainer}>
<div className="reaction-toolbar">
<ConnectedToolbarComponent handleViewContextChange={handleViewContextChange} data={routeData} />
<ConnectedToolbarComponent handleViewContextChange={this.handleViewContextChange} data={routeData} />
</div>
<div style={styles.scrollableContainer}>
<Switch>
Expand Down

0 comments on commit cc7e293

Please sign in to comment.