Skip to content

Commit

Permalink
fix(xo-web/home): don't make VM's resource set name clickable for non…
Browse files Browse the repository at this point in the history
…-admins (#6252)

See https://xcp-ng.org/forum/topic/5902/permissions-for-users-to-be-able-to-snapshot/5?_=1653902135402

Non-admin users aren't allowed to view the Self Service page so it doesn't make
sense to have a link to that page
  • Loading branch information
pdonias committed May 30, 2022
1 parent c988200 commit 7451f45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [S3] Fix S3 remote with empty directory not showing anything to restore (PR [#6218](https://github.com/vatesfr/xen-orchestra/pull/6218))
- [S3] remote fom did not save the `https` and `allow unatuhorized`during remote creation (PR [#6219](https://github.com/vatesfr/xen-orchestra/pull/6219))
- [VM/advanced] Fix various errors when adding ACLs [#6213](https://github.com/vatesfr/xen-orchestra/issues/6213) (PR [#6230](https://github.com/vatesfr/xen-orchestra/pull/6230))
- [Home/Self] Don't make VM's resource set name clickable for non admin users as they aren't allowed to view the Self Service page (PR [#6252](https://github.com/vatesfr/xen-orchestra/pull/6252))

### Packages to release

Expand Down
11 changes: 8 additions & 3 deletions packages/xo-web/src/xo-app/home/vm-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Text, XoSelect } from 'editable'
import { isEmpty, map } from 'lodash'
import { addTag, editVm, fetchVmStats, migrateVm, removeTag, startVm, stopVm, subscribeResourceSets } from 'xo'
import { addSubscriptions, connectStore, formatSizeShort, osFamily } from 'utils'
import { createFinder, createGetObject, createGetVmDisks, createSelector, createSumBy } from 'selectors'
import { createFinder, createGetObject, createGetVmDisks, createSelector, createSumBy, isAdmin } from 'selectors'

import MiniStats from './mini-stats'
import styles from './index.css'
Expand All @@ -23,6 +23,7 @@ import styles from './index.css'
})
@connectStore(() => ({
container: createGetObject((_, props) => props.item.$container),
isAdmin,
totalDiskSize: createSumBy(
createGetVmDisks((_, props) => props.item),
'size'
Expand Down Expand Up @@ -65,7 +66,7 @@ export default class VmItem extends Component {
)

render() {
const { item: vm, container, expandAll, selected } = this.props
const { item: vm, container, expandAll, isAdmin, selected } = this.props
const resourceSet = this._getResourceSet()
const state = this._getVmState()

Expand Down Expand Up @@ -189,7 +190,11 @@ export default class VmItem extends Component {
{resourceSet && (
<span>
{_('homeResourceSet', {
resourceSet: <Link to={`self?resourceSet=${resourceSet.id}`}>{resourceSet.name}</Link>,
resourceSet: isAdmin ? (
<Link to={`self?resourceSet=${resourceSet.id}`}>{resourceSet.name}</Link>
) : (
resourceSet.name
),
})}
</span>
)}
Expand Down

0 comments on commit 7451f45

Please sign in to comment.