-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates from code review including Shop ID and array map
Signed-off-by: Chris Potter <chris@reactioncommerce.com>
- Loading branch information
Chris Potter
committed
Apr 9, 2019
1 parent
dc4e8e0
commit dc63918
Showing
3 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
9 changes: 7 additions & 2 deletions
9
imports/plugins/core/system-info/server/no-meteor/queries/systemInformation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import packageJson from "/package.json"; | ||
import ReactionError from "@reactioncommerce/reaction-error"; | ||
|
||
|
||
/** | ||
* @name queries.systemInformation | ||
* @method | ||
* @memberof SystemInformation/GraphQL | ||
* @summary get systemInformations | ||
* @param {String} args.shopId The ID of the shop to load settings for | ||
* @param {Object} context - an object containing the per-request state | ||
* @return {<Object} System Information | ||
**/ | ||
export default async function systemInformation(context) { | ||
export default async function systemInformation(id, context) { | ||
if (!context.userHasPermission(["owner", "admin"], id)) throw new ReactionError("access-denied", "User does not have permission"); | ||
const plugins = await context.collections.Packages.find({ shopId: id, version: { $exists: true } }).toArray(); | ||
return { | ||
apiVersion: packageJson.version, | ||
plugins: await context.collections.Packages.find({ version: { $exists: true } }).toArray() | ||
plugins: plugins.map(({ name, version }) => ({ name, version })) | ||
}; | ||
} |
6 changes: 4 additions & 2 deletions
6
imports/plugins/core/system-info/server/no-meteor/resolvers/Query/systemInformation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { decodeShopOpaqueId } from "@reactioncommerce/reaction-graphql-xforms/shop"; | ||
|
||
/** | ||
* @name Query.systemInformation | ||
* @method | ||
* @memberof SystemInformation/GraphQL | ||
* @summary get system information for reaction site | ||
* @param {ConnectionArgs} args An object of all arguments that were sent by the client | ||
* @param {String} args.shopId The ID of the shop to load navigation items for | ||
* @param {Object} context An object containing the per-request state | ||
* @return {<Object>} System Information Object | ||
*/ | ||
export default async function systemInformation(_, args, context) { | ||
return context.queries.systemInformation(context); | ||
const dbShopId = decodeShopOpaqueId(args.shopId); | ||
return context.queries.systemInformation(dbShopId, context); | ||
} |
13 changes: 9 additions & 4 deletions
13
imports/plugins/core/system-info/server/no-meteor/schemas/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
extend type Query { | ||
systemInformation: SystemInfo | ||
systemInformation(shopId: ID!): SystemInformation! | ||
} | ||
|
||
"Represents Reaction Plugin" | ||
type Plugin { | ||
name: String, | ||
# name of plugin | ||
name: String | ||
# version of plugin | ||
version: String | ||
} | ||
|
||
"Represents Reaction System Infomation" | ||
type SystemInfo { | ||
type SystemInformation { | ||
# core api version | ||
apiVersion: String, | ||
apiVersion: String | ||
# TODO: data version | ||
# TODO: mongo version | ||
#plugins installed with name, version information | ||
plugins:[Plugin] | ||
} |