Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
15 changes: 0 additions & 15 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,21 +681,6 @@ export default {
return slug;
},

/**
* @name isPreview
* @method
* @memberof Core/Client
*/
isPreview() {
const viewAs = this.getUserPreferences("reaction-dashboard", "viewAs", "administrator");

if (viewAs === "customer") {
return true;
}

return false;
},

/**
* @name getPackageSettings
* @method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function handleChange(event, value) {
}

if (value.name === "createProduct") {
Reaction.setUserPreferences("reaction-dashboard", "viewAs", "administrator");
Meteor.call("products/createProduct", (error, productId) => {
let currentTag;
let currentTagId;
Expand Down
69 changes: 20 additions & 49 deletions imports/plugins/core/catalog/client/components/publishControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Components } from "@reactioncommerce/reaction-components";
import {
Button,
FlatButton,
Switch,
Icon
} from "/imports/plugins/core/ui/client/components";
import { Translatable } from "/imports/plugins/core/ui/client/providers";
Expand All @@ -18,23 +17,16 @@ class PublishControls extends Component {
documentIds: PropTypes.arrayOf(PropTypes.string),
documents: PropTypes.arrayOf(PropTypes.object),
isEnabled: PropTypes.bool,
isPreview: PropTypes.bool,
onAction: PropTypes.func,
onAddProduct: PropTypes.func,
onPublishClick: PropTypes.func,
onViewContextChange: PropTypes.func,
onVisibilityChange: PropTypes.func,
revisions: PropTypes.arrayOf(PropTypes.object),
showViewAsControls: PropTypes.bool, // eslint-disable-line react/boolean-prop-naming
translation: PropTypes.shape({
lang: PropTypes.string
})
}

static defaultProps = {
showViewAsControls: true
}

constructor(props) {
super(props);

Expand Down Expand Up @@ -87,12 +79,6 @@ class PublishControls extends Component {
}
}

onViewContextChange = (event, isChecked) => {
if (typeof this.props.onViewContextChange === "function") {
this.props.onViewContextChange(event, isChecked ? "customer" : "administrator");
}
}

get showChangesButtonLabel() {
if (!this.showDiffs) {
return "Show Changes";
Expand Down Expand Up @@ -182,33 +168,29 @@ class PublishControls extends Component {
}

renderViewControls() {
if (this.props.showViewAsControls) {
let tooltip = "Private";
let i18nKeyTooltip = "app.private";
let tooltip = "Private";
let i18nKeyTooltip = "app.private";

if (this.isVisible === "public") {
tooltip = "Public";
i18nKeyTooltip = "app.public";
}

return (
<div className="hidden-xs">
<FlatButton
i18nKeyTooltip={i18nKeyTooltip}
icon="fa fa-eye-slash"
onIcon="fa fa-eye"
toggle={true}
tooltip={tooltip}
value="public"
onValue="private"
toggleOn={this.isVisible === "public"}
onToggle={this.handleVisibilityChange}
/>
</div>
);
if (this.isVisible === "public") {
tooltip = "Public";
i18nKeyTooltip = "app.public";
}

return null;
return (
<div className="hidden-xs">
<FlatButton
i18nKeyTooltip={i18nKeyTooltip}
icon="fa fa-eye-slash"
onIcon="fa fa-eye"
toggle={true}
tooltip={tooltip}
value="public"
onValue="private"
toggleOn={this.isVisible === "public"}
onToggle={this.handleVisibilityChange}
/>
</div>
);
}

renderArchiveButton() {
Expand All @@ -233,17 +215,6 @@ class PublishControls extends Component {
);
}

renderVisibilitySwitch() {
return (
<Switch
i18nKeyLabel={"admin.dashboard.preview"}
label={"Preview"}
checked={this.props.isPreview}
onChange={this.onViewContextChange}
/>
);
}

renderAdminButton() {
return (
<FlatButton
Expand Down
21 changes: 8 additions & 13 deletions imports/plugins/core/catalog/client/containers/publishContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Meteor } from "meteor/meteor";
import { composeWithTracker } from "@reactioncommerce/reaction-components";
import { Reaction, i18next } from "/client/api";
import { i18next } from "/client/api";
import TranslationProvider from "/imports/plugins/core/ui/client/providers/translationProvider";
import PublishControls from "../components/publishControls";

Expand Down Expand Up @@ -44,7 +44,6 @@ class PublishContainer extends Component {
onPublishClick={this.handlePublishClick}
onAction={this.handlePublishActions}
onVisibilityChange={this.props.onVisibilityChange}
isPreview={this.props.isPreview}
/>
</TranslationProvider>
);
Expand All @@ -55,29 +54,25 @@ PublishContainer.propTypes = {
documentIds: PropTypes.arrayOf(PropTypes.string),
documents: PropTypes.arrayOf(PropTypes.object),
isEnabled: PropTypes.bool,
isPreview: PropTypes.bool,
onAction: PropTypes.func,
onPublishSuccess: PropTypes.func,
onVisibilityChange: PropTypes.func,
product: PropTypes.object
};

/**
* @private
* @param {Object} props Props
* @param {Function} onData Call this to update props
* @returns {undefined}
*/
function composer(props, onData) {
const viewAs = Reaction.getUserPreferences("reaction-dashboard", "viewAs", "administrator");

if (Array.isArray(props.documentIds) && props.documentIds.length) {
onData(null, {
documentIds: props.documentIds,
documents: props.documents,
isPreview: viewAs === "customer"
documents: props.documents
});

return;
}

onData(null, {
isPreview: viewAs === "customer"
});
}

