-
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.
Merge branch 'development' into joykare-inventory-tracking-1928
- Loading branch information
Showing
5 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
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
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
47 changes: 47 additions & 0 deletions
47
imports/plugins/core/versions/server/migrations/4_update_templates_priority.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Migrations } from "/imports/plugins/core/versions"; | ||
import { Packages } from "/lib/collections"; | ||
|
||
const reactionPkgs = [ // reaction packages with layouts | ||
"reaction-accounts", | ||
"reaction-checkout", | ||
"reaction-dashboard", | ||
"reaction-email", | ||
"reaction-orders", | ||
"reaction-ui", | ||
"reaction-inventory", | ||
"reaction-product-variant"]; | ||
|
||
const query = { | ||
name: { $in: reactionPkgs }, | ||
layout: { $type: 3 } // docs with layouts set | ||
}; | ||
|
||
Migrations.add({ | ||
version: 4, | ||
up() { | ||
const packages = Packages.find(query).fetch(); | ||
packages.forEach(updateHandler(1, 999)); | ||
}, | ||
down() { | ||
const packages = Packages.find(query).fetch(); | ||
packages.forEach(updateHandler(999, 1)); | ||
} | ||
}); | ||
|
||
function updateHandler(oldValue, newValue) { | ||
return function (pkg) { | ||
let changed = false; // to track if updating is needed | ||
pkg.layout.forEach((layout) => { | ||
if (!layout.priority || layout.priority === oldValue) { | ||
layout.priority = newValue; | ||
changed = true; | ||
} | ||
}); | ||
|
||
if (changed) { | ||
Packages.update(pkg._id, { | ||
$set: { layout: pkg.layout } | ||
}); | ||
} | ||
}; | ||
} |
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,3 +1,4 @@ | ||
import "./1_rebuild_account_and_order_search_collections"; | ||
import "./2_add_key_to_search_ui"; | ||
import "./3_reset_package_registry"; | ||
import "./4_update_templates_priority"; |
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