fix(测试跟踪): 首页跳转权限控制

--bug=1018781 --user=李玉号 【系统设置】用户只开启接口、测试跟踪、性能的首页权限登陆查看缺少模块显示
https://www.tapd.cn/55049933/s/1297747
This commit is contained in:
shiziyuan9527 2022-11-17 16:54:40 +08:00 committed by lyh
parent 167e14cd88
commit 0bcb8e6587
17 changed files with 102 additions and 37 deletions

View File

@ -22,7 +22,7 @@
<el-col :span="12">
<span class="main-info-card-title">{{ $t("home.dashboard.public.this_week") }}</span>
<div class="common-amount">
<el-button class="common-amount-button" @click="redirect('createdInWeek')">
<el-button class="common-amount-button" v-permission-disable="linkPermission" @click="redirect('createdInWeek')">
+{{ countData.createdInWeek }}
<img class="main-info-card-right" src="/assets/figma/icon_right_outlined.svg" alt="">
</el-button>
@ -31,7 +31,7 @@
<el-col :span="12">
<span class="main-info-card-title">{{ $t("home.dashboard.public.fake_error") }}</span>
<div class="common-amount">
<el-button class="common-amount-button" @click="redirect('fakeError')">
<el-button class="common-amount-button" v-permission-disable="linkPermission" @click="redirect('fakeError')">
{{ countData.fakeErrorCount }}
<img class="main-info-card-right" src="/assets/figma/icon_right_outlined.svg" alt="">
</el-button>
@ -54,6 +54,7 @@ export default {
countData: Object,
redirectPageName: String,
redirectDataType: String,
linkPermission: []
},
methods: {
redirect(seletDataType) {

View File

@ -15,6 +15,7 @@
import MsChart from "metersphere-frontend/src/components/chart/MsChart";
import {formatNumber} from "@/api/home";
import {getUUID} from "metersphere-frontend/src/utils";
import {hasPermission} from "metersphere-frontend/src/utils/permission";
export default {
name: "CountChart",
@ -173,7 +174,7 @@ export default {
},
}
},
sublink: "/#/api/definition/" + getUUID() + "/api/thisWeekCount",
sublink: hasPermission('PROJECT_API_DEFINITION:READ') ? "/#/api/definition/" + getUUID() + "/api/thisWeekCount" : "",
subtextStyle: {
color: "#1F2329",
fontSize: 12,

View File

@ -19,6 +19,7 @@
:is-execute-info="false"
redirect-page-name="api"
redirect-data-type="apiTestCase"
:link-permission="['PROJECT_API_DEFINITION:READ']"
@redirectPage="redirectPage"/>
</el-col>
<el-col :span=" 12
@ -46,7 +47,7 @@
{{ $t("home.dashboard.public.covered") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'coveredTestCase', null)">
{{ formatAmount(apiCaseData.coveredCount) }}
</el-link>
@ -57,7 +58,7 @@
{{ $t("home.dashboard.public.not_covered") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'notCoveredTestCase', null)">
{{ formatAmount(apiCaseData.notCoveredCount) }}
</el-link>
@ -84,7 +85,7 @@
{{ $t("home.dashboard.public.executed") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'apiTestCase', 'executedCount', null)">
{{ formatAmount(apiCaseData.executedCount) }}
</el-link>
@ -95,7 +96,7 @@
{{ $t("home.dashboard.public.not_executed") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'apiTestCase', 'unexecuteCount', null)">
{{ formatAmount(apiCaseData.notExecutedCount) }}
</el-link>
@ -122,7 +123,7 @@
{{ $t("home.dashboard.public.pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'apiTestCase', 'executionPassCount', null)">
{{ formatAmount(apiCaseData.passCount) }}
</el-link>
@ -133,7 +134,7 @@
{{ $t("home.dashboard.public.not_pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'apiTestCase', 'executionFailedCount', null)">
{{ formatAmount(apiCaseData.unPassCount) }}
</el-link>

View File

@ -32,7 +32,8 @@
{{ $t('home.dashboard.public.covered') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('api', 'api', 'covered', null)">
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'covered', null)">
{{ formatAmount(apiData.coveredCount) }}
</el-link>
</div>
@ -42,7 +43,8 @@
{{ $t('home.dashboard.public.not_covered') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('api', 'api', 'notCovered', null)">
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'notCovered', null)">
{{ formatAmount(apiData.notCoveredCount) }}
</el-link>
</div>
@ -68,7 +70,7 @@
{{ $t("home.dashboard.public.completed") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('api', 'api', 'Completed', null)">
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']" @click="redirectPage('api', 'api', 'Completed', null)">
{{ formatAmount(apiData.finishedCount) }}
</el-link>
</div>
@ -78,7 +80,7 @@
{{ $t("home.dashboard.public.underway") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('api', 'api', 'Underway', null)">
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']" @click="redirectPage('api', 'api', 'Underway', null)">
{{ formatAmount(apiData.runningCount) }}
</el-link>
</div>
@ -88,7 +90,7 @@
{{ $t("home.dashboard.public.prepared") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('api', 'api', 'Prepare', null)">
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']" @click="redirectPage('api', 'api', 'Prepare', null)">
{{ formatAmount(apiData.notStartedCount) }}
</el-link>
</div>

View File

@ -18,11 +18,13 @@
<main-info-card :title="$t('home.dashboard.scenario.title')" :count-data="scenarioData"
redirect-page-name="scenario"
redirect-data-type="scenario"
:link-permission="['PROJECT_API_SCENARIO:READ']"
@redirectPage="redirectPage"
:is-execute-info="false"/>
</el-col>
<el-col :span="12">
<main-info-card :title="$t('home.dashboard.public.executed_times_in_week')" :count-data="scenarioData"
<main-info-card :link-permission="['PROJECT_API_SCENARIO:READ']"
:title="$t('home.dashboard.public.executed_times_in_week')" :count-data="scenarioData"
:is-execute-info="true"/>
</el-col>
</el-row>
@ -45,7 +47,7 @@
{{ $t("home.dashboard.public.covered") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'coveredScenario', null)">
{{ formatAmount(scenarioData.coveredCount) }}
</el-link>
@ -56,7 +58,7 @@
{{ $t("home.dashboard.public.not_covered") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage('api', 'api', 'notCoveredScenario', null)">
{{ formatAmount(scenarioData.notCoveredCount) }}
</el-link>
@ -83,7 +85,7 @@
{{ $t("home.dashboard.public.executed") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'scenario', 'executedCount', null)">
{{ formatAmount(scenarioData.executedCount) }}
</el-link>
@ -94,7 +96,7 @@
{{ $t("home.dashboard.public.not_executed") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'scenario', 'unExecuteCount', null)">
{{ formatAmount(scenarioData.notExecutedCount) }}
</el-link>
@ -121,7 +123,7 @@
{{ $t("home.dashboard.public.pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'scenario', 'executionPassCount', null)">
{{ formatAmount(scenarioData.passCount) }}
</el-link>
@ -132,7 +134,7 @@
{{ $t("home.dashboard.public.not_pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'scenario', 'executionFailedCount', null)">
{{ formatAmount(scenarioData.unPassCount) }}
</el-link>

View File

@ -18,6 +18,7 @@
<main-info-card :title="$t('home.dashboard.scenario_schedule.title')" :count-data="scenarioScheduleData"
redirect-page-name="scenario"
redirect-data-type="schedule"
:link-permission="['PROJECT_API_SCENARIO:READ']"
@redirectPage="redirectPage"
:is-execute-info="false"/>
</el-col>
@ -46,7 +47,7 @@
{{ $t("home.dashboard.public.running") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'schedule', 'running', null)">
{{ formatAmount(scenarioScheduleData.runningCount) }}
</el-link>
@ -57,7 +58,7 @@
{{ $t("home.dashboard.public.not_run") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'schedule', 'notRun', null)">
{{ formatAmount(scenarioScheduleData.notRunCount) }}
</el-link>
@ -84,7 +85,7 @@
{{ $t("home.dashboard.public.pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_REPORT:READ']"
@click="redirectPage('scenarioReport', 'scenario', 'scheduleExecutionPassCount', null)">
{{ formatAmount(scenarioScheduleData.passCount) }}
</el-link>
@ -95,7 +96,7 @@
{{ $t("home.dashboard.public.not_pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num"
<el-link class="addition-info-num" v-permission-disable="['PROJECT_API_REPORT:READ']"
@click="redirectPage('scenarioReport', 'scenario', 'scheduleExecutionFailedCount', null)">
{{ formatAmount(scenarioScheduleData.unPassCount) }}
</el-link>

View File

@ -52,7 +52,7 @@
</el-table-column>
<el-table-column prop="caseTotal" :label="$t('home.new_case.relation_case')" align="right" width="120">
<template v-slot:default="{row}">
<el-link style="color: #783887;width: 100%;" type="info" :underline="false"
<el-link style="color: #783887;width: 100%;" type="info" :underline="false" v-permission-disable="['PROJECT_API_DEFINITION:READ']"
@click="redirectPage( 'api', 'apiTestCase', 'singleList:' + row.id)">
<span style="float: right">
{{ row.caseTotal }}
@ -63,7 +63,7 @@
<el-table-column prop="scenarioTotal" :label="$t('home.new_case.relation_scenario')" align="right"
width="140">
<template v-slot:default="{row}">
<el-link style="color: #783887;width: 100%;" type="info" :underline="false"
<el-link style="color: #783887;width: 100%;" type="info" :underline="false" v-permission-disable="['PROJECT_API_SCENARIO:READ']"
@click="redirectPage('scenario', 'scenario','list:' +row.scenarioIds)">
<span style="float: right">
{{ row.scenarioTotal }}
@ -96,6 +96,7 @@ import {API_STATUS} from "@/business/definition/model/JsonData";
import ApiStatus from "@/business/definition/components/list/ApiStatus";
import HomeTablePagination from "@/business/home/components/table/HomeTablePagination";
import BasicStatusLabel from "metersphere-frontend/src/components/BasicStatusLabel";
import {hasPermission} from "metersphere-frontend/src/utils/permission";
export default {
name: "UpdatedApiList",
@ -120,6 +121,9 @@ export default {
methods: {
clickRow(row, column, event) {
if (column.property !== 'caseTotal' && column.property !== 'scenarioTotal') {
if (!hasPermission('PROJECT_API_DEFINITION:READ')) {
return;
}
this.redirectPage('api', 'api', 'edit:' + row.id);
}
},

View File

@ -4,6 +4,7 @@ import Drag from "./drag";
import directive from './loading/directive';
import service from './loading/index';
import modules from "./module";
import NoPermissionDisable from "./permission/permission-disable";
export const onceLinkClick = {
@ -36,6 +37,7 @@ export default {
install(Vue) {
Vue.directive('click-outside', ClickOutside);
Vue.directive('permission', Permission.hasPermissions);
Vue.directive('permission-disable', NoPermissionDisable.hasPermissions);
Vue.directive('xpack', Permission.hasLicense);
Vue.directive('preventLinkReClick', onceLinkClick);
Vue.directive('preventReClick', onceClick);

View File

@ -0,0 +1,27 @@
import {hasPermissions} from "../../utils/permission"
function checkPermissions(el, binding) {
const {value} = binding;
if (value && value instanceof Array && value.length > 0) {
let hasPermission = hasPermissions(...(value));
if (!hasPermission) {
if (el.nodeName === 'A') {
el.style["pointer-events"] = "none";
} else {
el.disabled = true;
el.classList.add('is-disabled');
}
}
}
}
export default {
hasPermissions: {
inserted(el, binding) {
checkPermissions(el, binding);
},
update(el, binding) {
checkPermissions(el, binding);
}
}
}

View File

@ -34,7 +34,7 @@
{{ $t('home.case_review_dashboard.not_review') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('notReviewed')">
<el-link class="addition-info-num" @click="redirectPage('notReviewed')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(trackData.prepareCount) }}
</el-link>
</div>
@ -44,7 +44,7 @@
{{ $t('home.case_review_dashboard.finished_review') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('reviewed')">
<el-link class="addition-info-num" @click="redirectPage('reviewed')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(trackData.passCount + trackData.unPassCount) }}
</el-link>
</div>
@ -70,7 +70,7 @@
{{ $t("home.case_review_dashboard.not_pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('UnPass')">
<el-link class="addition-info-num" @click="redirectPage('UnPass')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(trackData.unPassCount) }}
</el-link>
</div>
@ -80,7 +80,7 @@
{{ $t("home.case_review_dashboard.pass") }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('Pass')">
<el-link class="addition-info-num" @click="redirectPage('Pass')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(trackData.passCount) }}
</el-link>
</div>
@ -103,6 +103,7 @@ import hoverCard from "@/business/home/components/card/HoverCard";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getTrackCount} from "@/api/track";
import {formatNumber} from "@/api/track"
import {hasPermission} from "@/business/utils/sdk-utils";
export default {
name: "CaseCountCard",
@ -162,6 +163,9 @@ export default {
return formatNumber(number);
},
redirectPage(clickType) {
if (!hasPermission('PROJECT_TRACK_CASE:READ')) {
return;
}
this.$emit("redirectPage", "testCase", "case", clickType);
}
}

View File

@ -32,7 +32,7 @@
</el-table-column>
<el-table-column prop="testPlan" :label="$t('home.case.test_plan')">
<template v-slot:default="{row}">
<el-link type="info" @click="redirect('testPlanEdit',row.testPlanId)">
<el-link type="info" @click="redirect('testPlanEdit',row.testPlanId)" v-permission-disable="['PROJECT_TRACK_PLAN:READ']">
{{ row.testPlan }}
</el-link>
</template>

View File

@ -34,7 +34,7 @@
{{ $t('home.relevance_dashboard.not_cover') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('uncoverage')">
<el-link class="addition-info-num" @click="redirectPage('uncoverage')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(relevanceData.uncoverageCount) }}
</el-link>
</div>
@ -44,7 +44,7 @@
{{ $t('home.relevance_dashboard.cover') }}
</span>
<div class="common-amount">
<el-link class="addition-info-num" @click="redirectPage('coverage')">
<el-link class="addition-info-num" @click="redirectPage('coverage')" v-permission-disable="['PROJECT_TRACK_CASE:READ']">
{{ formatAmount(relevanceData.coverageCount) }}
</el-link>
</div>

View File

@ -61,6 +61,7 @@ import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/s
import {getRelateTestCaseReview} from "@/api/test-review";
import HomePagination from "@/business/home/components/pagination/HomePagination";
import BasicStatusLabel from "metersphere-frontend/src/components/BasicStatusLabel";
import {hasPermission} from "@/business/utils/sdk-utils";
export default {
name: "ReviewList",
@ -104,6 +105,9 @@ export default {
});
},
intoPlan(row) {
if (!hasPermission('PROJECT_TRACK_REVIEW:READ')) {
return;
}
let home = this.$router.resolve('/track/review/view/' + row.id);
if (home) {
window.open(home.href, '_blank');

View File

@ -85,6 +85,7 @@ import {getTrackRunningTask} from "@/api/track";
import {updatePlanSchedule} from "@/api/remote/plan/test-plan";
import HomePagination from "@/business/home/components/pagination/HomePagination";
import BasicTaskTypeLabel from "metersphere-frontend/src/components/BasicTaskTypeLabel";
import {hasPermission} from "@/business/utils/sdk-utils";
export default {
name: "MsRunningTaskList",
@ -168,10 +169,19 @@ export default {
},
redirect(param) {
if (param.taskGroup === 'TEST_PLAN_TEST') {
if (!hasPermission('PROJECT_TRACK_PLAN:READ')) {
return;
}
this.$emit('redirectPage', 'testPlanEdit', '', param.scenarioId);
} else if (param.taskGroup === 'API_SCENARIO_TEST') {
if (!hasPermission('PROJECT_API_SCENARIO:READ')) {
return;
}
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param.scenarioId);
} else if (param.taskGroup === 'SWAGGER_IMPORT') {
if (!hasPermission('PROJECT_API_DEFINITION:READ')) {
return;
}
this.$emit('redirectPage', 'api', 'api', {param});
}
}

View File

@ -62,6 +62,7 @@ import StatusTableItem from "../../common/tableItems/planview/StatusTableItem";
import TypeTableItem from "../../common/tableItems/planview/TypeTableItem";
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {hasPermission} from "metersphere-frontend/src/utils/permission";
export default {
name: "TestCaseSideList",
@ -90,7 +91,10 @@ export default {
});
},
editTestCase(row, event, column) {
this.$router.push('/track/plan/view/edit/' + row.id)
if (!hasPermission('PROJECT_TRACK_PLAN:READ')) {
return;
}
this.$router.push('/track/plan/view/edit/' + row.id);
}
}
}

View File

@ -49,6 +49,7 @@
import MsChart from "metersphere-frontend/src/components/chart/MsChart";
import {getUUID} from "metersphere-frontend/src/utils";
import {formatNumber} from "@/api/track";
import {hasPermission} from "@/business/utils/sdk-utils";
export default {
name: "CaseCountChart",
@ -152,7 +153,7 @@ export default {
},
}
},
sublink: "/#/track/case/all/" + getUUID() + "/case/thisWeekCount",
sublink: hasPermission('PROJECT_TRACK_CASE:READ') ? "/#/track/case/all/" + getUUID() + "/case/thisWeekCount" : '',
subtextStyle: {
color: "#1F2329",
fontSize: 12,

View File

@ -42,6 +42,7 @@
import MsChart from "metersphere-frontend/src/components/chart/MsChart";
import {getUUID} from "metersphere-frontend/src/utils";
import {formatNumber} from "@/api/track";
import {hasPermission} from "@/business/utils/sdk-utils";
export default {
name: "RelevanceCountChart",
@ -141,7 +142,7 @@ export default {
},
}
},
sublink: "/#/track/case/all/" + getUUID() + "/case/thisWeekRelevanceCount",
sublink: hasPermission('PROJECT_TRACK_CASE:READ') ? "/#/track/case/all/" + getUUID() + "/case/thisWeekRelevanceCount" : "",
subtextStyle: {
color: "#1F2329",
fontSize: 12,