Commit cb24aa2c authored by Anton's avatar Anton

Refactor ACL functions to mbjs-quasar, update mbjs-quasar, add ACL to mosys grids, update changelog

parent 5bd7c9bf
......@@ -7,12 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Access control menu available for MoSys grids
### Changed
- Moved ACL functionality to [mbjs-quasar](https://gitlab.rlp.net/motionbank/mbjs/quasar) module
## [1.2.1] - 2019-02-15
### Fixed
- Post-annotator timestamps now display correct values, independent of timezone or DST
- currentIndex property no longer throws when attempting to scroll to invalid annotation index
- Timestamps in post-annotator are no longer being cut off, display hours as well
## [1.2.0] - 2019-02-14
### Added
......@@ -46,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [mbjs-api-client](https://gitlab.rlp.net/motionbank/mbjs/api-client) now at version 1.1.0
## [1.1.1] - 2019-01-28
### Fixed
......@@ -99,7 +112,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Start proper versioning at 1.0.0
[Unreleased]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.2.0...master
[Unreleased]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.2.1...master
[1.2.1]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.2.0...v1.2.1
[1.2.0]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.1.1...v1.2.0
[1.1.1]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.1.0...v1.1.1
[1.1.0]: https://gitlab.rlp.net/motionbank/systems-frontend/compare/v1.0.0...v1.1.0
......
......@@ -8692,9 +8692,9 @@
}
},
"mbjs-quasar": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/mbjs-quasar/-/mbjs-quasar-1.1.0.tgz",
"integrity": "sha512-6QkoqmTqKvAkZBH3A1Tn7YyE9YQnk4sb1PzT79Z6SVGvLizA6GcFVXo5uAIvpULEdjGM4GJ0vf7sNjgAC79Sbw==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mbjs-quasar/-/mbjs-quasar-1.2.0.tgz",
"integrity": "sha512-CjXtdTyMQfY81+IW5N637DHBhnuuHImIl8XUHwqphzUod5eFExAG+u0u4YrZwwkQ8K3zTJmTQ8xXpGlRhuf2yA==",
"requires": {
"marked": "^0.5.2",
"sanitize-html": "^1.19.2"
......
......@@ -9,26 +9,23 @@
q-btn.q-mr-md.bg-grey-9(q-if="$route.params.id && userHasPackager", slot="form-buttons-add",
:label="packageLabel", @click="createPackage")
.row
.col-md-12
// access-control(:resource="grid")
.row(v-if="env.IS_STAGING")
.col-md-12
p {{ $t('labels.access_control') }}
q-checkbox(v-model="acl.public", :label="$t('labels.access_control_public')", dark)
.col-md-12
p {{ $t('labels.access_control_add_group') }}
q-input(v-model="acl.group", :label="$t('labels.access_control_add_group')", dark)
.col-md-12
p {{ $t('labels.access_control_remove_group') }}
q-input(v-model="acl.group_remove", :label="$t('labels.access_control_remove_group')", dark)
.row(v-if="availableRoles.length")
.col-md-12
p {{ $t('labels.recursive') }}
q-checkbox(v-model="acl.recursive", :label="$t('labels.recursive')", dark)
.col-md-12
q-btn.q-mr-md.bg-grey-9(:label="$t('buttons.update_access_control')", @click="updateACL")
h5.caption.text-light {{ $t('labels.access_control') }}
p {{ $t('descriptions.access_control') }}
.col-md-12.q-mb-md
q-field(orientation="vertical", dark)
q-select(v-model="acl.group", :clearable="true", :clear-value="undefined",
:float-label="$t('labels.access_control_add_group')", :options="availableRoles", dark)
.col-md-12.q-mb-md
q-field(orientation="vertical", dark)
q-select(v-model="acl.group_remove", :clearable="true", :clear-value="undefined",
:float-label="$t('labels.access_control_remove_group')", :options="availableRoles", dark)
.col-md-12.q-mb-md
q-field(dark)
q-checkbox(v-model="acl.recursive", :label="$t('labels.recursive')", dark)
.row.xs-gutter.full-width.justify-end.items-end
q-btn(:label="$t('buttons.update_access_control')", @click="updateACL", color="grey")
</template>
<script>
......@@ -40,9 +37,7 @@
import constants from 'mbjs-data-models/src/constants'
import { openURL } from 'quasar'
import { mapGetters } from 'vuex'
import { userHasFeature } from 'mbjs-quasar/src/lib'
import { ObjectUtil } from 'mbjs-utils'
import { userHasFeature, aclHelper } from 'mbjs-quasar/src/lib'
export default {
components: {
......@@ -89,7 +84,7 @@
async mounted () {
this.grid = await this.$store.dispatch('maps/get', this.$route.params.id)
if (process.env.IS_STAGING) {
const aclQuery = {role: 'public', uuid: this.grid.uuid, id: this.grid.id, permission: 'get'}
const aclQuery = {role: 'public', id: this.grid.id, permission: 'get'}
const permissions = await this.$store.dispatch('acl/isRoleAllowed', aclQuery)
this.acl.public = permissions.get === true
}
......@@ -98,6 +93,16 @@
...mapGetters({
user: 'auth/getUserState'
}),
availableRoles () {
try {
return this.user[`${process.env.AUTH0_APP_METADATA_PREFIX}roles`]
.filter(role => role !== 'user')
.map(role => { return { label: role, value: role } })
}
catch (e) {
return []
}
},
userHasPackager () {
return userHasFeature(this.user, 'packager')
}
......@@ -124,37 +129,8 @@
}
this.$q.loading.hide()
},
async setACL (action, payload, recursive = false) {
await this.$store.dispatch(action, payload)
if (recursive) {
const results = await this.$store.dispatch('annotations/find', { 'target.id': payload.id })
for (let item of results.items) {
if (item.author.id === this.$store.state.auth.user.uuid) {
const itemPayload = ObjectUtil.merge({}, payload)
itemPayload.uuid = item.uuid
await this.$store.dispatch(action, itemPayload)
}
}
}
},
async updateACL () {
console.debug('setting acl...', this.acl)
if (this.acl.public) {
await this.setACL('acl/set', { role: 'public', uuid: this.grid.uuid, permissions: ['get'] }, this.acl.recursive)
}
else {
await this.setACL('acl/remove', { role: 'public', uuid: this.grid.uuid, permission: 'get' }, this.acl.recursive)
}
if (this.acl.group) {
await this.setACL('acl/set', { role: this.acl.group, uuid: this.grid.uuid, permissions: ['get'] }, this.acl.recursive)
}
if (this.acl.group_remove) {
await this.setACL('acl/remove', { role: this.acl.group_remove, uuid: this.grid.uuid, permission: 'get' }, this.acl.recursive)
}
this.$store.commit('notifications/addMessage', {
body: 'messages.acl_updated',
type: 'success'
})
await aclHelper.updateACL(this, this.acl, this.grid)
}
}
}
......
......@@ -34,9 +34,9 @@
import Tags from '../../../components/shared/partials/Tags'
import FormMain from '../../../components/shared/forms/FormMain'
import { ObjectUtil } from 'mbjs-utils'
import { required } from 'vuelidate/lib/validators'
import constants from 'mbjs-data-models/src/constants'
import { aclHelper } from 'mbjs-quasar/src/lib'
import { openURL } from 'quasar'
import { mapGetters } from 'vuex'
......@@ -128,47 +128,8 @@
}
this.$q.loading.hide()
},
async setACL (action, payload, recursive = false) {
await this.$store.dispatch(action, payload)
if (recursive) {
await this.setRelatedACLForTarget(payload.id, action, payload)
}
},
async setRelatedACLForTarget (targetId, action, payload) {
const results = await this.$store.dispatch('annotations/find', {
'target.id': targetId,
'author.id': this.$store.state.auth.user.uuid
})
for (let item of results.items) {
if (item.author.id === this.$store.state.auth.user.uuid) {
const itemPayload = ObjectUtil.merge({}, payload)
itemPayload.uuid = item.uuid
if (itemPayload.id) itemPayload.id = item.id
await this.$store.dispatch(action, itemPayload)
await this.setRelatedACLForTarget(item.id, action, itemPayload)
}
}
},
async updateACL () {
this.$q.loading.show()
console.debug('setting acl...', this.acl)
if (this.acl.public) {
await this.setACL('acl/set', { role: 'public', uuid: this.timeline.uuid, id: this.timeline.id, permissions: ['get'] }, this.acl.recursive)
}
else {
await this.setACL('acl/remove', { role: 'public', uuid: this.timeline.uuid, id: this.timeline.id, permission: 'get' }, this.acl.recursive)
}
if (this.acl.group) {
await this.setACL('acl/set', { role: this.acl.group, uuid: this.timeline.uuid, id: this.timeline.id, permissions: ['get'] }, this.acl.recursive)
}
if (this.acl.group_remove) {
await this.setACL('acl/remove', { role: this.acl.group_remove, uuid: this.timeline.uuid, id: this.timeline.id, permission: 'get' }, this.acl.recursive)
}
this.$q.loading.hide()
this.$store.commit('notifications/addMessage', {
body: 'messages.acl_updated',
type: 'success'
})
await aclHelper.updateACL(this, this.acl, this.timeline)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment