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

View File

@ -24,7 +24,7 @@
<el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center"> <el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <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> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <template v-for="(item, index) in tableLabel">
@ -33,7 +33,8 @@
min-width="120px" min-width="120px"
show-overflow-tooltip :key="index"> show-overflow-tooltip :key="index">
<template slot-scope="scope"> <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> <a style="cursor:pointer" @click="edit(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip> </el-tooltip>
</template> </template>
@ -107,7 +108,7 @@
min-width="120px" min-width="120px"
show-overflow-tooltip :key="index"/> show-overflow-tooltip :key="index"/>
</template> </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"> <template slot="header">
<header-label-operate @exec="customHeader"/> <header-label-operate @exec="customHeader"/>
</template> </template>
@ -232,6 +233,11 @@
default() { default() {
return [] return []
}, },
},
//
isReadOnly: {
type: Boolean,
default: false,
} }
}, },
data() { data() {

View File

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

View File

@ -26,14 +26,17 @@
<el-table-column width="30" :resizable="false" min-width="30px" align="center"> <el-table-column width="30" :resizable="false" min-width="30px" align="center">
<template v-slot:default="scope"> <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> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <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 <el-table-column v-if="item.id == 'num'" prop="num" label="ID" min-width="120px" show-overflow-tooltip
:key="index"> :key="index">
<template slot-scope="scope"> <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> <a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip> </el-tooltip>
</template> </template>

View File

@ -27,7 +27,8 @@
<el-table-column width="30" :resizable="false" align="center"> <el-table-column width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <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> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <template v-for="(item, index) in tableLabel">
@ -40,9 +41,11 @@
sortable="custom" sortable="custom"
:key="index"> :key="index">
<template slot-scope="scope"> <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> <a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>
</el-tooltip> </el-tooltip >
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -155,7 +158,7 @@
show-overflow-tooltip show-overflow-tooltip
:key="index"/> :key="index"/>
</template> </template>
<!-- 操作 -->
<el-table-column fixed="right" v-if="!isReadOnly" min-width="180" <el-table-column fixed="right" v-if="!isReadOnly" min-width="180"
align="center"> align="center">
@ -168,6 +171,7 @@
:tip="$t('api_test.automation.execute')" :tip="$t('api_test.automation.execute')"
icon="el-icon-video-play" icon="el-icon-video-play"
@exec="runApi(scope.row)"/> @exec="runApi(scope.row)"/>
<!-- 回收站的恢复按钮 -->
<ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left" <ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left"
@exec="reductionApi(scope.row)" v-if="trashEnable" v-tester/> @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 <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)" <el-button @click="handleTestCase(scope.row)"
@keydown.enter.native.prevent @keydown.enter.native.prevent
type="primary" type="primary"
:disabled="isReadOnly"
circle circle
style="color:white;padding: 0px 0.1px;font-size: 11px;width: 28px;height: 28px;" style="color:white;padding: 0px 0.1px;font-size: 11px;width: 28px;height: 28px;"
size="mini">case size="mini">case
@ -218,7 +223,7 @@ import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; 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 {PROJECT_NAME} from '@/common/js/constants';
import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils"; import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants'; 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="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" > <el-table-column prop="name" :label="$t('commons.name')" width="200" >
<template v-slot:default="{row}"> <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 }} {{ row.name }}
</el-link> </el-link>
</template> </template>
@ -25,9 +29,10 @@
<template v-slot:default="scope"> <template v-slot:default="scope">
<div> <div>
<el-switch <el-switch
:disabled="isReadOnly"
v-model="scope.row.taskStatus" v-model="scope.row.taskStatus"
class="captcha-img" class="captcha-img"
@click.native="closeTaskConfirm(scope.row)" @change="closeTaskConfirm(scope.row)"
></el-switch> ></el-switch>
</div> </div>
</template> </template>
@ -51,7 +56,7 @@
</template> </template>
<script> <script>
import {getCurrentProjectID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentProjectID} from "@/common/js/utils";
import MsTag from "@/business/components/common/components/MsTag"; import MsTag from "@/business/components/common/components/MsTag";
export default { export default {
name: "MsRunningTaskList", name: "MsRunningTaskList",
@ -69,6 +74,12 @@ export default {
} }
}, },
computed:{
isReadOnly(){
return !checkoutTestManagerOrTestUser();
}
},
methods: { methods: {
search() { search() {
let projectID = getCurrentProjectID(); let projectID = getCurrentProjectID();