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

Record plugin versions in DB and show in Shop panel #4895

Merged
merged 7 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 5 additions & 0 deletions imports/collections/schemas/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export const PackageConfig = new SimpleSchema({
type: Boolean,
defaultValue: true
},
"version": {
type: String,
label: "Package Version",
optional: true
},
"icon": {
type: String,
optional: true
Expand Down
5 changes: 5 additions & 0 deletions imports/plugins/core/core/server/Reaction/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ export default {
// Settings from the package registry.js
const settingsFromPackage = {
name: pkgName,
version: config.version,
icon: config.icon,
enabled: !!config.autoEnable,
settings: config.settings,
Expand All @@ -1098,6 +1099,10 @@ export default {

const combinedSettings = merge({}, settingsFromPackage, settingsFromFixture || {}, settingsFromDB || {});

// always use version from package
if (combinedSettings.version) {
combinedSettings.version = settingsFromPackage.version || settingsFromDB.version;
}
if (combinedSettings.registry) {
combinedSettings.registry = combinedSettings.registry.map((entry) => {
if (entry.provides && !Array.isArray(entry.provides)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { Component } from "react";
import PropTypes from "prop-types";


export default class PluginVersion extends Component {
brent-hoover marked this conversation as resolved.
Show resolved Hide resolved
static propTypes = {
versionedPackage: PropTypes.object
brent-hoover marked this conversation as resolved.
Show resolved Hide resolved
};

render() {
const { versionedPackage } = this.props;
return (
<div>
<p>{versionedPackage.name} {versionedPackage.version}</p>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import PluginVersion from "../components/plugin-versions";

class PluginVersionsContainer extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In new code we name the file the same as the component, in the same case: PluginVersionsContainer.js

static propTypes = {
versionedPackages: PropTypes.object
};

render() {
const { versionedPackages } = this.props;
return (
<div>
{versionedPackages.map((versionedPackage) => {
return <PluginVersion versionedPackage={versionedPackage} key={versionedPackage._id} />;
})}
</div>
);
}
}

export default PluginVersionsContainer;
brent-hoover marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@
</div>
</div>


<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<a
href="#plugin-versions"
aria-controls="plugin-versions"
aria-expanded="true"
role="button"
data-toggle="collapse"
data-parent="#shopSettingsAccordian">Plugin Versions</a>
</div>
</div>
<div id="plugin-versions" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
{{> React component=PluginVersionsContainer versionedPackages=versionedPackages}}
</div>
</div>
</div>

{{#each reactionApps provides='shopSettings'}}
<div class="panel panel-default">
<div class="panel-heading panel-heading-flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Reaction, i18next } from "/client/api";
import { Packages, Shops } from "/lib/collections";
import { Media } from "/imports/plugins/core/files/client";
import SitemapSettingsContainer from "/imports/plugins/included/sitemap-generator/client/containers/sitemap-settings-container";
import PluginVersionsContainer from "../../../containers/plugin-versions";
import ShopBrandMediaManager from "./ShopBrandMediaManager";


Expand Down Expand Up @@ -158,12 +159,31 @@ Template.optionsShopSettings.helpers({
shopId: Reaction.getShopId()
});
},
versionedPackages() {
const versionedPackages = Packages.find({ version: { $exists: true }, shopId: Reaction.getShopId() });
return versionedPackages;
},

isPackageEnabled(name) {
return Reaction.isPackageEnabled(name);
},

SitemapSettingsContainer() {
return SitemapSettingsContainer;
},

PluginVersionsContainer() {
return PluginVersionsContainer;
}
});
brent-hoover marked this conversation as resolved.
Show resolved Hide resolved

Template.shopSettings.helpers({
versionedPackages() {
const versionedPackages = Packages.find({ version: { $exists: true }, shopId: Reaction.getShopId() });
return versionedPackages;
},

PluginVersionsContainer() {
return PluginVersionsContainer;
}
});