Skip to content

Commit 468b871

Browse files
committed
feat: remove unused role and permission functions to streamline constants module
1 parent e67c47f commit 468b871

2 files changed

Lines changed: 1 addition & 65 deletions

File tree

src/authz-module/constants.test.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
import {
2-
getRolesMetadata,
3-
getPermissions,
4-
getResourceTypes,
5-
courseRolesMetadata,
6-
} from './constants';
7-
8-
describe('getRolesMetadata', () => {
9-
it('returns empty array for unknown resource type', () => {
10-
// @ts-expect-error testing invalid input
11-
expect(getRolesMetadata('unknown')).toEqual([]);
12-
});
13-
});
14-
15-
describe('getPermissions', () => {
16-
it('returns empty array for unknown resource type', () => {
17-
// @ts-expect-error testing invalid input
18-
expect(getPermissions('unknown')).toEqual([]);
19-
});
20-
});
21-
22-
describe('getResourceTypes', () => {
23-
it('returns empty array for unknown resource type', () => {
24-
// @ts-expect-error testing invalid input
25-
expect(getResourceTypes('unknown')).toEqual([]);
26-
});
27-
});
1+
import { courseRolesMetadata } from './constants';
282

293
describe('courseRolesMetadata', () => {
304
it('course_editor and course_auditor are disabled', () => {

src/authz-module/constants.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import {
2-
libraryRolesMetadata,
3-
libraryResourceTypes,
4-
libraryPermissions,
5-
} from '@src/authz-module/roles-permissions/libraries/constants';
6-
71
export const ROUTES = {
82
LIBRARIES_TEAM_PATH: '/libraries/:libraryId',
93
LIBRARIES_USER_PATH: '/libraries/:libraryId/:username',
@@ -86,35 +80,3 @@ export const courseRolesMetadata = [
8680
role: 'course_auditor', name: 'Course Auditor', description: 'Can view course content and settings, but cannot make changes.', contextType: 'course', disabled: true,
8781
},
8882
];
89-
90-
// Get roles metadata by resource type
91-
export const getRolesMetadata = (resourceType: ResourceType) => {
92-
switch (resourceType) {
93-
case RESOURCE_TYPES.LIBRARY:
94-
return libraryRolesMetadata;
95-
case RESOURCE_TYPES.COURSE:
96-
return courseRolesMetadata;
97-
default:
98-
return [];
99-
}
100-
};
101-
102-
// Get permissions by resource type
103-
export const getPermissions = (resourceType: ResourceType) => {
104-
switch (resourceType) {
105-
case RESOURCE_TYPES.LIBRARY:
106-
return libraryPermissions;
107-
default:
108-
return [];
109-
}
110-
};
111-
112-
// Get the resource sub-types (e.g. library, content, collection) for the given resource type
113-
export const getResourceTypes = (resourceType: ResourceType) => {
114-
switch (resourceType) {
115-
case RESOURCE_TYPES.LIBRARY:
116-
return libraryResourceTypes;
117-
default:
118-
return [];
119-
}
120-
};

0 commit comments

Comments
 (0)