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

Performance/Refactor remove revision control #4238

Merged
merged 58 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
260e86c
chore: update package lock
mikemurray May 10, 2018
04cf316
refactor: remove revision control from publication
mikemurray May 10, 2018
4ce419a
refactor: remove revisions from publication
mikemurray May 10, 2018
2ffa0cc
refactor: move publish controls to `reaction-catalog` package
mikemurray May 10, 2018
86f852b
refactor: remove publish from revisions to products
mikemurray May 10, 2018
a28e27c
refactor: remove `applyProductRevision`
mikemurray May 10, 2018
e8f58a7
refactor: remove `applyProductRevision`
mikemurray May 10, 2018
ddaa4c8
refactor: remove `applyProductRevision` and `resubscribeAfterCloning`
mikemurray May 10, 2018
aae79a5
refactor: remove `applyProductRevision`
mikemurray May 10, 2018
e3c7581
refactor: remove `applyProductRevision` helper
mikemurray May 10, 2018
146fcc3
fix: fetch products
mikemurray May 10, 2018
ebde697
refactor: remove `isRevisionControlEnabled` stub
mikemurray May 11, 2018
0ce83ce
refactor: remove `isRevisionControlEnabled` stub
mikemurray May 11, 2018
678c131
refactor: remove `isRevisionControlEnabled` stub
mikemurray May 11, 2018
593b3e9
refactor: remove `isRevisionControlEnabled` stub
mikemurray May 11, 2018
a0ffc6e
refactor: remove `isRevisionControlEnabled`
mikemurray May 11, 2018
f2de5c1
refactor: remove `isRevisionControlEnabled`
mikemurray May 11, 2018
820444e
refactor: remove `isRevisionControlEnabled` conditional
mikemurray May 11, 2018
193f166
refactor: remove dependency on revision control system
mikemurray May 14, 2018
baaca84
refactor: remove revision control hooks
mikemurray May 15, 2018
2f45c0b
refactor: remove revision control hooks
mikemurray May 15, 2018
972b9a5
refactor: use standard catalog api
mikemurray May 15, 2018
0efddf8
refactor: use standard catalog api
mikemurray May 15, 2018
0c710bb
refactor: don't depend on the result of the `beforeUpdateCatalogProdu…
mikemurray May 15, 2018
3c374ab
refactor: fix lint issue
mikemurray May 15, 2018
6aa5e3b
refactor: update tests to not depend on revision control
mikemurray May 15, 2018
98dacee
refactor: remove revision subscription
mikemurray May 15, 2018
20adfa7
refactor: remove revision publication
mikemurray May 15, 2018
7497ca1
breaking: remove revision control package
mikemurray May 15, 2018
1e13685
chore: add migration to remove revision registry entry
mikemurray May 15, 2018
39cfb5d
breaking: remove Revisions schema and collection
mikemurray May 15, 2018
e95780c
refactor: check Products collection for isDeleted ancestors
mikemurray May 16, 2018
0b4114a
fix: import catalog directly
mikemurray May 16, 2018
ac09598
fix: set inventoryPolicy in state
mikemurray May 16, 2018
0f1c7e0
docs: update summaries
mikemurray May 16, 2018
c5dde21
docs: update comment
mikemurray May 16, 2018
0f5fc54
docs: remove comma
mikemurray May 16, 2018
29d7dc3
Merge branch 'release-1.12.0' into feat-4237-mikemurray-remove-revisions
mikemurray May 18, 2018
cbff4ee
fix: conflict
mikemurray May 18, 2018
e5a5c95
refactor: import helpers from catalog package
mikemurray May 18, 2018
40d38ea
refactor: import helpers from catalog package
mikemurray May 18, 2018
4e31b58
test: fix broken assertions
mikemurray May 18, 2018
869d19f
refactor: remove revision control
mikemurray May 18, 2018
07a7ca5
test: update test assertion result
mikemurray May 18, 2018
4b01aa7
fix: add type option to product update
mikemurray May 18, 2018
36b714e
test: fix test that relied on revision control indirectly
mikemurray May 18, 2018
4266a13
test: fix assertion for product handle
mikemurray May 18, 2018
8997444
refactor: add revision control package removal migration
mikemurray May 18, 2018
7e0271c
fix: use toArchiveProduct as the string product id
mikemurray May 18, 2018
82a02ba
test: add type to product update statements to fix broken tests
mikemurray May 18, 2018
d49b6f0
chore: update package lock file
mikemurray May 18, 2018
4dd5fea
refactor: remove revisions definition
mikemurray May 21, 2018
e3b27e7
refactor: remove unused render function
mikemurray May 21, 2018
057d83f
refactor: remove "discard" logic
mikemurray May 21, 2018
d5f96c3
refactor: remove revisions prop
mikemurray May 21, 2018
7f35a34
refactor: remove unused render func
mikemurray May 21, 2018
746ec21
refactor: remove revision logic for the edit button
mikemurray May 21, 2018
0e1421e
refactor: remove revision translations
mikemurray May 21, 2018
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
1 change: 0 additions & 1 deletion imports/collections/defineCollections.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function defineCollections(db, collections) {
Orders: db.collection("Orders"),
Packages: db.collection("Packages"),
Products: db.collection("Products"),
Revisions: db.collection("Revisions"),
roles: db.collection("roles"),
SellerShops: db.collection("SellerShops"),
Shipping: db.collection("Shipping"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ import { Components } from "@reactioncommerce/reaction-components";
import {
Button,
FlatButton,
IconButton,
Divider,
DropDownMenu,
MenuItem,
Switch,
Icon
} from "/imports/plugins/core/ui/client/components";
import SimpleDiff from "./simpleDiff";
import { Translatable } from "/imports/plugins/core/ui/client/providers";

/** TMP **/
Expand Down Expand Up @@ -176,19 +171,6 @@ class PublishControls extends Component {
return false;
}

renderChanges() {
if (this.showDiffs) {
const diffs = this.props.revisions.map((revision) => <SimpleDiff diff={revision.diff} key={revision._id} />);

return (
<div>
{diffs}
</div>
);
}
return null;
}

renderDeletionStatus() {
if (this.hasChanges) {
if (this.primaryRevision && this.primaryRevision.documentData.isDeleted) {
Expand Down Expand Up @@ -232,48 +214,6 @@ class PublishControls extends Component {
);
}

renderMoreOptionsButton() {
return (
<DropDownMenu
buttonElement={<IconButton icon={"fa fa-ellipsis-v"}/>}
handleMenuItemChange={this.handleAction}
>
<MenuItem label="Administrator" value="administrator" />
<MenuItem label="Customer" value="customer" />
<Divider />
<MenuItem
i18nKeyLabel="app.public"
icon="fa fa-unlock"
label="Public"
selectLabel="Public"
value="public"
/>
<MenuItem
i18nKeyLabel="app.private"
label="Private"
icon="fa fa-lock"
selectLabel="Public"
value="private"
/>
<Divider />
<MenuItem
disabled={this.hasChanges === false}
i18nKeyLabel="revisions.discardChanges"
icon="fa fa-undo"
label="Discard Changes"
value="discard"
/>
<Divider />
<MenuItem
i18nKeyLabel="app.archive"
icon="fa fa-trash-o"
label="Archive"
value="archive"
/>
</DropDownMenu>
);
}

renderViewControls() {
if (this.props.showViewAsControls) {
let tooltip = "Private";
Expand Down Expand Up @@ -304,19 +244,6 @@ class PublishControls extends Component {
return null;
}

renderUndoButton() {
return (
<FlatButton
disabled={this.hasChanges === false}
tooltip="Discard Changes"
i18nKeyTooltip="revisions.discardChanges"
icon={"fa fa-undo"}
value="discard"
onClick={this.handleAction}
/>
);
}

renderArchiveButton() {
return (
<FlatButton
Expand Down Expand Up @@ -378,20 +305,14 @@ class PublishControls extends Component {
}

render() {
if (this.props.isEnabled) {
return (
<Components.ToolbarGroup lastChild={true}>
{this.renderDeletionStatus()}
{this.renderUndoButton()}
{this.renderArchiveButton()}
{this.renderViewControls()}
{this.renderPublishButton()}
{/* this.renderMoreOptionsButton() */}
</Components.ToolbarGroup>
);
}

return null;
return (
<Components.ToolbarGroup lastChild={true}>
{this.renderDeletionStatus()}
{this.renderArchiveButton()}
{this.renderViewControls()}
{this.renderPublishButton()}
</Components.ToolbarGroup>
);
}
}

Expand Down
83 changes: 83 additions & 0 deletions imports/plugins/core/catalog/client/containers/publishContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { composeWithTracker } from "@reactioncommerce/reaction-components";
import PublishControls from "../components/publishControls";
import { Meteor } from "meteor/meteor";
import TranslationProvider from "/imports/plugins/core/ui/client/providers/translationProvider";
import { Reaction, i18next } from "/client/api";

/*
* PublishContainer is a container component connected to Meteor data source.
*/
class PublishContainer extends Component {
publishToCatalog(collection, documentIds) {
Meteor.call(`catalog/publish/${collection}`, documentIds, (error, result) => {
if (result) {
Alerts.toast(i18next.t("admin.catalogProductPublishSuccess", { defaultValue: "Product published to catalog" }), "success");
} else if (error) {
Alerts.toast(error.message, "error");
}
});
}

handlePublishClick = () => {
const productIds = this.props.documents
.filter((doc) => doc.type === "simple")
.map((doc) => doc._id);

this.publishToCatalog("products", productIds);
}

handlePublishActions = (event, action) => {
if (action === "archive" && this.props.onAction) {
this.props.onAction(event, action, this.props.documentIds);
}
}

render() {
return (
<TranslationProvider>
<PublishControls
documentIds={this.props.documentIds}
documents={this.props.documents}
isEnabled={this.props.isEnabled}
onPublishClick={this.handlePublishClick}
onAction={this.handlePublishActions}
onVisibilityChange={this.props.onVisibilityChange}
isPreview={this.props.isPreview}
/>
</TranslationProvider>
);
}
}

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
};

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"
});

return;
}

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

export default composeWithTracker(composer)(PublishContainer);
Loading