fix(接口测试):修复只读用户权限过高能对数据进行操作 (#1614)

Co-authored-by: 黎龙鑫 <lilongxinya@163.com>
Co-authored-by: jianxing <41557596+AgAngle@users.noreply.github.com>
This commit is contained in:
Ambitiousliga 2021-03-11 20:41:25 +08:00 committed by GitHub
parent 5ec898a4fb
commit b8c8d036bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 15 deletions

View File

@ -25,6 +25,7 @@
:trash-enable="trashEnable"
:checkRedirectID="checkRedirectID"
:isRedirectEdit="isRedirectEdit"
:is-read-only="isReadOnly"
@openScenario="editScenario"
@edit="editScenario"
@changeSelectDataRangeAll="changeSelectDataRangeAll"
@ -66,7 +67,7 @@
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
import {getUUID, downloadFile} from "@/common/js/utils";
import {getUUID, downloadFile, checkoutTestManagerOrTestUser} from "@/common/js/utils";
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
import MsEditApiScenario from "./scenario/EditApiScenario";
import {getCurrentProjectID} from "../../../../common/js/utils";
@ -92,6 +93,9 @@
let redirectParam = this.$route.params.dataSelectRange;
this.checkRedirectEditPage(redirectParam);
return redirectParam;
},
isReadOnly(){
return !checkoutTestManagerOrTestUser();
}
},
data() {

View File

@ -24,7 +24,7 @@
<el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/>
</template>
</el-table-column>
<template v-for="(item, index) in tableLabel">
@ -33,7 +33,8 @@
min-width="120px"
show-overflow-tooltip :key="index">
<template slot-scope="scope">
<el-tooltip content="编辑">
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
<el-tooltip v-else content="编辑">
<a style="cursor:pointer" @click="edit(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</template>
@ -107,7 +108,7 @@
min-width="120px"
show-overflow-tooltip :key="index"/>
</template>
<el-table-column fixed="right" :label="$t('commons.operating')" width="190px" v-if="!referenced">
<el-table-column fixed="right" :label="$t('commons.operating')" width="190px" v-if="!referenced && !isReadOnly">
<template slot="header">
<header-label-operate @exec="customHeader"/>
</template>
@ -232,6 +233,11 @@
default() {
return []
},
},
//
isReadOnly: {
type: Boolean,
default: false,
}
},
data() {

View File

@ -46,6 +46,7 @@
:trash-enable="trashEnable"
:queryDataType="queryDataType"
:selectDataRange="selectDataRange"
:is-read-only="isReadOnly"
@changeSelectDataRangeAll="changeSelectDataRangeAll"
@editApi="editApi"
@handleCase="handleCase"
@ -60,6 +61,7 @@
:select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
:queryDataType="queryDataType"
:is-read-only="isReadOnly"
@changeSelectDataRangeAll="changeSelectDataRangeAll"
@handleCase="handleCase"
@showExecResult="showExecResult"
@ -138,7 +140,7 @@ import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
import {getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils";
import {checkoutTestManagerOrTestUser, getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
@ -155,6 +157,9 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
this.changeRedirectParam(redirectIDParam);
return routeParam;
},
isReadOnly(){
return !checkoutTestManagerOrTestUser();
}
},
components: {
MsTabButton,

View File

@ -26,14 +26,17 @@
<el-table-column width="30" :resizable="false" min-width="30px" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
<!-- 选中后浮现提供批量操作的按钮-->
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/>
</template>
</el-table-column>
<template v-for="(item, index) in tableLabel">
<el-table-column v-if="item.id == 'num'" prop="num" label="ID" min-width="120px" show-overflow-tooltip
:key="index">
<template slot-scope="scope">
<el-tooltip content="编辑">
<!-- 为只读用户的话不能编辑 -->
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
<el-tooltip content="编辑" v-else>
<a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</template>

View File

@ -27,7 +27,8 @@
<el-table-column width="30" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
<!-- 选中记录后浮现的按钮提供对记录的批量操作 -->
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/>
</template>
</el-table-column>
<template v-for="(item, index) in tableLabel">
@ -40,9 +41,11 @@
sortable="custom"
:key="index">
<template slot-scope="scope">
<el-tooltip content="编辑">
<!-- 判断为只读用户的话不可点击ID进行编辑操作 -->
<span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>
<el-tooltip v-else content="编辑">
<a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip>
</el-tooltip >
</template>
</el-table-column>
<el-table-column
@ -155,7 +158,7 @@
show-overflow-tooltip
:key="index"/>
</template>
<!-- 操作 -->
<el-table-column fixed="right" v-if="!isReadOnly" min-width="180"
align="center">
@ -168,6 +171,7 @@
:tip="$t('api_test.automation.execute')"
icon="el-icon-video-play"
@exec="runApi(scope.row)"/>
<!-- 回收站的恢复按钮 -->
<ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left"
@exec="reductionApi(scope.row)" v-if="trashEnable" v-tester/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editApi(scope.row)" v-else
@ -179,6 +183,7 @@
<el-button @click="handleTestCase(scope.row)"
@keydown.enter.native.prevent
type="primary"
:disabled="isReadOnly"
circle
style="color:white;padding: 0px 0.1px;font-size: 11px;width: 28px;height: 28px;"
size="mini">case
@ -218,7 +223,7 @@ import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {downloadFile, getUUID} from "@/common/js/utils";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
import {PROJECT_NAME} from '@/common/js/constants';
import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants';

View File

@ -9,7 +9,11 @@
<el-table-column prop="index" :label="$t('api_test.home_page.running_task_list.table_coloum.index')" width="80" show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('commons.name')" width="200" >
<template v-slot:default="{row}">
<el-link type="info" @click="redirect(row)">
<!-- 若为只读用户不可点击之后跳转-->
<span v-if="isReadOnly">
{{ row.name }}
</span>
<el-link v-else type="info" @click="redirect(row)">
{{ row.name }}
</el-link>
</template>
@ -25,9 +29,10 @@
<template v-slot:default="scope">
<div>
<el-switch
:disabled="isReadOnly"
v-model="scope.row.taskStatus"
class="captcha-img"
@click.native="closeTaskConfirm(scope.row)"
@change="closeTaskConfirm(scope.row)"
></el-switch>
</div>
</template>
@ -51,7 +56,7 @@
</template>
<script>
import {getCurrentProjectID} from "@/common/js/utils";
import {checkoutTestManagerOrTestUser, getCurrentProjectID} from "@/common/js/utils";
import MsTag from "@/business/components/common/components/MsTag";
export default {
name: "MsRunningTaskList",
@ -69,6 +74,12 @@ export default {
}
},
computed:{
isReadOnly(){
return !checkoutTestManagerOrTestUser();
}
},
methods: {
search() {
let projectID = getCurrentProjectID();