export default composeWithTracker(composer)(PublishContainer);
63 changes: 15 additions & 48 deletions imports/plugins/core/dashboard/client/components/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Tracker } from "meteor/tracker";
import { Components } from "@reactioncommerce/reaction-components";
import {
FlatButton,
Switch,
Icon,
VerticalDivider
} from "/imports/plugins/core/ui/client/components";
Expand All @@ -20,22 +19,18 @@ class PublishControls extends Component {
documents: PropTypes.arrayOf(PropTypes.object),
hasCreateProductAccess: PropTypes.bool,
isEnabled: PropTypes.bool,
isPreview: PropTypes.bool,
onAddProduct: PropTypes.func,
onShopSelectChange: PropTypes.func,
onViewContextChange: PropTypes.func,
onVisibilityChange: PropTypes.func,
packageButtons: PropTypes.arrayOf(PropTypes.object),
shopId: PropTypes.string,
shops: PropTypes.arrayOf(PropTypes.object),
showViewAsControls: PropTypes.bool, // eslint-disable-line react/boolean-prop-naming
translation: PropTypes.shape({
lang: PropTypes.string
})
}

static defaultProps = {
showViewAsControls: true,
isEnabled: true
}

Expand All @@ -55,12 +50,6 @@ class PublishControls extends Component {
this.tracker.stop();
}

onViewContextChange = (event, isChecked) => {
if (typeof this.props.onViewContextChange === "function") {
this.props.onViewContextChange(event, isChecked ? "administrator" : "customer");
}
}

