Skip to content

Commit

Permalink
Fix actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Nov 20, 2024
1 parent 263f817 commit d2e42ee
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/collections/action/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export class ActionCollection extends Collection {
.filter((model) => includes(req.permissions, model.permission))
.groupBy('category')
.mapValues((category) =>
map(category, (action) =>
omit(action, ['order', 'permission', 'category']),
),
map(category, (action) => ({
...omit(action, ['order', 'permission', 'category']),
url: action.url ? action.url.replace('$username', req.user.id) : null,
})),
)
.value();
}
Expand Down
11 changes: 11 additions & 0 deletions src/migrations/202405121608_actions_url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const up = async (knex) => {
await knex.schema.alterTable('action', (table) => {
table.string('url');
});
};

export const down = async (knex) => {
await knex.schema.alterTable('action', (table) => {
table.dropColumn('url');
});
};
2 changes: 1 addition & 1 deletion src/seeds/action/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const seedAction = async (trx, profilePath) => {
if (fileExists(`${profilePath}/actions`)) {
const profile = stripI18n(require(`${profilePath}/actions`));
if (profile.purge) {
await Action.delete(trx);
await Action.delete({}, trx);
}
await mapAsync(
['object', 'site_actions', 'object_buttons', 'user'],
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/group/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const seedGroup = async (trx, profilePath) => {
if (fileExists(`${profilePath}/groups`)) {
const profile = stripI18n(require(`${profilePath}/groups`));
if (profile.purge) {
await Group.delete(trx);
await Group.delete({}, trx);
}
await Promise.all(
map(profile.groups, async (group) => {
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/permission/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const seedPermission = async (trx, profilePath) => {
if (fileExists(`${profilePath}/permissions`)) {
const profile = stripI18n(require(`${profilePath}/permissions`));
if (profile.purge) {
await Permission.delete(trx);
await Permission.delete({}, trx);
}
await Promise.all(
map(
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/redirect/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const seedRedirect = async (trx, profilePath) => {
if (fileExists(`${profilePath}/redirects`)) {
const profile = stripI18n(require(`${profilePath}/redirects`));
if (profile.purge) {
await Redirect.delete(trx);
await Redirect.delete({}, trx);
}
await Promise.all(
map(
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/role/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const seedRole = async (trx, profilePath) => {
if (fileExists(`${profilePath}/roles`)) {
const profile = stripI18n(require(`${profilePath}/roles`));
if (profile.purge) {
await Role.delete(trx);
await Role.delete({}, trx);
}
await mapAsync(profile.roles, async (role, index) => {
await Role.create(
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const seedUser = async (trx, profilePath) => {
if (fileExists(`${profilePath}/users`)) {
const profile = stripI18n(require(`${profilePath}/users`));
if (profile.purge) {
await User.delete(trx);
await User.delete({}, trx);
}
await Promise.all(
map(profile.users, async (user) => {
Expand Down
2 changes: 1 addition & 1 deletion src/seeds/workflow/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const seedWorkflow = async (trx, profilePath) => {
if (fileExists(`${profilePath}/workflows`)) {
const profile = stripI18n(require(`${profilePath}/workflows`));
if (profile.purge) {
await Workflow.delete(trx);
await Workflow.delete({}, trx);
}
await Promise.all(
map(profile.workflows, async (workflow) => {
Expand Down

0 comments on commit d2e42ee

Please sign in to comment.