Skip to content

Commit

Permalink
Merge branch 'master' into fix/members-csv-empty-required
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohvinov authored Jan 10, 2024
2 parents fd37370 + 8663525 commit 0c8ac91
Show file tree
Hide file tree
Showing 39 changed files with 528 additions and 336 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@vuelidate/validators": "^2.0.0",
"@vueuse/core": "^10.3.0",
"@webitel/flow-ui-sdk": "^0.1.14",
"@webitel/ui-sdk": "^23.12.129",
"@webitel/ui-sdk": "^24.2.5",
"axios": "^0.27.1",
"clipboard-copy": "^4.0.1",
"cron-validator": "^1.3.1",
Expand All @@ -36,7 +36,7 @@
"vue-router": "^4.2.5",
"vue2-dropzone": "^3.6.0",
"vuex": "^4.1.0",
"webitel-sdk": "^23.12.9"
"webitel-sdk": "^23.12.11"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
Expand Down
79 changes: 79 additions & 0 deletions src/app/api/PermissionsAPIService/APIPermissionsGetter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import instance from '../instance';
import applyTransform, {
camelToSnake, generateUrl,
merge, mergeEach, notify,
sanitize, snakeToCamel,
starToSearch
} from '@webitel/ui-sdk/src/api/transformers';
import { getDefaultGetListResponse, getDefaultGetParams } from '@webitel/ui-sdk/src/api/defaults';

export default class APIPermissionsGetter {
nestedUrl = 'acl';

constructor(url) {
this.baseUrl = url;

this.listGetter = async ({ parentId, ...params }) => {
const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id'];

const defaultObject = {
user: false,
};

const url = applyTransform(params, [
merge(getDefaultGetParams()),
starToSearch('search'),
(params) => ({ ...params, q: params.search }),
sanitize(fieldsToSend),
camelToSnake(),
generateUrl(`${this.baseUrl}/${parentId}/${this.nestedUrl}`),
]);
try {
const response = await instance.get(url);
const { items, next } = applyTransform(response.data, [
snakeToCamel(),
merge(getDefaultGetListResponse()),
]);
return {
items: applyTransform(items, [
mergeEach(defaultObject),
APIPermissionsGetter.handlePermissionsList,
]),
next,
};
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};
}

static handlePermissionsList(items) {
return items.map((item) => ({
...item,
access: {
x: {
id: ((item.granted.match(/x/g) || []).length + 1),
rule: 'x'.repeat((item.granted.match(/x/g) || []).length),
},
r: {
id: ((item.granted.match(/r/g) || []).length + 1),
rule: 'r'.repeat((item.granted.match(/r/g) || []).length),
},
w: {
id: ((item.granted.match(/w/g) || []).length + 1),
rule: 'w'.repeat((item.granted.match(/w/g) || []).length),
},
d: {
id: ((item.granted.match(/d/g) || []).length + 1),
rule: 'd'.repeat((item.granted.match(/d/g) || []).length),
},
},
}));
}

async getList(params) {
return this.listGetter(params);
}
}
33 changes: 33 additions & 0 deletions src/app/api/PermissionsAPIService/APIPermissionsPatcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import instance from '../instance';
import applyTransform, {
camelToSnake,
notify,
snakeToCamel,
} from '@webitel/ui-sdk/src/api/transformers';

export default class APIPermissionsPatcher {
constructor(baseUrl) {
this.baseUrl = baseUrl;
this.patcher = async ({ changes, id }) => {
const afterUrl = 'acl';
const body = applyTransform(changes, [
camelToSnake(),
]);
const url = `${baseUrl}/${id}/${afterUrl}`;
try {
const response = await instance.patch(url, body);
return applyTransform(response.data, [
snakeToCamel(),
]);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};
}

async patchItem({ id, changes }) {
return this.patcher({ id, changes });
}
}
49 changes: 0 additions & 49 deletions src/app/api/old/PermissionsAPIService/APIPermissionsGetter.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/api/old/PermissionsAPIService/APIPermissionsPatcher.js

This file was deleted.

31 changes: 0 additions & 31 deletions src/app/api/old/instance.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/app/api/old/interceptors/InterceptorType.enum.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/api/old/interceptors/apply.js

This file was deleted.

50 changes: 0 additions & 50 deletions src/app/api/old/interceptors/defaultInterceptorsSetup.js

This file was deleted.

Loading

0 comments on commit 0c8ac91

Please sign in to comment.