Skip to content

Commit

Permalink
Performance/vuems integration (ergonode#629)
Browse files Browse the repository at this point in the history
* performance(core): isolation all mechanism to modules

* performance(microservices): add support for local middlewares

* performance(microservices): Change global methods from VueMS, move elements from skeleton to modules

* package change
  • Loading branch information
bleto authored Jan 4, 2021
1 parent e75fe48 commit 53b9ada
Show file tree
Hide file tree
Showing 54 changed files with 320 additions and 306 deletions.
18 changes: 5 additions & 13 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,17 @@

<script>
import DefaultLayout from '@Core/layouts/default';
import {
defaultLayoutMiddleware,
} from '@Core/middleware/layouts';
export default {
name: 'NuxtDefaultLayout',
components: {
DefaultLayout,
},
async middleware({
store,
redirect,
}) {
const {
authentication,
} = store.state;
if (!authentication.isLogged) {
return redirect('/');
}
return null;
async middleware(ctx) {
await defaultLayoutMiddleware(ctx);
},
};
</script>
12 changes: 5 additions & 7 deletions layouts/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@

<script>
import LoginLayout from '@Core/layouts/login';
import {
loginLayoutMiddleware,
} from '@Core/middleware/layouts';
export default {
name: 'NuxtLoginLayout',
components: {
LoginLayout,
},
middleware({
store, redirect,
}) {
if (store.state.authentication.isLogged) {
return redirect('/dashboard');
}
return null;
middleware(ctx) {
loginLayoutMiddleware(ctx);
},
};
</script>
36 changes: 36 additions & 0 deletions lib/index-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node
/*
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved.
* See LICENSE for license details.
*/
const chalk = require('chalk');
const envinfo = require('envinfo');

const showEnvInfo = async () => {
console.log(chalk.bold('\nEnvironment Info:'));
const result = await envinfo
.run({
System: [
'OS',
'CPU',
'Memory',
],
Binaries: [
'Node',
'Yarn',
'npm',
],
Browsers: [
'Chrome',
'Edge',
'Firefox',
'Safari',
],
npmGlobalPackages: [
'nuxt',
],
});
console.log(result);
};

showEnvInfo();
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ program
.command('env', 'Creat .env file', {
isDefault: true,
})
.command('info', 'Show environment info')
.command('modules', 'Modules configuration')
.command('modules-all', 'All modules configuration')
.parse(process.argv); // allow commander to parse `process.argv`
Expand Down
4 changes: 2 additions & 2 deletions middleware/modulesMiddlewareLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved.
* See LICENSE for license details.
*/
import middlewareModules from '~/.nuxt/middleware.modules';
import modulesMiddlewares from '~/.nuxt/middleware.modules';

export default (ctx) => {
middlewareModules(ctx);
modulesMiddlewares(ctx);
};
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {
'code',
]),
extendedMainAction() {
return this.$getExtendedComponents('@Attributes/pages/attribute-groups/_group/mainAction');
return this.$getExtendSlot('@Attributes/pages/attribute-groups/_group/mainAction');
},
isReadOnly() {
return this.$isReadOnly(PRIVILEGES.ATTRIBUTE_GROUP.namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export default {
],
computed: {
extendedMainAction() {
return this.$getExtendedComponents('@Attributes/pages/attribute-groups/mainAction');
return this.$getExtendSlot('@Attributes/pages/attribute-groups/mainAction');
},
extendedModals() {
return this.$getExtendedComponents('@Attributes/pages/attribute-groups/injectModal');
return this.$getExtendSlot('@Attributes/pages/attribute-groups/injectModal');
},
isReadOnly() {
return this.$isReadOnly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
'attrTypes',
]),
extendedMainAction() {
return this.$getExtendedComponents('@Attributes/pages/attributes/_attribute/mainAction');
return this.$getExtendSlot('@Attributes/pages/attributes/_attribute/mainAction');
},
isReadOnly() {
return this.$isReadOnly(PRIVILEGES.ATTRIBUTE.namespace);
Expand All @@ -119,7 +119,7 @@ export default {
route: this.$route,
});
const type = getKeyByValue(this.attrTypes, this.type);
const tabs = await this.$extendMethods('@Core/pages/tabs', {
const tabs = await this.$getExtendMethod('@Core/pages/tabs', {
$this: this,
type,
tabs: tmpTabs,
Expand Down
4 changes: 2 additions & 2 deletions modules/@ergonode/attributes/src/pages/attributes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export default {
],
computed: {
extendedMainAction() {
return this.$getExtendedComponents('@Attributes/pages/attributes/mainAction');
return this.$getExtendSlot('@Attributes/pages/attributes/mainAction');
},
extendedModals() {
return this.$getExtendedComponents('@Attributes/pages/attributes/injectModal');
return this.$getExtendSlot('@Attributes/pages/attributes/injectModal');
},
isReadOnly() {
return this.$isReadOnly(
Expand Down
16 changes: 8 additions & 8 deletions modules/@ergonode/attributes/src/store/attribute/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
};

// EXTENDED BEFORE METHOD
const extendedData = await this.$extendMethods('@Attributes/store/attribute/action/createAttribute/__before', {
const extendedData = await this.$getExtendMethod('@Attributes/store/attribute/action/createAttribute/__before', {
$this: this,
type: typeKey,
data,
Expand All @@ -70,7 +70,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attribute/action/createAttribute/__after', {
await this.$getExtendMethod('@Attributes/store/attribute/action/createAttribute/__after', {
$this: this,
type: typeKey,
data: {
Expand Down Expand Up @@ -147,7 +147,7 @@ export default {

try {
// EXTENDED BEFORE METHOD
await this.$extendMethods('@Attributes/store/attribute/action/getAttribute/__before', {
await this.$getExtendMethod('@Attributes/store/attribute/action/getAttribute/__before', {
$this: this,
data: {
id,
Expand Down Expand Up @@ -198,7 +198,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attribute/action/getAttribute/__after', {
await this.$getExtendMethod('@Attributes/store/attribute/action/getAttribute/__after', {
$this: this,
data,
type,
Expand Down Expand Up @@ -247,7 +247,7 @@ export default {
};

// EXTENDED BEFORE METHOD
const extendedData = await this.$extendMethods('@Attributes/store/attribute/action/updateAttribute/__before', {
const extendedData = await this.$getExtendMethod('@Attributes/store/attribute/action/updateAttribute/__before', {
$this: this,
type: typeKey,
data: {
Expand All @@ -271,7 +271,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attribute/action/updateAttribute/__after', {
await this.$getExtendMethod('@Attributes/store/attribute/action/updateAttribute/__after', {
$this: this,
type: typeKey,
data,
Expand Down Expand Up @@ -313,7 +313,7 @@ export default {

try {
// EXTENDED BEFORE METHOD
await this.$extendMethods('@Attributes/store/attribute/action/removeAttribute/__before', {
await this.$getExtendMethod('@Attributes/store/attribute/action/removeAttribute/__before', {
$this: this,
type: typeKey,
});
Expand All @@ -325,7 +325,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attribute/action/removeAttribute/__after', {
await this.$getExtendMethod('@Attributes/store/attribute/action/removeAttribute/__after', {
$this: this,
type: typeKey,
});
Expand Down
16 changes: 8 additions & 8 deletions modules/@ergonode/attributes/src/store/attributeGroup/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
};

// EXTENDED BEFORE METHOD
const extendedData = await this.$extendMethods('@Attributes/store/attributeGroup/action/createAttributeGroup/__before', {
const extendedData = await this.$getExtendMethod('@Attributes/store/attributeGroup/action/createAttributeGroup/__before', {
$this: this,
data,
});
Expand All @@ -50,7 +50,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/createAttributeGroup/__after', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/createAttributeGroup/__after', {
$this: this,
data: {
id,
Expand Down Expand Up @@ -88,7 +88,7 @@ export default {
) {
try {
// EXTENDED BEFORE METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/getAttributeGroup/__before', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/getAttributeGroup/__before', {
$this: this,
data: {
id,
Expand Down Expand Up @@ -127,7 +127,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/getAttributeGroup/__after', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/getAttributeGroup/__after', {
$this: this,
data,
});
Expand Down Expand Up @@ -164,7 +164,7 @@ export default {
name,
};
// EXTENDED BEFORE METHOD
const extendedData = await this.$extendMethods('@Attributes/store/attributeGroup/action/updateAttributeGroup/__before', {
const extendedData = await this.$getExtendMethod('@Attributes/store/attributeGroup/action/updateAttributeGroup/__before', {
$this: this,
data: {
id,
Expand All @@ -186,7 +186,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/updateAttributeGroup/__after', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/updateAttributeGroup/__after', {
$this: this,
data,
});
Expand Down Expand Up @@ -221,7 +221,7 @@ export default {
} = state;

// EXTENDED BEFORE METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/removeAttributeGroup/__before', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/removeAttributeGroup/__before', {
$this: this,
data: {
id,
Expand All @@ -235,7 +235,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Attributes/store/attributeGroup/action/removeAttributeGroup/__after', {
await this.$getExtendMethod('@Attributes/store/attributeGroup/action/removeAttributeGroup/__after', {
$this: this,
});
// EXTENDED AFTER METHOD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
}) {
try {
// EXTENDED BEFORE METHOD
await this.$extendMethods('@Authentication/store/authentication/action/getUser/__before', {
await this.$getExtendMethod('@Authentication/store/authentication/action/getUser/__before', {
$this: this,
});
// EXTENDED BEFORE METHOD
Expand All @@ -118,7 +118,7 @@ export default {
});

// EXTENDED AFTER METHOD
await this.$extendMethods('@Authentication/store/authentication/action/getUser/__after', {
await this.$getExtendMethod('@Authentication/store/authentication/action/getUser/__after', {
$this: this,
data: transformedUserData,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export default {
];
},
extendedFilterComponents() {
return this.$getExtendedComponents('@UI/components/AdvancedFilters/Type');
return this.$getExtendSlot('@UI/components/AdvancedFilters/Type');
},
selectedTreeCategoryIds() {
if (!this.isCategoryTreeSelected) {
Expand Down
Loading

0 comments on commit 53b9ada

Please sign in to comment.