diff --git a/src/components/dropdowns/UserSettingsDropdown.vue b/src/components/dropdowns/UserSettingsDropdown.vue index 9408ec4..e245908 100644 --- a/src/components/dropdowns/UserSettingsDropdown.vue +++ b/src/components/dropdowns/UserSettingsDropdown.vue @@ -5,10 +5,10 @@ - -
+
{{ $t('pageNewsReadMore') }} - {{ $t('buttonDelete') }} + {{ $t('buttonDelete') }} @@ -59,7 +59,7 @@ {{ $t('pageNewsReadMore') }} - + {{ $t('buttonDelete') }} @@ -76,7 +76,7 @@ @change="updateProjects" /> -
+
{{ $t('buttonAddNews') }}
@@ -89,7 +89,7 @@ import { mapGetters } from 'vuex' import MdiIcon from '@/components/icons/MdiIcon' import DataImportJobs from '@/components/dataimport/DataImportJobs' import AddNewsModal from '@/components/modals/AddNewsModal' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { apiPostNewsTable, apiDeleteNews } from '@/mixins/api/misc' import { getImageUrl } from '@/mixins/image' import { MAX_JAVA_INTEGER } from '@/mixins/api/base' @@ -184,7 +184,8 @@ export default { text: () => this.$t('widgetNewsTypeGeneralNews'), path: mdiNewspaper } - } + }, + USER_TYPE_DATA_CURATOR } }, watch: { diff --git a/src/components/structure/SidebarAsyncJobs.vue b/src/components/structure/SidebarAsyncJobs.vue index 67c9389..a1cb02a 100644 --- a/src/components/structure/SidebarAsyncJobs.vue +++ b/src/components/structure/SidebarAsyncJobs.vue @@ -103,7 +103,7 @@  {{ $t('widgetAsyncJobPanelFeedback') }}
-
+
@@ -148,7 +148,7 @@ import { mdiDelete, mdiDownload, mdiUpload, mdiRefresh, mdiDatabase, mdiClose, m import UploadStatusTable from '@/components/tables/UploadStatusTable' import { apiPostDatasetAsyncExport, apiDeleteDatasetAsyncExport } from '@/mixins/api/dataset' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { apiPostDataAsyncImport, apiDeleteDataAsyncImport, apiGetDataAsyncImportStart, apiGetDataAsyncImportLog } from '@/mixins/api/misc' import { templateImportTypes } from '@/mixins/types' import { downloadBlob } from '@/mixins/util' @@ -258,7 +258,8 @@ export default { path: mdiImageMultiple, color: () => this.storeServerSettings ? this.storeServerSettings.colorsTemplate[5 % this.storeServerSettings.colorsTemplate.length] : null } - } + }, + USER_TYPE_DATA_CURATOR } }, computed: { diff --git a/src/components/structure/SidebarComponent.vue b/src/components/structure/SidebarComponent.vue index 9240a6d..368fed2 100644 --- a/src/components/structure/SidebarComponent.vue +++ b/src/components/structure/SidebarComponent.vue @@ -25,10 +25,11 @@ import 'vue-sidebar-menu/dist/vue-sidebar-menu.css' import { getNumberWithSuffix } from '@/mixins/formatting' -import { mdiArrowCollapseLeft, mdiArrowCollapseRight, mdiChartAreaspline, mdiBookOpenPageVariant, mdiChartGantt, mdiChartSankey, mdiChevronRight, mdiDatabase, mdiDna, mdiEarth, mdiFileDownload, mdiFileExport, mdiFolderTable, mdiFormatIndentIncrease, mdiGroup, mdiHarddisk, mdiHome, mdiImageMultiple, mdiInformation, mdiInformationOutline, mdiMagnify, mdiMap, mdiMapSearch, mdiNewspaperVariant, mdiPulse, mdiReorderVertical, mdiShovel, mdiSprout, mdiTagMultiple, mdiTagTextOutline, mdiWeatherSnowyRainy } from '@mdi/js' +import { mdiArrowCollapseLeft, mdiArrowCollapseRight, mdiViewGridPlusOutline, mdiChartAreaspline, mdiBookOpenPageVariant, mdiChartGantt, mdiChartSankey, mdiChevronRight, mdiDatabase, mdiDna, mdiEarth, mdiFileDownload, mdiFileExport, mdiFolderTable, mdiFormatIndentIncrease, mdiGroup, mdiHarddisk, mdiHome, mdiImageMultiple, mdiInformation, mdiInformationOutline, mdiMagnify, mdiMap, mdiMapSearch, mdiNewspaperVariant, mdiPulse, mdiReorderVertical, mdiShovel, mdiSprout, mdiTagMultiple, mdiTagTextOutline, mdiWeatherSnowyRainy } from '@mdi/js' import { apiGetOverviewStats } from '@/mixins/api/stats' import { Pages } from '@/mixins/pages' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' const emitter = require('tiny-emitter/instance') const germinateLogo = 'M 11.999836,0 C 5.384778,0 -3.9999998e-7,5.38515 0,12.00026 -3.9999998e-7,18.61531 5.384778,24.00011 11.999836,24.00011 18.614894,24.00011 24,18.61531 24,12.00026 24,5.38515 18.614894,0 11.999836,0 Z m 0,2.09227 c 5.484271,0 9.907984,4.42367 9.907984,9.90799 0,5.48425 -4.423713,9.90754 -9.907984,9.90754 -5.4842703,0 -9.9076558,-4.42329 -9.9076558,-9.90754 0,-5.48432 4.4233855,-9.90799 9.9076558,-9.90799 z M 9.5003025,5.50579 c -2.4997191,0 -2.4997043,0 -3.7494633,2.16472 L 4.500991,9.83539 c -1.2498943,2.16476 -1.2498943,2.16487 0,4.32945 l 1.2498482,2.16476 c 1.261759,2.16476 1.2617442,2.16476 3.7494633,2.16476 2.4996545,0 2.4997185,0 3.7495455,-2.16476 h -8.1e-5 c 1.249812,-2.16476 1.249787,-2.16469 0,-4.32934 v -1.1e-4 H 10.750152 8.2505363 l 1.2497662,2.16469 H 12 L 10.750152,16.3296 H 8.2505363 L 7.0006881,14.16484 5.7508392,12.00015 7.0006881,9.83539 8.2505363,7.67051 h 2.4996157 2.499696 L 12,5.50579 Z m 4.9993125,0 1.249849,2.16472 1.249848,2.16488 h -2.499697 l -1.249767,2.16476 h 2.499616 l 1.249848,2.16469 -1.249848,2.16476 -1.249849,2.16476 h 2.499697 l 1.249849,-2.16476 1.249766,-2.16476 c 1.249826,-2.16476 1.249826,-2.16469 0,-4.32945 L 18.249161,7.67051 16.999312,5.50579 Z' @@ -58,7 +59,8 @@ export default { }, computed: { ...mapGetters([ - 'storeServerSettings' + 'storeServerSettings', + 'storeToken' ]), menu: function () { const tempNav = [ @@ -206,6 +208,18 @@ export default { path: mdiShovel } } + }, + { + title: this.$t('menuTrialsCreate'), + identifiers: ['trial-creation'], + href: { name: Pages.trialCreation }, + icon: { + element: SidebarIcon, + attributes: { + path: mdiViewGridPlusOutline + } + }, + hidden: !userIsAtLeast(this.storeToken ? this.storeToken.userType : null, USER_TYPE_DATA_CURATOR) } ] }, @@ -474,25 +488,29 @@ export default { } ] - if (this.storeServerSettings && this.storeServerSettings.hiddenPages && this.storeServerSettings.hiddenPages.length > 0) { - const hiddenPages = this.storeServerSettings.hiddenPages + const hiddenPages = (this.storeServerSettings && this.storeServerSettings.hiddenPages && this.storeServerSettings.hiddenPages.length > 0) ? this.storeServerSettings.hiddenPages : [] - return tempNav.filter(function f (o) { - if (o.identifiers) { - if (o.identifiers.some(i => hiddenPages.includes(i))) { - return false - } - } + // const currentUserType = this.storeToken ? this.storeToken.userType : null - if (o.child && o.child.length > 0) { - return (o.child = o.child.filter(f)).length + return tempNav.filter(function f (o) { + if (o.identifiers) { + if (o.identifiers.some(i => hiddenPages.includes(i))) { + return false } + } - return true - }) - } else { - return tempNav - } + // if (o.minUserType) { + // if (!userIsAtLeast(currentUserType, o.minUserType)) { + // return false + // } + // } + + if (o.child && o.child.length > 0) { + return (o.child = o.child.filter(f)).length + } + + return true + }) } }, methods: { diff --git a/src/components/structure/StoryNavbar.vue b/src/components/structure/StoryNavbar.vue index 775dc1a..97bc409 100644 --- a/src/components/structure/StoryNavbar.vue +++ b/src/components/structure/StoryNavbar.vue @@ -26,7 +26,7 @@ {{ $t('buttonCloseStory') }} - + @@ -78,7 +78,7 @@ import MdiIcon from '@/components/icons/MdiIcon' import AddStoryStepModal from '@/components/modals/AddStoryStepModal' import { mdiChevronLeft, mdiChevronRight, mdiClose, mdiArrowDown, mdiArrowDownRight, mdiFormatListNumbered, mdiDelete, mdiPencil } from '@mdi/js' import { getImageUrlById } from '@/mixins/image' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { apiDeleteStoryStep, apiPostStoryTable } from '@/mixins/api/misc' export default { @@ -97,7 +97,8 @@ export default { mdiChevronLeft, mdiChevronRight, showPopover: true, - stepIndexOffset: 0 + stepIndexOffset: 0, + USER_TYPE_DATA_CURATOR } }, computed: { diff --git a/src/components/tables/DatasetTable.vue b/src/components/tables/DatasetTable.vue index 21e63a4..85fdfda 100644 --- a/src/components/tables/DatasetTable.vue +++ b/src/components/tables/DatasetTable.vue @@ -194,7 +194,7 @@ import { apiPostPedigreeDatasetExport } from '@/mixins/api/germplasm' import { datasetStates, datasetTypes } from '@/mixins/types' import { getHighContrastTextColor } from '@/mixins/colors' import { isPageAvailable, downloadBlob } from '@/mixins/util' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { getDateTimeString, isTruncatedAfterWords, truncateAfterWords, getNumberWithSuffix } from '@/mixins/formatting' import { mdiHelpCircle, mdiOpenInNew, mdiPageNext, mdiInformationOutline, mdiPlusBox, mdiDelete, mdiAttachment, mdiMapMarker, mdiCheck, mdiNewBox, mdiTextBoxCheckOutline, mdiAccountMultiple, mdiFilePlus, mdiDownload, mdiSquareEditOutline, mdiLinkBoxVariantOutline, mdiTextBoxOutline } from '@mdi/js' @@ -268,7 +268,7 @@ export default { 'storeToken' ]), userIsDataCurator: function () { - return this.storeToken && userIsAtLeast(this.storeToken.userType, 'Data Curator') + return this.storeToken && userIsAtLeast(this.storeToken.userType, USER_TYPE_DATA_CURATOR) }, localTableActions: function () { return [{ diff --git a/src/components/tables/ExperimentTable.vue b/src/components/tables/ExperimentTable.vue index 1643546..9afbaac 100644 --- a/src/components/tables/ExperimentTable.vue +++ b/src/components/tables/ExperimentTable.vue @@ -49,14 +49,14 @@ @@ -76,7 +76,7 @@ import ExperimentCreationModal from '@/components/modals/ExperimentCreationModal import { datasetTypes } from '@/mixins/types' import { getHighContrastTextColor } from '@/mixins/colors' import { isTruncatedAfterWords, truncateAfterWords } from '@/mixins/formatting' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { mdiPageNext, mdiSquareEditOutline, mdiDelete } from '@mdi/js' import { Pages } from '@/mixins/pages' @@ -103,7 +103,8 @@ export default { idColumn: 'experimentId', tableName: 'experiments' }, - selectedExperiment: null + selectedExperiment: null, + USER_TYPE_DATA_CURATOR } }, computed: { @@ -143,7 +144,7 @@ export default { } ] - if (this.storeToken && userIsAtLeast(this.storeToken.userType, 'Data Curator')) { + if (this.storeToken && userIsAtLeast(this.storeToken.userType, USER_TYPE_DATA_CURATOR)) { result.push({ key: 'edit', type: undefined, diff --git a/src/components/tables/FileresourceTable.vue b/src/components/tables/FileresourceTable.vue index b1daf37..8bc5c7f 100644 --- a/src/components/tables/FileresourceTable.vue +++ b/src/components/tables/FileresourceTable.vue @@ -30,7 +30,7 @@
@@ -40,7 +40,7 @@ import { mapGetters } from 'vuex' import BaseTable from '@/components/tables/BaseTable' import defaultProps from '@/const/table-props.js' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { isTruncatedAfterWords, truncateAfterWords, getNumberWithSuffix } from '@/mixins/formatting' import { apiDeleteFileresource, apiGetDataResource } from '@/mixins/api/dataset' import { downloadBlob } from '@/mixins/util' @@ -70,7 +70,8 @@ export default { options: { idColumn: 'fileresourceId', tableName: 'fileresources' - } + }, + USER_TYPE_DATA_CURATOR } }, computed: { @@ -131,7 +132,7 @@ export default { } ] - if (this.storeToken && userIsAtLeast(this.storeToken.userType, 'Data Curator')) { + if (this.storeToken && userIsAtLeast(this.storeToken.userType, USER_TYPE_DATA_CURATOR)) { result.push({ key: 'deleteFileresource', type: undefined, diff --git a/src/components/tables/TraitTable.vue b/src/components/tables/TraitTable.vue index bc7de46..4ac45da 100644 --- a/src/components/tables/TraitTable.vue +++ b/src/components/tables/TraitTable.vue @@ -48,14 +48,14 @@ - +
@@ -66,7 +66,7 @@ import BaseTable from '@/components/tables/BaseTable' import TraitEditModal from '@/components/modals/TraitEditModal' import defaultProps from '@/const/table-props.js' import { dataTypes } from '@/mixins/types.js' -import { userIsAtLeast } from '@/mixins/api/auth' +import { userIsAtLeast, USER_TYPE_ADMINISTRATOR, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth' import { getNumberWithSuffix } from '@/mixins/formatting' import { Pages } from '@/mixins/pages' @@ -94,7 +94,9 @@ export default { idColumn: 'traitId', tableName: 'traits' }, - trait: null + trait: null, + USER_TYPE_ADMINISTRATOR, + USER_TYPE_DATA_CURATOR } }, computed: { @@ -170,7 +172,7 @@ export default { } ] - if (this.storeToken && userIsAtLeast(this.storeToken.userType, 'Data Curator')) { + if (this.storeToken && userIsAtLeast(this.storeToken.userType, USER_TYPE_DATA_CURATOR)) { result.push({ key: 'edit', type: undefined, diff --git a/src/components/tables/UserGroupTable.vue b/src/components/tables/UserGroupTable.vue index 0f55525..1112a44 100644 --- a/src/components/tables/UserGroupTable.vue +++ b/src/components/tables/UserGroupTable.vue @@ -24,7 +24,7 @@