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 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
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
21 changes: 21 additions & 0 deletions imports/plugins/core/dashboard/client/components/PluginVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Component } from "react";
import PropTypes from "prop-types";


export default class PluginVersion extends Component {
static propTypes = {
versionedPackage: PropTypes.shape({
name: PropTypes.string.isRequired,
version: PropTypes.string
}).isRequired
};

render() {
const { versionedPackage } = this.props;
return (
<div>
<p>{versionedPackage.name} {versionedPackage.version}</p>
</div>
);
}
}
18 changes: 18 additions & 0 deletions imports/plugins/core/dashboard/client/components/PluginVersions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import PluginVersion from "./PluginVersion";

class PluginVersions extends Component {
static propTypes = {
versionedPackages: PropTypes.object
};

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

export default PluginVersions;
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=PluginVersions 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 PluginVersions from "../../../components/PluginVersions";
import ShopBrandMediaManager from "./ShopBrandMediaManager";


Expand Down Expand Up @@ -167,3 +168,14 @@ Template.optionsShopSettings.helpers({
return SitemapSettingsContainer;
}
});
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;
},

PluginVersions() {
return PluginVersions;
}
});