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

feat: locations CRUD #6824

Open
wants to merge 9 commits into
base: feat/promotions
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions apps/reaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@reactioncommerce/api-plugin-inventory": "1.0.5",
"@reactioncommerce/api-plugin-inventory-simple": "1.0.6",
"@reactioncommerce/api-plugin-job-queue": "1.0.7",
"@reactioncommerce/api-plugin-location": "1.0.0",
"@reactioncommerce/api-plugin-navigation": "1.1.2",
"@reactioncommerce/api-plugin-notifications": "1.1.4",
"@reactioncommerce/api-plugin-orders": "1.4.5",
Expand Down
3 changes: 2 additions & 1 deletion apps/reaction/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"promotionsCoupons": "@reactioncommerce/api-plugin-promotions-coupons",
"promotionsDiscounts": "@reactioncommerce/api-plugin-promotions-discounts",
"promotionsOffers": "@reactioncommerce/api-plugin-promotions-offers",
"bullJobQueue": "@reactioncommerce/api-plugin-bull-queue"
"bullJobQueue": "@reactioncommerce/api-plugin-bull-queue",
"location": "@reactioncommerce/api-plugin-location"
}
48 changes: 48 additions & 0 deletions packages/api-plugin-authorization-simple/migrations/7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const affectedGroups = [
"owner",
"shop manager"
];

const newShopPermissions = [
"reaction:legacy:locations/create",
"reaction:legacy:locations/read",
"reaction:legacy:locations/update"
];

/**
* @summary Performs migration up from previous data version
* @param {Object} context Migration context
* @param {Object} context.db MongoDB `Db` instance
* @param {Function} context.progress A function to report progress, takes percent
* number as argument.
* @return {undefined}
*/
async function up({ db, progress }) {
await db.collection("Groups").updateMany({
slug: { $in: affectedGroups }
}, {
$addToSet: { permissions: { $each: newShopPermissions } }
});

progress(100);
}

/**
* @summary Performs migration down from previous data version
* @param {Object} context Migration context
* @param {Object} context.db MongoDB `Db` instance
* @param {Function} context.progress A function to report progress, takes percent
* number as argument.
* @return {undefined}
*/
async function down({ db, progress }) {
await db.collection("Groups").updateMany({
slug: { $in: affectedGroups }
}, {
$pullAll: { permissions: newShopPermissions }
});

progress(100);
}

export default { down, up };
2 changes: 1 addition & 1 deletion packages/api-plugin-authorization-simple/src/preStartup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import doesDatabaseVersionMatch from "@reactioncommerce/db-version-check";
import { migrationsNamespace } from "../migrations/migrationsNamespace.js";

const expectedVersion = 6;
const expectedVersion = 7;

/**
* @summary Called before startup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export const defaultShopManagerRoles = [
"reaction:legacy:promotions/create",
"reaction:legacy:promotions/read",
"reaction:legacy:promotions/update",
"reaction:legacy:promotions/preview"
"reaction:legacy:promotions/preview",
"reaction:legacy:locations/create",
"reaction:legacy:locations/read",
"reaction:legacy:locations/update"
];

export const defaultShopOwnerRoles = [
Expand Down
61 changes: 61 additions & 0 deletions packages/api-plugin-location/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
Loading