forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Much simpler default dataset permissions for typical users.
- Loading branch information
Showing
4 changed files
with
126 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<script lang="ts" setup> | ||
import axios from "axios"; | ||
import { computed, ref } from "vue"; | ||
import { withPrefix } from "@/utils/redirect"; | ||
import FormGeneric from "@/components/Form/FormGeneric.vue"; | ||
interface UserDatasetPermissionsProps { | ||
userId: string; | ||
} | ||
const props = defineProps<UserDatasetPermissionsProps>(); | ||
const loading = ref(true); | ||
interface InputOption { | ||
roleName: string; | ||
roleValue: number; | ||
} | ||
const selectedAdvancedForm = ref(false); | ||
const managePermissionsOptions = ref<InputOption[]>([]); | ||
const accessPermissionsOptions = ref<InputOption[]>([]); | ||
const managePermissions = ref<number[]>([]); | ||
const accessPermissions = ref<number[]>([]); | ||
const inputsUrl = computed(() => { | ||
return `/api/users/${props.userId}/permissions/inputs`; | ||
}); | ||
async function init() { | ||
const { data } = await axios.get(withPrefix(inputsUrl.value)); | ||
console.log(data); | ||
loading.value = false; | ||
const inputs = data.inputs; | ||
const manageInput = inputs[0]; | ||
const accessInput = inputs[1]; | ||
managePermissionsOptions.value = manageInput.options.map((v: [string, number]) => { return <InputOption> {roleName: v[0], roleValue: v[1]}; } ); | ||
accessPermissionsOptions.value = accessInput.options.map((v: [string, number]) => { return <InputOption> {roleName: v[0], roleValue: v[1]}; } ); | ||
managePermissions.value = manageInput.value; | ||
accessPermissions.value = accessInput.value; | ||
} | ||
init(); | ||
const simplePermissions = computed(() => { | ||
// we have one manage permission and read access can be that or not that but nothing else | ||
const hasOneManagePermission = managePermissions.value.length == 1; | ||
const hasAtMostOneAccessPermissions = accessPermissions.value.length < 2; | ||
if (!hasOneManagePermission || !hasAtMostOneAccessPermissions) { | ||
return false; | ||
} | ||
const managePermissionValue = managePermissions.value[0]; | ||
return accessPermissions.value.length == 0 || accessPermissions.value[0] == managePermissionValue; | ||
}); | ||
const title = "Set Dataset Permissions for New Histories"; | ||
const formConfig = computed(() => { | ||
return { | ||
title: title, | ||
id: "edit-preferences-permissions", | ||
description: "Grant others default access to newly created histories. Changes made here will only affect histories created after these settings have been stored.", | ||
url: inputsUrl.value, | ||
icon: "fa-users", | ||
submitTitle: "Save Permissions", | ||
redirect: "/user", | ||
}; | ||
}); | ||
const checked = ref(false); | ||
async function change(value: unknown) { | ||
const managePermissionValue: number = managePermissions.value[0] as number; | ||
let access: number[] = [] as number[]; | ||
if(value) { | ||
access = [managePermissionValue]; | ||
} | ||
const formValue = { | ||
"DATASET_MANAGE_PERMISSIONS": [managePermissionValue], | ||
"DATASET_ACCESS": access, | ||
}; | ||
const { data } = await axios.put(withPrefix(inputsUrl.value), formValue); | ||
console.log(data); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div v-if="loading"> | ||
Loading.... | ||
</div> | ||
<div v-else-if="simplePermissions && !selectedAdvancedForm"> | ||
<div class="ui-portlet-section"> | ||
<div class="portlet-header"><span class="portlet-title"><span class="portlet-title-icon fa mr-1 fa-users"></span> <b itemprop="name" class="portlet-title-text">{{ title }}</b> </span></div> | ||
<div class="portlet-content"> | ||
<div class="mb-3 mt-3"> | ||
<b-form-checkbox v-model="checked" name="check-button" switch @change="change"> | ||
Make new datasets private | ||
</b-form-checkbox> | ||
</div> | ||
<a href="#" @click="selectedAdvancedForm = true">Show advanced options.</a> | ||
</div> | ||
</div> | ||
</div> | ||
<div v-else> | ||
<FormGeneric v-bind="formConfig" /> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters