Skip to content

Commit

Permalink
Merge pull request #3426 from csordasmarton/show_edit_only_for_admins
Browse files Browse the repository at this point in the history
[server][gui] Show edit option only for admins
  • Loading branch information
bruntib authored Sep 8, 2021
2 parents 6892118 + f8fbbd4 commit 1472cd9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
16 changes: 13 additions & 3 deletions web/server/codechecker_server/api/product_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def __require_permission(self, required, args=None):

return True

def __administrating(self, args):
""" True if the current user can administrate the given product. """
if permissions.require_permission(permissions.SUPERUSER, args,
self.__auth_session):
return True

if permissions.require_permission(permissions.PRODUCT_ADMIN, args,
self.__auth_session):
return True

return False

def __get_product(self, session, product):
"""
Retrieve the product connection object and create a Thrift Product
Expand All @@ -95,8 +107,6 @@ def __get_product(self, session, product):
'productID': product.id}
product_access = permissions.require_permission(
permissions.PRODUCT_VIEW, args, self.__auth_session)
product_admin = permissions.require_permission(
permissions.PRODUCT_ADMIN, args, self.__auth_session)

admin_perm_name = permissions.PRODUCT_ADMIN.name
admins = session.query(ProductPermission). \
Expand All @@ -119,7 +129,7 @@ def __get_product(self, session, product):
latestStoreToProduct=latest_storage_date,
connected=connected,
accessible=product_access,
administrating=product_admin,
administrating=self.__administrating(args),
databaseStatus=server_product.db_status,
admins=[admin.name for admin in admins])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
>
<template v-slot:prepend-toolbar-items>
<v-btn
v-if="currentProduct.administrating"
class="manage-cleanup-plan-btn"
icon
small
Expand All @@ -34,6 +35,7 @@
</template>

<script>
import { mapGetters } from "vuex";
import { ccService, handleThriftError } from "@cc-api";
import {
Expand All @@ -58,6 +60,12 @@ export default {
};
},
computed: {
...mapGetters([
"currentProduct"
])
},
watch: {
dialog(value) {
if (value) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
>
<template v-slot:prepend-toolbar-items>
<v-btn
v-if="currentProduct.administrating"
class="manage-components-btn"
icon
small
Expand Down Expand Up @@ -49,6 +50,7 @@
</template>

<script>
import { mapGetters } from "vuex";
import { ccService, handleThriftError } from "@cc-api";
import {
Expand Down Expand Up @@ -79,6 +81,12 @@ export default {
};
},
computed: {
...mapGetters([
"currentProduct"
])
},
watch: {
dialog(value) {
if (value) return;
Expand Down
2 changes: 1 addition & 1 deletion web/server/vue-cli/src/views/Products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<template v-slot:item.action="{ item }">
<div class="text-no-wrap">
<edit-product-btn
v-if="isSuperUser || item.administrating"
v-if="item.administrating"
:product="item"
:is-super-user="isSuperUser"
@on-complete="onCompleteEditProduct"
Expand Down

0 comments on commit 1472cd9

Please sign in to comment.