// Passthrough to shopSelectChange handler in container above
onShopSelectChange = (event, shopId) => {
if (typeof this.props.onShopSelectChange === "function") {
Expand All @@ -69,25 +58,21 @@ class PublishControls extends Component {
}

renderViewControls() {
if (this.props.showViewAsControls) {
return (
<FlatButton
label="Private"
i18nKeyLabel="app.private"
i18nKeyToggleOnLabel="app.public"
toggleOnLabel="Public"
icon="fa fa-eye-slash"
onIcon="fa fa-eye"
toggle={true}
value="public"
onValue="private"
toggleOn={this.isVisible === "public"}
onToggle={this.handleVisibilityChange}
/>
);
}

return null;
return (
<FlatButton
label="Private"
i18nKeyLabel="app.private"
i18nKeyToggleOnLabel="app.public"
toggleOnLabel="Public"
icon="fa fa-eye-slash"
onIcon="fa fa-eye"
toggle={true}
value="public"
onValue="private"
toggleOn={this.isVisible === "public"}
onToggle={this.handleVisibilityChange}
/>
);
}

renderShopSelect() {
Expand All @@ -106,23 +91,6 @@ class PublishControls extends Component {
return null;
}

renderVisibilitySwitch() {
if (this.props.hasCreateProductAccess) {
return (
<Switch
i18nKeyLabel="app.editMode"
i18nKeyOnLabel="app.editMode"
label={"Edit Mode"}
onLabel={"Edit Mode"}
checked={!this.props.isPreview}
onChange={this.onViewContextChange}
/>
);
}

return null;
}

renderAdminButton() {
return (
<div className="hidden-xs">
Expand Down Expand Up @@ -190,7 +158,6 @@ class PublishControls extends Component {
return (
<Components.Toolbar>
<Components.ToolbarGroup firstChild={true}>
{this.renderVisibilitySwitch()}
{this.renderShopSelect()}
</Components.ToolbarGroup>
<Components.ToolbarGroup lastChild={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Tags, Shops } from "/lib/collections";
import { AdminContextProvider } from "/imports/plugins/core/ui/client/providers";

const handleAddProduct = () => {
Reaction.setUserPreferences("reaction-dashboard", "viewAs", "administrator");
Meteor.call("products/createProduct", (error, productId) => {
if (Meteor.isClient) {
let currentTag;
Expand Down Expand Up @@ -45,6 +44,12 @@ const handleShopSelectChange = (event, shopId) => {
}
};

/**
* @private
* @param {Object} props Props
* @param {Function} onData Call this to update props
* @returns {undefined}
*/
function composer(props, onData) {
// Reactive data sources
const routeName = Reaction.Router.getRouteName();
Expand Down Expand Up @@ -81,7 +86,6 @@ function composer(props, onData) {
onData(null, {
packageButtons,
dashboardHeaderTemplate: props.data.dashboardHeader,
isPreview: Reaction.isPreview(),
isActionViewAtRootView: Reaction.isActionViewAtRootView(),
actionViewIsOpen: Reaction.isActionViewOpen(),
hasCreateProductAccess: Reaction.hasPermission("createProduct", Reaction.getUserId(), Reaction.getShopId()),
Expand All @@ -90,8 +94,7 @@ function composer(props, onData) {

// Callbacks
onAddProduct: handleAddProduct,
onShopSelectChange: handleShopSelectChange,
onViewContextChange: props.handleViewContextChange
onShopSelectChange: handleShopSelectChange
});
}

Expand Down
26 changes: 13 additions & 13 deletions imports/plugins/core/ui-navbar/client/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,16 @@ class NavBar extends Component {

renderTagNav() {
return (
<header className="menu" role="banner">
<Components.TagNav
isVisible={this.state.navBarVisible}
closeNavbar={this.handleCloseNavbar}
{...this.props}
>
<Components.Brand />
{this.renderNotificationIcon()}
{this.renderLanguage()}
{this.renderCurrency()}
</Components.TagNav>
</header>
<Components.TagNav
isVisible={this.state.navBarVisible}
closeNavbar={this.handleCloseNavbar}
{...this.props}
>
<Components.Brand />
{this.renderNotificationIcon()}
{this.renderLanguage()}
{this.renderCurrency()}
</Components.TagNav>
);
}

Expand All @@ -138,7 +136,9 @@ class NavBar extends Component {
<div className="rui navbar">
{this.props.visibility.hamburger && this.renderHamburgerButton()}
{this.props.visibility.brand && this.renderBrand()}
{this.props.visibility.tags && this.renderTagNav()}
<header className="menu" role="banner">
{this.props.visibility.tags && this.renderTagNav()}
</header>
{this.props.visibility.search && this.renderSearchButton()}
{this.props.visibility.notifications && this.renderNotificationIcon()}
{this.props.visibility.languages && this.renderLanguage()}
Expand Down
Loading