mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
chore: project permission
This commit is contained in:
@@ -3,21 +3,25 @@
|
||||
<template #overlay>
|
||||
<a-menu @click="handleMenuClick">
|
||||
<a-menu-item v-for="item in projectStore.myProjects" :key="item.id">
|
||||
{{ item.name }}
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<span class="mr-1">{{ item.name }}</span>
|
||||
<fs-values-format :model-value="item.permission" :dict="projectPermissionDict"></fs-values-format>
|
||||
</div>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<div class="rounded pl-3 pr-3 px-2 py-1 flex-center flex pointer items-center bg-accent h-10 button-text" title="当前项目">
|
||||
<fs-icon icon="ion:apps" class="mr-1"></fs-icon>
|
||||
<!-- <fs-icon icon="ion:apps" class="mr-1"></fs-icon> -->
|
||||
<fs-icon :icon="currentIcon" class="mr-5"></fs-icon>
|
||||
当前项目:{{ projectStore.currentProject?.name || "..." }}
|
||||
<fs-icon icon="ion:chevron-down-outline" class="ml-1"></fs-icon>
|
||||
</div>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted } from "vue";
|
||||
import { computed, onMounted } from "vue";
|
||||
import { useProjectStore } from "/@/store/project";
|
||||
import { useDicts } from "/@/views/certd/dicts";
|
||||
defineOptions({
|
||||
name: "ProjectSelector",
|
||||
});
|
||||
@@ -25,12 +29,18 @@ defineOptions({
|
||||
const projectStore = useProjectStore();
|
||||
onMounted(async () => {
|
||||
await projectStore.reload();
|
||||
console.log(projectStore.myProjects);
|
||||
});
|
||||
|
||||
function handleMenuClick({ key }: any) {
|
||||
projectStore.changeCurrentProject(key);
|
||||
window.location.reload();
|
||||
}
|
||||
const { projectPermissionDict } = useDicts();
|
||||
|
||||
const currentIcon = computed(() => {
|
||||
return projectPermissionDict.dataMap[projectStore.currentProject?.permission || ""]?.icon || "";
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
.project-selector {
|
||||
|
||||
@@ -8,6 +8,7 @@ export type UseCrudPermissionExtraProps = {
|
||||
export type UseCrudPermissionExtra = (props: UseCrudPermissionExtraProps) => any;
|
||||
export type UseCrudPermissionCompProps = {
|
||||
isProjectPermission?: boolean;
|
||||
projectPermission?: string;
|
||||
prefix?: string;
|
||||
extra?: UseCrudPermissionExtra;
|
||||
[key: string]: any;
|
||||
@@ -69,17 +70,17 @@ export function useCrudPermission({ permission }: UseCrudPermissionProps) {
|
||||
|
||||
let addPermission = "add";
|
||||
if (isProjectPermission) {
|
||||
addPermission = "write";
|
||||
addPermission = per.projectPermission || "write";
|
||||
}
|
||||
|
||||
let editPermission = "edit";
|
||||
if (isProjectPermission) {
|
||||
editPermission = "write";
|
||||
editPermission = per.projectPermission || "write";
|
||||
}
|
||||
|
||||
let removePermission = "remove";
|
||||
if (isProjectPermission) {
|
||||
removePermission = "write";
|
||||
removePermission = per.projectPermission || "write";
|
||||
}
|
||||
return LodashMerge(
|
||||
{
|
||||
|
||||
@@ -241,6 +241,10 @@ export const certdResources = [
|
||||
icon: "mi:user-check",
|
||||
auth: true,
|
||||
isMenu: true,
|
||||
show: () => {
|
||||
const projectStore = useProjectStore();
|
||||
return !projectStore.isEnterprise;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,7 +22,10 @@ export default defineComponent({
|
||||
setup() {
|
||||
const api = createAddonApi({ from: "user", addonType: "" });
|
||||
addonProvide(api);
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({
|
||||
createCrudOptions,
|
||||
context: { api, permission: { isProjectPermission: true } },
|
||||
});
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -18,7 +18,12 @@ import createCrudOptions from "./crud";
|
||||
export default defineComponent({
|
||||
name: "BasicGroupManager",
|
||||
setup() {
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({
|
||||
createCrudOptions,
|
||||
context: {
|
||||
permission: { isProjectPermission: true },
|
||||
},
|
||||
});
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useSettingStore } from "/@/store/settings";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import CnameTip from "/@/components/plugins/cert/domains-verify-plan-editor/cname-tip.vue";
|
||||
import { useCnameImport } from "./use";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const crudBinding = crudExpose.crudBinding;
|
||||
const router = useRouter();
|
||||
@@ -45,6 +46,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
{ label: t("certd.validation_timed_out"), value: "timeout", color: "red" },
|
||||
],
|
||||
});
|
||||
|
||||
const { hasActionPermission } = useCrudPermission(context);
|
||||
return {
|
||||
crudOptions: {
|
||||
settings: {
|
||||
@@ -75,6 +78,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
icon: "ion:add-circle-outline",
|
||||
},
|
||||
import: {
|
||||
show: hasActionPermission("write"),
|
||||
title: "导入CNAME记录",
|
||||
type: "primary",
|
||||
text: "批量导入",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</template>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #pagination-left>
|
||||
<a-tooltip :title="t('certd.batch_delete')">
|
||||
<a-tooltip v-if="hasActionPermission('write')" :title="t('certd.batch_delete')">
|
||||
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
@@ -27,13 +27,20 @@ import createCrudOptions from "./crud";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import { DeleteBatch } from "./api";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "CnameRecord",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
|
||||
|
||||
const context: any = {
|
||||
permission: { isProjectPermission: true },
|
||||
};
|
||||
|
||||
const { hasActionPermission } = useCrudPermission(context);
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
const selectedRowKeys = context.selectedRowKeys;
|
||||
const handleBatchDelete = () => {
|
||||
|
||||
@@ -4,16 +4,22 @@ import { GetMyProjectList } from "./project/api";
|
||||
const projectPermissionDict = dict({
|
||||
data: [
|
||||
{
|
||||
label: "read",
|
||||
value: "只读",
|
||||
value: "read",
|
||||
label: "只读",
|
||||
color: "cyan",
|
||||
icon: "material-symbols:folder-eye-outline-sharp",
|
||||
},
|
||||
{
|
||||
label: "write",
|
||||
value: "读写",
|
||||
value: "write",
|
||||
label: "读写",
|
||||
color: "green",
|
||||
icon: "material-symbols:edit-square-outline-rounded",
|
||||
},
|
||||
{
|
||||
label: "admin",
|
||||
value: "管理员",
|
||||
value: "admin",
|
||||
label: "管理员",
|
||||
color: "orange",
|
||||
icon: "material-symbols:manage-accounts-rounded",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</template>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #pagination-left>
|
||||
<a-tooltip :title="t('certd.batchDelete')">
|
||||
<a-tooltip v-if="hasActionPermission('write')" :title="t('certd.batchDelete')">
|
||||
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
@@ -20,13 +20,20 @@ import createCrudOptions from "./crud";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import { DeleteBatch } from "./api";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "PipelineHistory",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
|
||||
|
||||
const context: any = {
|
||||
permission: { isProjectPermission: true },
|
||||
};
|
||||
|
||||
const { hasActionPermission } = useCrudPermission(context);
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
const selectedRowKeys = context.selectedRowKeys;
|
||||
const handleBatchDelete = () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ const { t } = useI18n();
|
||||
defineOptions({
|
||||
name: "CertStore",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { permission: { isProjectPermission: true } } });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<div class="helper">{{ t("monitor.setting.cronTrigger") }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<loading-button type="primary" html-type="button" :click="doSave">{{ t("certd.save") }}</loading-button>
|
||||
<loading-button type="primary" html-type="button" :click="doSave" :disabled="!hasActionPermission('write')">{{ t("certd.save") }}</loading-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
@@ -55,6 +55,7 @@ import { utils } from "/@/utils";
|
||||
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useSettingStore } from "/src/store/settings";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -73,6 +74,8 @@ async function loadUserSettings() {
|
||||
merge(formState, data);
|
||||
}
|
||||
|
||||
const { hasActionPermission } = useCrudPermission({ permission: { isProjectPermission: true } });
|
||||
|
||||
loadUserSettings();
|
||||
const doSave = async (form: any) => {
|
||||
await utils.sleep(300);
|
||||
|
||||
@@ -22,7 +22,7 @@ export default defineComponent({
|
||||
setup() {
|
||||
const api = createNotificationApi();
|
||||
notificationProvide(api);
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api, permission: { isProjectPermission: true } } });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -19,7 +19,7 @@ import { OPEN_API_DOC } from "/@/views/certd/open/openkey/api";
|
||||
defineOptions({
|
||||
name: "OpenKey",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { permission: { isProjectPermission: true } } });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -124,11 +124,11 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
|
||||
click() {
|
||||
openCertApplyDialog({ key: "CertApply" });
|
||||
},
|
||||
show: hasActionPermission("add"),
|
||||
show: hasActionPermission("write"),
|
||||
},
|
||||
uploadCert: {
|
||||
order: 2,
|
||||
show: hasActionPermission("uploadCert"),
|
||||
show: hasActionPermission("write"),
|
||||
text: t("certd.commercialCertHosting"),
|
||||
type: "primary",
|
||||
tooltip: {
|
||||
|
||||
@@ -14,12 +14,16 @@
|
||||
import { defineComponent, onActivated, onMounted } from "vue";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
import { createApi } from "./api";
|
||||
|
||||
export default defineComponent({
|
||||
name: "PipelineGroupManager",
|
||||
setup() {
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({
|
||||
createCrudOptions,
|
||||
context: {
|
||||
permission: { isProjectPermission: true },
|
||||
},
|
||||
});
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
<div v-if="selectedRowKeys.length > 0" class="batch-actions">
|
||||
<div class="batch-actions-inner">
|
||||
<span>{{ t("certd.selectedCount", { count: selectedRowKeys.length }) }}</span>
|
||||
<fs-button icon="ion:trash-outline" class="color-red" type="link" :text="t('certd.batchDelete')" @click="batchDelete"></fs-button>
|
||||
<fs-button v-if="hasActionPermission('write')" icon="ion:trash-outline" class="color-red" type="link" :text="t('certd.batchDelete')" @click="batchDelete"></fs-button>
|
||||
<batch-rerun :selected-row-keys="selectedRowKeys" @change="batchFinished"></batch-rerun>
|
||||
<change-group :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-group>
|
||||
<change-notification :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-notification>
|
||||
<change-trigger :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-trigger>
|
||||
<change-group v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-group>
|
||||
<change-notification v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-notification>
|
||||
<change-trigger v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-trigger>
|
||||
</div>
|
||||
</div>
|
||||
<template #form-bottom>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</template>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #pagination-left>
|
||||
<a-tooltip :title="t('certd.batchDelete')">
|
||||
<a-tooltip v-if="hasActionPermission('write')" :title="t('certd.batchDelete')">
|
||||
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
@@ -32,13 +32,21 @@ import createCrudOptions from "./crud";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import { DeleteBatch } from "./api";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "CnameRecord",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
|
||||
const context: any = {
|
||||
permission: {
|
||||
isProjectPermission: true,
|
||||
},
|
||||
};
|
||||
const { hasActionPermission } = useCrudPermission({ permission: context.permission });
|
||||
context.hasActionPermission = hasActionPermission;
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
const selectedRowKeys = context.selectedRowKeys;
|
||||
const handleBatchDelete = () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as api from "./api";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { userDict } from "../../dicts";
|
||||
import { useDicts } from "../../dicts";
|
||||
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const router = useRouter();
|
||||
@@ -35,6 +35,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
const selectedRowKeys: Ref<any[]> = ref([]);
|
||||
context.selectedRowKeys = selectedRowKeys;
|
||||
|
||||
const { userDict } = useDicts();
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
settings: {
|
||||
|
||||
@@ -30,7 +30,8 @@ const { t } = useI18n();
|
||||
defineOptions({
|
||||
name: "MyProjectManager",
|
||||
});
|
||||
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
|
||||
const context: any = { permission: { isProjectPermission: true, projectPermission: "admin" } };
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
const selectedRowKeys = context.selectedRowKeys;
|
||||
const handleBatchDelete = () => {
|
||||
|
||||
Reference in New Issue
Block a user