Skip to content

Commit

Permalink
View/Report permissions fixed (#3874)
Browse files Browse the repository at this point in the history
Co-authored-by: Ramin Haeri Azad <[email protected]>
  • Loading branch information
kazoompa and Ramin Haeri Azad authored Jul 25, 2024
1 parent b5dde57 commit 0602c66
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
11 changes: 11 additions & 0 deletions opal-ui/src/components/permissions/AccessControlTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ const cases = [
{ regex: /\/files\/(.*)$/, type: 'folder' },
{ regex: /\/datasource\/([^\/]+)\/table\/([^\/]+)\/variable\/(.*)$/, type: 'variable' },
{ regex: /\/datasource\/([^\/]+)\/table\/(.*)$/, type: 'table' },
{ regex: /\/datasource\/([^\/]+)\/view\/(.*)$/, type: 'view' },
{ regex: /\/datasource\/(.*)$/, type: 'project' },
{ regex: /\/project\/(.*)\/resources$/, type: 'resources' },
{ regex: /\/project\/(.*)\/resource\/(.*)$/, type: 'resource' },
{ regex: /\/project\/(.*)\/report-template/, type: 'report', url: '/admin/datashield' },
{ regex: /\/project\/(.*)$/, type: 'project' },
{ regex: /\/r$/, type: 'r_service', url: '/admin/rservers' },
{ regex: /\/datashield$/, type: 'datashield_service', url: '/admin/datashield' },
{ regex: /\/datashield\/profile\/(.*)$/, type: 'datashield_profile', url: '/admin/datashield' },
Expand Down Expand Up @@ -147,6 +150,10 @@ const rows = computed(() => {
case 'table':
result.title = `${match[1]}.${match[2]}`;
break;
case 'view':
result.title = `${match[1]}.${match[2]}`;
result.caption = t(item.type);
break;
case 'variable':
result.title = `${match[1]}.${match[2]}.${match[3]}`;
break;
Expand All @@ -156,6 +163,10 @@ const rows = computed(() => {
case 'resource':
result.title = `${match[1]}.${match[2]}`;
break;
case 'report':
result.title = `${match[1]}`;
result.caption = t(item.type);
break;
case 'r_service':
result.title = 'R';
result.caption = t(item.type);
Expand Down
12 changes: 7 additions & 5 deletions opal-ui/src/i18n/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default {
label: 'Add projects',
description: 'Add new projects and therefore can import/export data in the context of the project.',
},
PROJECT_All: {
PROJECT_ALL: {
label: 'Administrate projects',
description: 'Full access to project.',
},
Expand Down Expand Up @@ -255,12 +255,12 @@ export default {
},
// report permissions
REPORT_TEMPLATE_ALL: {
label: 'REPORT_TEMPLATE_ALL',
description: 'REPORT_TEMPLATE_ALL',
label: 'Administrate reports',
description: 'Full access to the report template (settings and reports).',
},
REPORT_TEMPLATE_READ: {
label: 'REPORT_TEMPLATE_ALL',
description: 'REPORT_TEMPLATE_ALL',
label: 'View reports',
description: 'View reports only.',
},
// resource permissions
RESOURCE_ALL: {
Expand Down Expand Up @@ -740,6 +740,7 @@ export default {
referenced_entity_type: 'Referenced entity type',
refresh: 'Refresh',
repeatable: 'Repeatable',
report: 'Report',
reports_caption: 'Configure and schedule reports',
reports: 'Reports',
reset: 'Reset',
Expand Down Expand Up @@ -837,6 +838,7 @@ export default {
variables: 'Variables',
variance: 'Variance',
version: 'Version',
view: 'View',
waiting: 'Waiting',
public_url: 'Public URL',
logout_url: 'URL after logout',
Expand Down
12 changes: 7 additions & 5 deletions opal-ui/src/i18n/fr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default {
label: 'Ajouter des projets',
description: 'Ajouter de nouveaux projets et ainsi pouvoir importer/exporter des données dans ces projets.',
},
PROJECT_All: {
PROJECT_ALL: {
label: 'Administrer le project',
description: 'Accès complet au projet',
},
Expand Down Expand Up @@ -255,12 +255,12 @@ export default {
},
// report permissions
REPORT_TEMPLATE_ALL: {
label: 'REPORT_TEMPLATE_ALL',
description: 'REPORT_TEMPLATE_ALL',
label: 'Administrer les rapports',
description: 'Accès complet au modèle de rapport (paramètres et rapports).',
},
REPORT_TEMPLATE_READ: {
label: 'REPORT_TEMPLATE_ALL',
description: 'REPORT_TEMPLATE_ALL',
label: 'Voir les rapports',
description: 'Voir les rapports uniquement.',
},
// resource permissions
RESOURCE_ALL: {
Expand Down Expand Up @@ -740,6 +740,7 @@ export default {
referenced_entity_type: "Type d'entité référencée",
refresh: 'Rafraîchir',
repeatable: 'Répétable',
report: 'Rapport',
reports_caption: 'Configurer et planifier des rapports',
reports: 'Rapports',
reset: 'Réinitialiser',
Expand Down Expand Up @@ -837,6 +838,7 @@ export default {
variables: 'Variables',
variance: 'Variance',
version: 'Version',
view: 'Vue',
waiting: 'En attente',
public_url: 'URL publique',
logout_url: 'URL après déconnexion',
Expand Down
9 changes: 3 additions & 6 deletions opal-ui/src/pages/ProjectPermsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<q-item
clickable
active-class="bg-light-blue-1"
:active="index === 0"
:active="selectedSubject.principal === subject.principal"
v-for="subject in subjects"
:key="subject.principal"
@click="onSubject(subject)"
Expand All @@ -46,7 +46,6 @@
:on-delete-acls="onDeleteAcls"
:hide-delete="false"
:loading="loading"
@selected="onSelectedAcl"
/>
</div>
</div>
Expand Down Expand Up @@ -112,6 +111,7 @@ function initializeSubjectTypes() {
subjectTypes.value = projectsStore.subjects.reduce((acc: Record<string, Subject[]>, subject: Subject) => {
acc[subject.type] = acc[subject.type] || [];
acc[subject.type].push(subject);
acc[subject.type].sort((a, b) => a.principal.localeCompare(b.principal));
return acc;
}, {} as Record<string, Subject[]>);
}
Expand All @@ -133,17 +133,14 @@ async function loadSubjects() {
// Handlers
function onSelectedAcl(acls: Acl[]) {
selectedAcls.value = acls;
}
function onDeleteAcls() {
showDeletes.value = true;
}
async function onSubject(subject: Subject) {
try {
selectedSubject.value = subject;
acls.value = await projectsStore.getSubjectPermissions(subject);
} catch (error) {
notifyError(error);
Expand Down
9 changes: 5 additions & 4 deletions opal-ui/src/stores/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ export const useProjectsStore = defineStore('projects', () => {
}

async function deleteSubjectPermission(subject: Subject, acl: Acl) {
const resource =
acl.resource.indexOf('table') > -1
? acl.resource.replace(/.*table/, 'table')
: acl.resource.replace(/\/datasource.*$/, 'datasource');
const resource = acl.resource
.replace(/^\//, '')
.replace(/^datasource.*/, 'datasource')
.replace(/.*(table|view)/, 'table')
.replace(/.*report-template/, 'report-template');

const params = { principal: subject.principal, type: subject.type };
return api.delete(`/project/${project.value.name}/permissions/${resource}`, {
Expand Down

0 comments on commit 0602c66

Please sign in to comment.