@rzyuan/hrbac-share 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dist/components/HrbacShareDrawer.vue.d.ts +60 -0
- package/dist/components/HrbacShareDrawer.vue.d.ts.map +1 -0
- package/dist/composables/useHrbacShare.d.ts +55 -0
- package/dist/composables/useHrbacShare.d.ts.map +1 -0
- package/dist/core/share-state.d.ts +6 -0
- package/dist/core/share-state.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +608 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @rzyuan/hrbac-share
|
|
2
|
+
|
|
3
|
+
Vue 3 + Element Plus HRBAC 分享抽屉。组件只负责通用分享交互,权限数据读写由业务应用通过 adapter 接入。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rzyuan/hrbac-share
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 发布
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm run build
|
|
15
|
+
npm publish --access public
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
发布到公网 npm 前,请确认包内没有内部域名、接口路径、真实人员、空间或权限码。
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
```vue
|
|
23
|
+
<template>
|
|
24
|
+
<HrbacShareDrawer
|
|
25
|
+
v-model="visible"
|
|
26
|
+
:resource="{ id: repository.id, name: repository.name }"
|
|
27
|
+
:adapter="adapter"
|
|
28
|
+
:readonly="!canManageShare"
|
|
29
|
+
@saved="reload"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref } from 'vue'
|
|
35
|
+
import {
|
|
36
|
+
HrbacShareDrawer,
|
|
37
|
+
type HrbacShareAdapter
|
|
38
|
+
} from '@rzyuan/hrbac-share'
|
|
39
|
+
|
|
40
|
+
const visible = ref(false)
|
|
41
|
+
|
|
42
|
+
const adapter: HrbacShareAdapter = {
|
|
43
|
+
listPermissions(resourceId) {
|
|
44
|
+
return api.listPermissions(resourceId)
|
|
45
|
+
},
|
|
46
|
+
searchSubjects(query) {
|
|
47
|
+
return api.searchShareSubjects(query)
|
|
48
|
+
},
|
|
49
|
+
grantPermission(payload) {
|
|
50
|
+
return api.grantPermission(payload)
|
|
51
|
+
},
|
|
52
|
+
updatePermissionRole(payload) {
|
|
53
|
+
return api.updatePermissionRole(payload)
|
|
54
|
+
},
|
|
55
|
+
revokePermission(payload) {
|
|
56
|
+
return api.revokePermission(payload)
|
|
57
|
+
},
|
|
58
|
+
transferOwner(payload) {
|
|
59
|
+
return api.transferOwner(payload)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Adapter 协议
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
interface HrbacShareAdapter {
|
|
69
|
+
listPermissions(resourceId: string): Promise<HrbacSharePermission[]>
|
|
70
|
+
searchSubjects(query: HrbacShareSubjectQuery): Promise<HrbacShareSubjectOption[]>
|
|
71
|
+
grantPermission(payload: HrbacShareGrantPayload): Promise<void>
|
|
72
|
+
updatePermissionRole(payload: HrbacShareUpdateRolePayload): Promise<void>
|
|
73
|
+
revokePermission(payload: HrbacShareRevokePayload): Promise<void>
|
|
74
|
+
transferOwner?(payload: HrbacShareTransferOwnerPayload): Promise<void>
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 设计边界
|
|
79
|
+
|
|
80
|
+
- 不包含业务 request、router、Pinia、资源 API。
|
|
81
|
+
- 不包含主应用或子应用的内部权限码。
|
|
82
|
+
- `vue`、`element-plus` 是 peer dependency,由使用方应用提供。
|
|
83
|
+
- 业务应用负责后端 HRBAC 表、角色规则和接口校验。
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { HrbacShareAdapter, HrbacShareLabels, HrbacShareResource, HrbacShareRoleOption, HrbacShareSubjectTypeOption } from '../types';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
modelValue: boolean;
|
|
5
|
+
resource: HrbacShareResource;
|
|
6
|
+
adapter: HrbacShareAdapter;
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
drawerSize?: string | number;
|
|
9
|
+
labels?: HrbacShareLabels;
|
|
10
|
+
subjectTypeOptions?: HrbacShareSubjectTypeOption[];
|
|
11
|
+
roleOptions?: HrbacShareRoleOption[];
|
|
12
|
+
allowTransferOwner?: boolean;
|
|
13
|
+
}>, {
|
|
14
|
+
readonly: boolean;
|
|
15
|
+
drawerSize: number;
|
|
16
|
+
allowTransferOwner: boolean;
|
|
17
|
+
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
18
|
+
"update:modelValue": (value: boolean) => void;
|
|
19
|
+
saved: () => void;
|
|
20
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
21
|
+
modelValue: boolean;
|
|
22
|
+
resource: HrbacShareResource;
|
|
23
|
+
adapter: HrbacShareAdapter;
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
drawerSize?: string | number;
|
|
26
|
+
labels?: HrbacShareLabels;
|
|
27
|
+
subjectTypeOptions?: HrbacShareSubjectTypeOption[];
|
|
28
|
+
roleOptions?: HrbacShareRoleOption[];
|
|
29
|
+
allowTransferOwner?: boolean;
|
|
30
|
+
}>, {
|
|
31
|
+
readonly: boolean;
|
|
32
|
+
drawerSize: number;
|
|
33
|
+
allowTransferOwner: boolean;
|
|
34
|
+
}>>> & Readonly<{
|
|
35
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
36
|
+
onSaved?: (() => any) | undefined;
|
|
37
|
+
}>, {
|
|
38
|
+
readonly: boolean;
|
|
39
|
+
drawerSize: string | number;
|
|
40
|
+
allowTransferOwner: boolean;
|
|
41
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
42
|
+
export default _default;
|
|
43
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
44
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
45
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
46
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
47
|
+
} : {
|
|
48
|
+
type: import('vue').PropType<T[K]>;
|
|
49
|
+
required: true;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type __VLS_WithDefaults<P, D> = {
|
|
53
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
54
|
+
default: D[K];
|
|
55
|
+
}> : P[K];
|
|
56
|
+
};
|
|
57
|
+
type __VLS_Prettify<T> = {
|
|
58
|
+
[K in keyof T]: T[K];
|
|
59
|
+
} & {};
|
|
60
|
+
//# sourceMappingURL=HrbacShareDrawer.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HrbacShareDrawer.vue.d.ts","sourceRoot":"","sources":["../../src/components/HrbacShareDrawer.vue"],"names":[],"mappings":"AAqNA;AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAEhB,kBAAkB,EAElB,oBAAoB,EAGpB,2BAA2B,EAC5B,MAAM,UAAU,CAAA;;gBA6kCH,OAAO;cACT,kBAAkB;aACnB,iBAAiB;eACf,OAAO;iBACL,MAAM,GAAG,MAAM;aACnB,gBAAgB;yBACJ,2BAA2B,EAAE;kBACpC,oBAAoB,EAAE;yBACf,OAAO;;;;;;;;;gBARhB,OAAO;cACT,kBAAkB;aACnB,iBAAiB;eACf,OAAO;iBACL,MAAM,GAAG,MAAM;aACnB,gBAAgB;yBACJ,2BAA2B,EAAE;kBACpC,oBAAoB,EAAE;yBACf,OAAO;;;;;;;;;cALjB,OAAO;gBACL,MAAM,GAAG,MAAM;wBAIP,OAAO;;AAd9B,wBAiBG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HrbacShareAdapter, HrbacSharePermission, HrbacShareRole, HrbacShareSubjectOption, HrbacShareSubjectType } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface UseHrbacShareOptions {
|
|
4
|
+
adapter: HrbacShareAdapter;
|
|
5
|
+
resourceId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useHrbacShare(options: UseHrbacShareOptions): {
|
|
8
|
+
loading: import('vue').Ref<boolean, boolean>;
|
|
9
|
+
saving: import('vue').Ref<boolean, boolean>;
|
|
10
|
+
keyword: import('vue').Ref<string, string>;
|
|
11
|
+
subjectType: import('vue').Ref<HrbacShareSubjectType, HrbacShareSubjectType>;
|
|
12
|
+
selectedSubjectIds: import('vue').Ref<string[], string[]>;
|
|
13
|
+
selectedRole: import('vue').Ref<"MANAGER" | "EDITOR" | "VIEWER", "MANAGER" | "EDITOR" | "VIEWER">;
|
|
14
|
+
permissions: import('vue').Ref<{
|
|
15
|
+
role: HrbacShareRole;
|
|
16
|
+
readonly?: boolean | undefined;
|
|
17
|
+
inherited?: boolean | undefined;
|
|
18
|
+
subjectName: string;
|
|
19
|
+
description?: string | undefined;
|
|
20
|
+
disabled?: boolean | undefined;
|
|
21
|
+
subjectType: HrbacShareSubjectType;
|
|
22
|
+
subjectId: string;
|
|
23
|
+
}[], HrbacSharePermission[] | {
|
|
24
|
+
role: HrbacShareRole;
|
|
25
|
+
readonly?: boolean | undefined;
|
|
26
|
+
inherited?: boolean | undefined;
|
|
27
|
+
subjectName: string;
|
|
28
|
+
description?: string | undefined;
|
|
29
|
+
disabled?: boolean | undefined;
|
|
30
|
+
subjectType: HrbacShareSubjectType;
|
|
31
|
+
subjectId: string;
|
|
32
|
+
}[]>;
|
|
33
|
+
candidates: import('vue').Ref<{
|
|
34
|
+
subjectName: string;
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
disabled?: boolean | undefined;
|
|
37
|
+
subjectType: HrbacShareSubjectType;
|
|
38
|
+
subjectId: string;
|
|
39
|
+
}[], HrbacShareSubjectOption[] | {
|
|
40
|
+
subjectName: string;
|
|
41
|
+
description?: string | undefined;
|
|
42
|
+
disabled?: boolean | undefined;
|
|
43
|
+
subjectType: HrbacShareSubjectType;
|
|
44
|
+
subjectId: string;
|
|
45
|
+
}[]>;
|
|
46
|
+
sortedPermissions: import('vue').ComputedRef<HrbacSharePermission[]>;
|
|
47
|
+
availableCandidates: import('vue').ComputedRef<HrbacShareSubjectOption[]>;
|
|
48
|
+
loadPermissions: () => Promise<void>;
|
|
49
|
+
searchCandidates: () => Promise<void>;
|
|
50
|
+
grantSelected: () => Promise<void>;
|
|
51
|
+
updateRole: (permission: HrbacSharePermission, role: Exclude<HrbacShareRole, "OWNER">) => Promise<void>;
|
|
52
|
+
revoke: (permission: HrbacSharePermission) => Promise<void>;
|
|
53
|
+
transferOwner: (permission: HrbacSharePermission, previousOwnerRole?: Exclude<HrbacShareRole, "OWNER">) => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=useHrbacShare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHrbacShare.d.ts","sourceRoot":"","sources":["../../src/composables/useHrbacShare.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAiDnB,oBAAoB,QAAQ,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;yBAehE,oBAAoB;gCAgBxC,oBAAoB,sBACb,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;EAmCtD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HrbacSharePermission, HrbacShareSubjectOption, HrbacShareSubjectRef } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare function buildSubjectKey(subject: HrbacShareSubjectRef): string;
|
|
4
|
+
export declare function excludeExistingSubjects(candidates: HrbacShareSubjectOption[], permissions: HrbacSharePermission[]): HrbacShareSubjectOption[];
|
|
5
|
+
export declare function sortSharePermissions(permissions: HrbacSharePermission[]): HrbacSharePermission[];
|
|
6
|
+
//# sourceMappingURL=share-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-state.d.ts","sourceRoot":"","sources":["../../src/core/share-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,uBAAuB,EACvB,oBAAoB,EAErB,MAAM,UAAU,CAAA;AAQjB,wBAAgB,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAErE;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,uBAAuB,EAAE,EACrC,WAAW,EAAE,oBAAoB,EAAE,GAClC,uBAAuB,EAAE,CAG3B;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CAUhG"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),b=require("element-plus"),z=require("@element-plus/icons-vue"),F={USER:1,LINE:2,SPACE:3};function D(o){return`${o.subjectType}:${o.subjectId}`}function P(o,u){const r=new Set(u.map(D));return o.filter(c=>!r.has(D(c)))}function L(o){return[...o].sort((u,r)=>{if(u.role==="OWNER"&&r.role!=="OWNER")return-1;if(u.role!=="OWNER"&&r.role==="OWNER")return 1;const c=F[u.subjectType]-F[r.subjectType];return c!==0?c:u.subjectName.localeCompare(r.subjectName,"zh-CN")})}const fe={class:"hrbac-share-drawer__header"},me={class:"hrbac-share-drawer__title"},_e={class:"hrbac-share-drawer__subtitle"},ye={class:"hrbac-share-drawer__body"},he={class:"hrbac-share-drawer__section"},we={class:"hrbac-share-drawer__section-head"},ge={class:"hrbac-share-drawer__section-title"},Ee={class:"hrbac-share-drawer__add-row"},Ve={class:"hrbac-share-drawer__candidate-option"},Ne={key:0,class:"hrbac-share-drawer__candidate-desc"},ke={class:"hrbac-share-drawer__section hrbac-share-drawer__section--list"},Ce={class:"hrbac-share-drawer__section-head"},je={class:"hrbac-share-drawer__section-title"},Te={key:0,class:"hrbac-share-drawer__list"},Se={class:"hrbac-share-drawer__row-main"},Be={class:"hrbac-share-drawer__row-name"},Re={key:0,class:"hrbac-share-drawer__row-desc"},Ie={class:"hrbac-share-drawer__dialog-text"},xe={key:0,class:"hrbac-share-drawer__dialog-target"},Oe={class:"hrbac-share-drawer__dialog-text"},De={key:0,class:"hrbac-share-drawer__dialog-target"},Pe="__remove__",Le="__transfer__",Me=e.defineComponent({__name:"HrbacShareDrawer",props:{modelValue:{type:Boolean},resource:{},adapter:{},readonly:{type:Boolean,default:!1},drawerSize:{default:560},labels:{},subjectTypeOptions:{},roleOptions:{},allowTransferOwner:{type:Boolean,default:!0}},emits:["update:modelValue","saved"],setup(o,{emit:u}){const r=o,c=u,_={title:"分享设置",addSectionTitle:"添加协作者",collaboratorTitle:"协作者",readonlyTip:"当前仅可查看协作者,暂无修改分享设置权限",emptyCollaborators:"暂无协作者",removeTitle:"确认移除协作者?",removeDescription:"移除后,该对象将无法继续访问资源:",transferTitle:"转移所有权",transferDescription:"转移后,新的所有者为:"},w=[{label:"按用户",value:"USER"},{label:"按条线",value:"LINE"},{label:"按空间",value:"SPACE"}],B=[{label:"可管理",value:"MANAGER"},{label:"可编辑",value:"EDITOR"},{label:"可查看",value:"VIEWER"}],m=e.ref(!1),s=e.ref(!1),C=e.ref(!1),v=e.ref("USER"),i=e.ref([]),y=e.ref("VIEWER"),j=e.ref([]),R=e.ref([]),T=e.ref(""),h=e.ref(!1),d=e.ref(!1),n=e.ref(null),x=e.ref("MANAGER"),f=e.computed(()=>({..._,...r.labels})),O=e.computed(()=>{var a;return(a=r.subjectTypeOptions)!=null&&a.length?r.subjectTypeOptions:w}),M=e.computed(()=>{var a;return(a=r.roleOptions)!=null&&a.length?r.roleOptions:B}),U=e.computed(()=>M.value.filter(a=>a.value!=="OWNER")),W=e.computed(()=>L(j.value)),H=e.computed(()=>P(R.value,j.value)),G=e.computed(()=>v.value==="USER"?"搜索用户":v.value==="LINE"?"搜索条线":"搜索空间"),A=e.computed(()=>{const a=T.value.trim().toLowerCase();return a?W.value.filter(t=>{var p;return t.subjectName.toLowerCase().includes(a)||t.subjectId.toLowerCase().includes(a)||((p=t.description)==null?void 0:p.toLowerCase().includes(a))}):W.value});e.watch(()=>r.modelValue,a=>{a&&(g(),E(""))}),e.watch(O,a=>{var t;a.some(p=>p.value===v.value)||(v.value=((t=a[0])==null?void 0:t.value)||"USER")},{immediate:!0});function K(a){c("update:modelValue",a)}function q(){g(),E("")}async function g(){m.value=!0;try{j.value=await r.adapter.listPermissions(r.resource.id)}catch(a){b.ElMessage.error(V(a,"协作者加载失败"))}finally{m.value=!1}}async function E(a){C.value=!0;try{R.value=await r.adapter.searchSubjects({subjectType:v.value,keyword:a,resourceId:r.resource.id})}catch(t){b.ElMessage.error(V(t,"候选对象加载失败"))}finally{C.value=!1}}function J(){i.value=[],E("")}async function Y(){if(i.value.length){s.value=!0;try{await Promise.all(i.value.map(a=>r.adapter.grantPermission({resourceId:r.resource.id,subjectType:v.value,subjectId:a,role:y.value}))),i.value=[],b.ElMessage.success("协作者已添加"),c("saved"),await g(),await E("")}catch(a){b.ElMessage.error(V(a,"协作者添加失败"))}finally{s.value=!1}}}async function Q(a,t){if(t===Pe){n.value=a,h.value=!0;return}if(t===Le){n.value=a,d.value=!0;return}if(!(t==="OWNER"||t===a.role)){s.value=!0;try{await r.adapter.updatePermissionRole({resourceId:r.resource.id,subjectType:a.subjectType,subjectId:a.subjectId,role:t}),b.ElMessage.success("权限已更新"),c("saved"),await g()}catch(p){b.ElMessage.error(V(p,"权限更新失败"))}finally{s.value=!1}}}function X(a,t){typeof t=="string"&&Q(a,t)}async function Z(){if(n.value){s.value=!0;try{await r.adapter.revokePermission({resourceId:r.resource.id,subjectType:n.value.subjectType,subjectId:n.value.subjectId}),h.value=!1,n.value=null,b.ElMessage.success("协作者已移除"),c("saved"),await g(),await E("")}catch(a){b.ElMessage.error(V(a,"协作者移除失败"))}finally{s.value=!1}}}async function ee(){if(!(!n.value||!r.adapter.transferOwner)){s.value=!0;try{await r.adapter.transferOwner({resourceId:r.resource.id,subjectType:n.value.subjectType,subjectId:n.value.subjectId,previousOwnerRole:x.value}),d.value=!1,n.value=null,b.ElMessage.success("所有权已转移"),c("saved"),await g()}catch(a){b.ElMessage.error(V(a,"所有权转移失败"))}finally{s.value=!1}}}function ae(a){var t;return((t=O.value.find(p=>p.value===a))==null?void 0:t.label.replace(/^按/,""))||a}function te(a){return a.role==="OWNER"?[{label:"所有者",value:"OWNER",disabled:!0}]:M.value.filter(t=>t.value!=="OWNER")}function le(a){return r.readonly||s.value||a.readonly===!0||a.role==="OWNER"}function re(a){return!r.readonly&&!a.readonly&&a.role!=="OWNER"}function oe(a){return r.allowTransferOwner&&!!r.adapter.transferOwner&&!r.readonly&&!a.readonly&&a.subjectType==="USER"&&a.role!=="OWNER"}function V(a,t){return a instanceof Error&&a.message?a.message:t}return(a,t)=>{const p=e.resolveComponent("el-alert"),se=e.resolveComponent("el-radio-button"),ne=e.resolveComponent("el-radio-group"),N=e.resolveComponent("el-option"),I=e.resolveComponent("el-select"),S=e.resolveComponent("el-button"),ce=e.resolveComponent("el-input"),de=e.resolveComponent("el-tag"),ue=e.resolveComponent("el-empty"),$=e.resolveComponent("el-dialog"),ie=e.resolveComponent("el-form-item"),ve=e.resolveComponent("el-form"),pe=e.resolveComponent("el-drawer"),be=e.resolveDirective("loading");return e.openBlock(),e.createBlock(pe,{"model-value":o.modelValue,size:o.drawerSize,"close-on-click-modal":!1,class:"hrbac-share-drawer","onUpdate:modelValue":K,onOpen:q},{header:e.withCtx(()=>[e.createElementVNode("div",fe,[e.createElementVNode("div",null,[e.createElementVNode("div",me,e.toDisplayString(f.value.title),1),e.createElementVNode("div",_e,e.toDisplayString(o.resource.name),1)])])]),default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",ye,[o.readonly?(e.openBlock(),e.createBlock(p,{key:0,title:f.value.readonlyTip,type:"info","show-icon":"",closable:!1,class:"hrbac-share-drawer__alert"},null,8,["title"])):e.createCommentVNode("",!0),e.createElementVNode("section",he,[e.createElementVNode("div",we,[e.createElementVNode("span",ge,e.toDisplayString(f.value.addSectionTitle),1),e.createVNode(ne,{modelValue:v.value,"onUpdate:modelValue":t[0]||(t[0]=l=>v.value=l),size:"small",disabled:o.readonly||s.value,onChange:J},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,l=>(e.openBlock(),e.createBlock(se,{key:l.value,label:l.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","disabled"])]),e.createElementVNode("div",Ee,[e.createVNode(I,{modelValue:i.value,"onUpdate:modelValue":t[1]||(t[1]=l=>i.value=l),multiple:"",filterable:"",remote:"","reserve-keyword":"","remote-method":E,loading:C.value,disabled:o.readonly||s.value,placeholder:G.value,class:"hrbac-share-drawer__candidate-select"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,l=>(e.openBlock(),e.createBlock(N,{key:`${l.subjectType}:${l.subjectId}`,label:l.subjectName,value:l.subjectId,disabled:l.disabled},{default:e.withCtx(()=>[e.createElementVNode("div",Ve,[e.createElementVNode("span",null,e.toDisplayString(l.subjectName),1),l.description?(e.openBlock(),e.createElementBlock("span",Ne,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])]),_:2},1032,["label","value","disabled"]))),128))]),_:1},8,["modelValue","loading","disabled","placeholder"]),e.createVNode(I,{modelValue:y.value,"onUpdate:modelValue":t[2]||(t[2]=l=>y.value=l),disabled:o.readonly||s.value,class:"hrbac-share-drawer__role-select"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,l=>(e.openBlock(),e.createBlock(N,{key:l.value,label:l.label,value:l.value,disabled:l.disabled},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue","disabled"]),e.createVNode(S,{type:"primary",icon:e.unref(z.Plus),loading:s.value,disabled:o.readonly||!i.value.length,onClick:Y},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode(" 添加 ",-1)])]),_:1},8,["icon","loading","disabled"])])]),e.createElementVNode("section",ke,[e.createElementVNode("div",Ce,[e.createElementVNode("span",je,e.toDisplayString(f.value.collaboratorTitle),1),e.createVNode(ce,{modelValue:T.value,"onUpdate:modelValue":t[3]||(t[3]=l=>T.value=l),"prefix-icon":e.unref(z.Search),clearable:"",placeholder:"搜索协作者",class:"hrbac-share-drawer__search"},null,8,["modelValue","prefix-icon"])]),A.value.length?(e.openBlock(),e.createElementBlock("div",Te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,l=>(e.openBlock(),e.createElementBlock("div",{key:`${l.subjectType}:${l.subjectId}`,class:"hrbac-share-drawer__row"},[e.createElementVNode("div",Se,[e.createVNode(de,{size:"small",effect:"plain"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(ae(l.subjectType)),1)]),_:2},1024),e.createElementVNode("div",null,[e.createElementVNode("div",Be,e.toDisplayString(l.subjectName),1),l.description?(e.openBlock(),e.createElementBlock("div",Re,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])]),e.createVNode(I,{"model-value":l.role,disabled:le(l),class:"hrbac-share-drawer__row-role",onChange:k=>X(l,k)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(te(l),k=>(e.openBlock(),e.createBlock(N,{key:k.value,label:k.label,value:k.value,disabled:k.disabled},null,8,["label","value","disabled"]))),128)),oe(l)?(e.openBlock(),e.createBlock(N,{key:0,label:"转移所有权",value:"__transfer__"})):e.createCommentVNode("",!0),re(l)?(e.openBlock(),e.createBlock(N,{key:1,label:"移除",value:"__remove__"})):e.createCommentVNode("",!0)]),_:2},1032,["model-value","disabled","onChange"])]))),128))])):(e.openBlock(),e.createBlock(ue,{key:1,description:f.value.emptyCollaborators,class:"hrbac-share-drawer__empty"},null,8,["description"]))])])),[[be,m.value]]),e.createVNode($,{modelValue:h.value,"onUpdate:modelValue":t[5]||(t[5]=l=>h.value=l),title:f.value.removeTitle,width:"420px","append-to-body":""},{footer:e.withCtx(()=>[e.createVNode(S,{onClick:t[4]||(t[4]=l=>h.value=!1)},{default:e.withCtx(()=>[...t[10]||(t[10]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(S,{type:"danger",loading:s.value,onClick:Z},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("移除",-1)])]),_:1},8,["loading"])]),default:e.withCtx(()=>[e.createElementVNode("p",Ie,[e.createTextVNode(e.toDisplayString(f.value.removeDescription)+" ",1),n.value?(e.openBlock(),e.createElementBlock("span",xe,e.toDisplayString(n.value.subjectName),1)):e.createCommentVNode("",!0)])]),_:1},8,["modelValue","title"]),e.createVNode($,{modelValue:d.value,"onUpdate:modelValue":t[8]||(t[8]=l=>d.value=l),title:f.value.transferTitle,width:"460px","append-to-body":""},{footer:e.withCtx(()=>[e.createVNode(S,{onClick:t[7]||(t[7]=l=>d.value=!1)},{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(S,{type:"primary",loading:s.value,onClick:ee},{default:e.withCtx(()=>[...t[13]||(t[13]=[e.createTextVNode("确认转移",-1)])]),_:1},8,["loading"])]),default:e.withCtx(()=>[e.createElementVNode("p",Oe,[e.createTextVNode(e.toDisplayString(f.value.transferDescription)+" ",1),n.value?(e.openBlock(),e.createElementBlock("span",De,e.toDisplayString(n.value.subjectName),1)):e.createCommentVNode("",!0)]),e.createVNode(ve,{"label-position":"left","label-width":"120px"},{default:e.withCtx(()=>[e.createVNode(ie,{label:"原所有者角色"},{default:e.withCtx(()=>[e.createVNode(I,{modelValue:x.value,"onUpdate:modelValue":t[6]||(t[6]=l=>x.value=l)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,l=>(e.openBlock(),e.createBlock(N,{key:l.value,label:l.label,value:l.value,disabled:l.disabled},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue","title"])]),_:1},8,["model-value","size"])}}}),Ue=(o,u)=>{const r=o.__vccOpts||o;for(const[c,_]of u)r[c]=_;return r},We=Ue(Me,[["__scopeId","data-v-cbf40cd5"]]);function Ae(o){const u=e.ref(!1),r=e.ref(!1),c=e.ref(""),_=e.ref("USER"),w=e.ref([]),B=e.ref("VIEWER"),m=e.ref([]),s=e.ref([]),C=e.computed(()=>L(m.value)),v=e.computed(()=>P(s.value,m.value));async function i(){u.value=!0;try{m.value=await o.adapter.listPermissions(o.resourceId)}finally{u.value=!1}}async function y(){s.value=await o.adapter.searchSubjects({subjectType:_.value,keyword:c.value,resourceId:o.resourceId})}async function j(){if(w.value.length){r.value=!0;try{await Promise.all(w.value.map(d=>o.adapter.grantPermission({resourceId:o.resourceId,subjectType:_.value,subjectId:d,role:B.value}))),w.value=[],c.value="",await i(),await y()}finally{r.value=!1}}}async function R(d,n){r.value=!0;try{await o.adapter.updatePermissionRole({resourceId:o.resourceId,subjectType:d.subjectType,subjectId:d.subjectId,role:n}),await i()}finally{r.value=!1}}async function T(d){r.value=!0;try{await o.adapter.revokePermission({resourceId:o.resourceId,subjectType:d.subjectType,subjectId:d.subjectId}),await i(),await y()}finally{r.value=!1}}async function h(d,n="MANAGER"){if(o.adapter.transferOwner){r.value=!0;try{await o.adapter.transferOwner({resourceId:o.resourceId,subjectType:d.subjectType,subjectId:d.subjectId,previousOwnerRole:n}),await i()}finally{r.value=!1}}}return{loading:u,saving:r,keyword:c,subjectType:_,selectedSubjectIds:w,selectedRole:B,permissions:m,candidates:s,sortedPermissions:C,availableCandidates:v,loadPermissions:i,searchCandidates:y,grantSelected:j,updateRole:R,revoke:T,transferOwner:h}}exports.HrbacShareDrawer=We;exports.buildSubjectKey=D;exports.excludeExistingSubjects=P;exports.sortSharePermissions=L;exports.useHrbacShare=Ae;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as HrbacShareDrawer } from './components/HrbacShareDrawer.vue';
|
|
2
|
+
export { useHrbacShare } from './composables/useHrbacShare';
|
|
3
|
+
export { buildSubjectKey, excludeExistingSubjects, sortSharePermissions } from './core/share-state';
|
|
4
|
+
export type { HrbacShareAdapter, HrbacShareGrantPayload, HrbacShareLabels, HrbacSharePermission, HrbacShareResource, HrbacShareRevokePayload, HrbacShareRole, HrbacShareRoleOption, HrbacShareSubjectOption, HrbacShareSubjectQuery, HrbacShareSubjectRef, HrbacShareSubjectType, HrbacShareSubjectTypeOption, HrbacShareTransferOwnerPayload, HrbacShareUpdateRolePayload } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import { defineComponent as Se, ref as n, computed as T, watch as Z, resolveComponent as y, resolveDirective as Ce, openBlock as s, createBlock as j, withCtx as o, withDirectives as Ne, createElementBlock as h, createCommentVNode as C, createElementVNode as c, toDisplayString as _, createVNode as b, Fragment as D, renderList as A, createTextVNode as E, unref as ee } from "vue";
|
|
2
|
+
import { ElMessage as g } from "element-plus";
|
|
3
|
+
import { Plus as ke, Search as Pe } from "@element-plus/icons-vue";
|
|
4
|
+
const ae = {
|
|
5
|
+
USER: 1,
|
|
6
|
+
LINE: 2,
|
|
7
|
+
SPACE: 3
|
|
8
|
+
};
|
|
9
|
+
function le(t) {
|
|
10
|
+
return `${t.subjectType}:${t.subjectId}`;
|
|
11
|
+
}
|
|
12
|
+
function re(t, f) {
|
|
13
|
+
const r = new Set(f.map(le));
|
|
14
|
+
return t.filter((i) => !r.has(le(i)));
|
|
15
|
+
}
|
|
16
|
+
function te(t) {
|
|
17
|
+
return [...t].sort((f, r) => {
|
|
18
|
+
if (f.role === "OWNER" && r.role !== "OWNER") return -1;
|
|
19
|
+
if (f.role !== "OWNER" && r.role === "OWNER") return 1;
|
|
20
|
+
const i = ae[f.subjectType] - ae[r.subjectType];
|
|
21
|
+
return i !== 0 ? i : f.subjectName.localeCompare(r.subjectName, "zh-CN");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const Ue = { class: "hrbac-share-drawer__header" }, xe = { class: "hrbac-share-drawer__title" }, We = { class: "hrbac-share-drawer__subtitle" }, De = { class: "hrbac-share-drawer__body" }, Ae = { class: "hrbac-share-drawer__section" }, Le = { class: "hrbac-share-drawer__section-head" }, Be = { class: "hrbac-share-drawer__section-title" }, $e = { class: "hrbac-share-drawer__add-row" }, ze = { class: "hrbac-share-drawer__candidate-option" }, Me = {
|
|
25
|
+
key: 0,
|
|
26
|
+
class: "hrbac-share-drawer__candidate-desc"
|
|
27
|
+
}, Ge = { class: "hrbac-share-drawer__section hrbac-share-drawer__section--list" }, He = { class: "hrbac-share-drawer__section-head" }, Ke = { class: "hrbac-share-drawer__section-title" }, Fe = {
|
|
28
|
+
key: 0,
|
|
29
|
+
class: "hrbac-share-drawer__list"
|
|
30
|
+
}, Je = { class: "hrbac-share-drawer__row-main" }, Ye = { class: "hrbac-share-drawer__row-name" }, qe = {
|
|
31
|
+
key: 0,
|
|
32
|
+
class: "hrbac-share-drawer__row-desc"
|
|
33
|
+
}, Qe = { class: "hrbac-share-drawer__dialog-text" }, Xe = {
|
|
34
|
+
key: 0,
|
|
35
|
+
class: "hrbac-share-drawer__dialog-target"
|
|
36
|
+
}, Ze = { class: "hrbac-share-drawer__dialog-text" }, ea = {
|
|
37
|
+
key: 0,
|
|
38
|
+
class: "hrbac-share-drawer__dialog-target"
|
|
39
|
+
}, aa = "__remove__", la = "__transfer__", ra = /* @__PURE__ */ Se({
|
|
40
|
+
__name: "HrbacShareDrawer",
|
|
41
|
+
props: {
|
|
42
|
+
modelValue: { type: Boolean },
|
|
43
|
+
resource: {},
|
|
44
|
+
adapter: {},
|
|
45
|
+
readonly: { type: Boolean, default: !1 },
|
|
46
|
+
drawerSize: { default: 560 },
|
|
47
|
+
labels: {},
|
|
48
|
+
subjectTypeOptions: {},
|
|
49
|
+
roleOptions: {},
|
|
50
|
+
allowTransferOwner: { type: Boolean, default: !0 }
|
|
51
|
+
},
|
|
52
|
+
emits: ["update:modelValue", "saved"],
|
|
53
|
+
setup(t, { emit: f }) {
|
|
54
|
+
const r = t, i = f, O = {
|
|
55
|
+
title: "分享设置",
|
|
56
|
+
addSectionTitle: "添加协作者",
|
|
57
|
+
collaboratorTitle: "协作者",
|
|
58
|
+
readonlyTip: "当前仅可查看协作者,暂无修改分享设置权限",
|
|
59
|
+
emptyCollaborators: "暂无协作者",
|
|
60
|
+
removeTitle: "确认移除协作者?",
|
|
61
|
+
removeDescription: "移除后,该对象将无法继续访问资源:",
|
|
62
|
+
transferTitle: "转移所有权",
|
|
63
|
+
transferDescription: "转移后,新的所有者为:"
|
|
64
|
+
}, N = [
|
|
65
|
+
{ label: "按用户", value: "USER" },
|
|
66
|
+
{ label: "按条线", value: "LINE" },
|
|
67
|
+
{ label: "按空间", value: "SPACE" }
|
|
68
|
+
], M = [
|
|
69
|
+
{ label: "可管理", value: "MANAGER" },
|
|
70
|
+
{ label: "可编辑", value: "EDITOR" },
|
|
71
|
+
{ label: "可查看", value: "VIEWER" }
|
|
72
|
+
], I = n(!1), u = n(!1), L = n(!1), m = n("USER"), p = n([]), V = n("VIEWER"), B = n([]), G = n([]), $ = n(""), S = n(!1), v = n(!1), d = n(null), K = n("MANAGER"), R = T(() => ({ ...O, ...r.labels })), F = T(() => {
|
|
73
|
+
var e;
|
|
74
|
+
return (e = r.subjectTypeOptions) != null && e.length ? r.subjectTypeOptions : N;
|
|
75
|
+
}), J = T(() => {
|
|
76
|
+
var e;
|
|
77
|
+
return (e = r.roleOptions) != null && e.length ? r.roleOptions : M;
|
|
78
|
+
}), Y = T(() => J.value.filter((e) => e.value !== "OWNER")), q = T(() => te(B.value)), se = T(() => re(G.value, B.value)), oe = T(() => m.value === "USER" ? "搜索用户" : m.value === "LINE" ? "搜索条线" : "搜索空间"), Q = T(() => {
|
|
79
|
+
const e = $.value.trim().toLowerCase();
|
|
80
|
+
return e ? q.value.filter((a) => {
|
|
81
|
+
var w;
|
|
82
|
+
return a.subjectName.toLowerCase().includes(e) || a.subjectId.toLowerCase().includes(e) || ((w = a.description) == null ? void 0 : w.toLowerCase().includes(e));
|
|
83
|
+
}) : q.value;
|
|
84
|
+
});
|
|
85
|
+
Z(() => r.modelValue, (e) => {
|
|
86
|
+
e && (k(), P(""));
|
|
87
|
+
}), Z(F, (e) => {
|
|
88
|
+
var a;
|
|
89
|
+
e.some((w) => w.value === m.value) || (m.value = ((a = e[0]) == null ? void 0 : a.value) || "USER");
|
|
90
|
+
}, { immediate: !0 });
|
|
91
|
+
function ne(e) {
|
|
92
|
+
i("update:modelValue", e);
|
|
93
|
+
}
|
|
94
|
+
function ue() {
|
|
95
|
+
k(), P("");
|
|
96
|
+
}
|
|
97
|
+
async function k() {
|
|
98
|
+
I.value = !0;
|
|
99
|
+
try {
|
|
100
|
+
B.value = await r.adapter.listPermissions(r.resource.id);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
g.error(U(e, "协作者加载失败"));
|
|
103
|
+
} finally {
|
|
104
|
+
I.value = !1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function P(e) {
|
|
108
|
+
L.value = !0;
|
|
109
|
+
try {
|
|
110
|
+
G.value = await r.adapter.searchSubjects({
|
|
111
|
+
subjectType: m.value,
|
|
112
|
+
keyword: e,
|
|
113
|
+
resourceId: r.resource.id
|
|
114
|
+
});
|
|
115
|
+
} catch (a) {
|
|
116
|
+
g.error(U(a, "候选对象加载失败"));
|
|
117
|
+
} finally {
|
|
118
|
+
L.value = !1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function de() {
|
|
122
|
+
p.value = [], P("");
|
|
123
|
+
}
|
|
124
|
+
async function ce() {
|
|
125
|
+
if (p.value.length) {
|
|
126
|
+
u.value = !0;
|
|
127
|
+
try {
|
|
128
|
+
await Promise.all(p.value.map((e) => r.adapter.grantPermission({
|
|
129
|
+
resourceId: r.resource.id,
|
|
130
|
+
subjectType: m.value,
|
|
131
|
+
subjectId: e,
|
|
132
|
+
role: V.value
|
|
133
|
+
}))), p.value = [], g.success("协作者已添加"), i("saved"), await k(), await P("");
|
|
134
|
+
} catch (e) {
|
|
135
|
+
g.error(U(e, "协作者添加失败"));
|
|
136
|
+
} finally {
|
|
137
|
+
u.value = !1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function ie(e, a) {
|
|
142
|
+
if (a === aa) {
|
|
143
|
+
d.value = e, S.value = !0;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (a === la) {
|
|
147
|
+
d.value = e, v.value = !0;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!(a === "OWNER" || a === e.role)) {
|
|
151
|
+
u.value = !0;
|
|
152
|
+
try {
|
|
153
|
+
await r.adapter.updatePermissionRole({
|
|
154
|
+
resourceId: r.resource.id,
|
|
155
|
+
subjectType: e.subjectType,
|
|
156
|
+
subjectId: e.subjectId,
|
|
157
|
+
role: a
|
|
158
|
+
}), g.success("权限已更新"), i("saved"), await k();
|
|
159
|
+
} catch (w) {
|
|
160
|
+
g.error(U(w, "权限更新失败"));
|
|
161
|
+
} finally {
|
|
162
|
+
u.value = !1;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function ve(e, a) {
|
|
167
|
+
typeof a == "string" && ie(e, a);
|
|
168
|
+
}
|
|
169
|
+
async function be() {
|
|
170
|
+
if (d.value) {
|
|
171
|
+
u.value = !0;
|
|
172
|
+
try {
|
|
173
|
+
await r.adapter.revokePermission({
|
|
174
|
+
resourceId: r.resource.id,
|
|
175
|
+
subjectType: d.value.subjectType,
|
|
176
|
+
subjectId: d.value.subjectId
|
|
177
|
+
}), S.value = !1, d.value = null, g.success("协作者已移除"), i("saved"), await k(), await P("");
|
|
178
|
+
} catch (e) {
|
|
179
|
+
g.error(U(e, "协作者移除失败"));
|
|
180
|
+
} finally {
|
|
181
|
+
u.value = !1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function fe() {
|
|
186
|
+
if (!(!d.value || !r.adapter.transferOwner)) {
|
|
187
|
+
u.value = !0;
|
|
188
|
+
try {
|
|
189
|
+
await r.adapter.transferOwner({
|
|
190
|
+
resourceId: r.resource.id,
|
|
191
|
+
subjectType: d.value.subjectType,
|
|
192
|
+
subjectId: d.value.subjectId,
|
|
193
|
+
previousOwnerRole: K.value
|
|
194
|
+
}), v.value = !1, d.value = null, g.success("所有权已转移"), i("saved"), await k();
|
|
195
|
+
} catch (e) {
|
|
196
|
+
g.error(U(e, "所有权转移失败"));
|
|
197
|
+
} finally {
|
|
198
|
+
u.value = !1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function _e(e) {
|
|
203
|
+
var a;
|
|
204
|
+
return ((a = F.value.find((w) => w.value === e)) == null ? void 0 : a.label.replace(/^按/, "")) || e;
|
|
205
|
+
}
|
|
206
|
+
function pe(e) {
|
|
207
|
+
return e.role === "OWNER" ? [{ label: "所有者", value: "OWNER", disabled: !0 }] : J.value.filter((a) => a.value !== "OWNER");
|
|
208
|
+
}
|
|
209
|
+
function ye(e) {
|
|
210
|
+
return r.readonly || u.value || e.readonly === !0 || e.role === "OWNER";
|
|
211
|
+
}
|
|
212
|
+
function he(e) {
|
|
213
|
+
return !r.readonly && !e.readonly && e.role !== "OWNER";
|
|
214
|
+
}
|
|
215
|
+
function me(e) {
|
|
216
|
+
return r.allowTransferOwner && !!r.adapter.transferOwner && !r.readonly && !e.readonly && e.subjectType === "USER" && e.role !== "OWNER";
|
|
217
|
+
}
|
|
218
|
+
function U(e, a) {
|
|
219
|
+
return e instanceof Error && e.message ? e.message : a;
|
|
220
|
+
}
|
|
221
|
+
return (e, a) => {
|
|
222
|
+
const w = y("el-alert"), we = y("el-radio-button"), je = y("el-radio-group"), x = y("el-option"), H = y("el-select"), z = y("el-button"), ge = y("el-input"), Te = y("el-tag"), Re = y("el-empty"), X = y("el-dialog"), Ee = y("el-form-item"), Ie = y("el-form"), Oe = y("el-drawer"), Ve = Ce("loading");
|
|
223
|
+
return s(), j(Oe, {
|
|
224
|
+
"model-value": t.modelValue,
|
|
225
|
+
size: t.drawerSize,
|
|
226
|
+
"close-on-click-modal": !1,
|
|
227
|
+
class: "hrbac-share-drawer",
|
|
228
|
+
"onUpdate:modelValue": ne,
|
|
229
|
+
onOpen: ue
|
|
230
|
+
}, {
|
|
231
|
+
header: o(() => [
|
|
232
|
+
c("div", Ue, [
|
|
233
|
+
c("div", null, [
|
|
234
|
+
c("div", xe, _(R.value.title), 1),
|
|
235
|
+
c("div", We, _(t.resource.name), 1)
|
|
236
|
+
])
|
|
237
|
+
])
|
|
238
|
+
]),
|
|
239
|
+
default: o(() => [
|
|
240
|
+
Ne((s(), h("div", De, [
|
|
241
|
+
t.readonly ? (s(), j(w, {
|
|
242
|
+
key: 0,
|
|
243
|
+
title: R.value.readonlyTip,
|
|
244
|
+
type: "info",
|
|
245
|
+
"show-icon": "",
|
|
246
|
+
closable: !1,
|
|
247
|
+
class: "hrbac-share-drawer__alert"
|
|
248
|
+
}, null, 8, ["title"])) : C("", !0),
|
|
249
|
+
c("section", Ae, [
|
|
250
|
+
c("div", Le, [
|
|
251
|
+
c("span", Be, _(R.value.addSectionTitle), 1),
|
|
252
|
+
b(je, {
|
|
253
|
+
modelValue: m.value,
|
|
254
|
+
"onUpdate:modelValue": a[0] || (a[0] = (l) => m.value = l),
|
|
255
|
+
size: "small",
|
|
256
|
+
disabled: t.readonly || u.value,
|
|
257
|
+
onChange: de
|
|
258
|
+
}, {
|
|
259
|
+
default: o(() => [
|
|
260
|
+
(s(!0), h(D, null, A(F.value, (l) => (s(), j(we, {
|
|
261
|
+
key: l.value,
|
|
262
|
+
label: l.value
|
|
263
|
+
}, {
|
|
264
|
+
default: o(() => [
|
|
265
|
+
E(_(l.label), 1)
|
|
266
|
+
]),
|
|
267
|
+
_: 2
|
|
268
|
+
}, 1032, ["label"]))), 128))
|
|
269
|
+
]),
|
|
270
|
+
_: 1
|
|
271
|
+
}, 8, ["modelValue", "disabled"])
|
|
272
|
+
]),
|
|
273
|
+
c("div", $e, [
|
|
274
|
+
b(H, {
|
|
275
|
+
modelValue: p.value,
|
|
276
|
+
"onUpdate:modelValue": a[1] || (a[1] = (l) => p.value = l),
|
|
277
|
+
multiple: "",
|
|
278
|
+
filterable: "",
|
|
279
|
+
remote: "",
|
|
280
|
+
"reserve-keyword": "",
|
|
281
|
+
"remote-method": P,
|
|
282
|
+
loading: L.value,
|
|
283
|
+
disabled: t.readonly || u.value,
|
|
284
|
+
placeholder: oe.value,
|
|
285
|
+
class: "hrbac-share-drawer__candidate-select"
|
|
286
|
+
}, {
|
|
287
|
+
default: o(() => [
|
|
288
|
+
(s(!0), h(D, null, A(se.value, (l) => (s(), j(x, {
|
|
289
|
+
key: `${l.subjectType}:${l.subjectId}`,
|
|
290
|
+
label: l.subjectName,
|
|
291
|
+
value: l.subjectId,
|
|
292
|
+
disabled: l.disabled
|
|
293
|
+
}, {
|
|
294
|
+
default: o(() => [
|
|
295
|
+
c("div", ze, [
|
|
296
|
+
c("span", null, _(l.subjectName), 1),
|
|
297
|
+
l.description ? (s(), h("span", Me, _(l.description), 1)) : C("", !0)
|
|
298
|
+
])
|
|
299
|
+
]),
|
|
300
|
+
_: 2
|
|
301
|
+
}, 1032, ["label", "value", "disabled"]))), 128))
|
|
302
|
+
]),
|
|
303
|
+
_: 1
|
|
304
|
+
}, 8, ["modelValue", "loading", "disabled", "placeholder"]),
|
|
305
|
+
b(H, {
|
|
306
|
+
modelValue: V.value,
|
|
307
|
+
"onUpdate:modelValue": a[2] || (a[2] = (l) => V.value = l),
|
|
308
|
+
disabled: t.readonly || u.value,
|
|
309
|
+
class: "hrbac-share-drawer__role-select"
|
|
310
|
+
}, {
|
|
311
|
+
default: o(() => [
|
|
312
|
+
(s(!0), h(D, null, A(Y.value, (l) => (s(), j(x, {
|
|
313
|
+
key: l.value,
|
|
314
|
+
label: l.label,
|
|
315
|
+
value: l.value,
|
|
316
|
+
disabled: l.disabled
|
|
317
|
+
}, null, 8, ["label", "value", "disabled"]))), 128))
|
|
318
|
+
]),
|
|
319
|
+
_: 1
|
|
320
|
+
}, 8, ["modelValue", "disabled"]),
|
|
321
|
+
b(z, {
|
|
322
|
+
type: "primary",
|
|
323
|
+
icon: ee(ke),
|
|
324
|
+
loading: u.value,
|
|
325
|
+
disabled: t.readonly || !p.value.length,
|
|
326
|
+
onClick: ce
|
|
327
|
+
}, {
|
|
328
|
+
default: o(() => [...a[9] || (a[9] = [
|
|
329
|
+
E(" 添加 ", -1)
|
|
330
|
+
])]),
|
|
331
|
+
_: 1
|
|
332
|
+
}, 8, ["icon", "loading", "disabled"])
|
|
333
|
+
])
|
|
334
|
+
]),
|
|
335
|
+
c("section", Ge, [
|
|
336
|
+
c("div", He, [
|
|
337
|
+
c("span", Ke, _(R.value.collaboratorTitle), 1),
|
|
338
|
+
b(ge, {
|
|
339
|
+
modelValue: $.value,
|
|
340
|
+
"onUpdate:modelValue": a[3] || (a[3] = (l) => $.value = l),
|
|
341
|
+
"prefix-icon": ee(Pe),
|
|
342
|
+
clearable: "",
|
|
343
|
+
placeholder: "搜索协作者",
|
|
344
|
+
class: "hrbac-share-drawer__search"
|
|
345
|
+
}, null, 8, ["modelValue", "prefix-icon"])
|
|
346
|
+
]),
|
|
347
|
+
Q.value.length ? (s(), h("div", Fe, [
|
|
348
|
+
(s(!0), h(D, null, A(Q.value, (l) => (s(), h("div", {
|
|
349
|
+
key: `${l.subjectType}:${l.subjectId}`,
|
|
350
|
+
class: "hrbac-share-drawer__row"
|
|
351
|
+
}, [
|
|
352
|
+
c("div", Je, [
|
|
353
|
+
b(Te, {
|
|
354
|
+
size: "small",
|
|
355
|
+
effect: "plain"
|
|
356
|
+
}, {
|
|
357
|
+
default: o(() => [
|
|
358
|
+
E(_(_e(l.subjectType)), 1)
|
|
359
|
+
]),
|
|
360
|
+
_: 2
|
|
361
|
+
}, 1024),
|
|
362
|
+
c("div", null, [
|
|
363
|
+
c("div", Ye, _(l.subjectName), 1),
|
|
364
|
+
l.description ? (s(), h("div", qe, _(l.description), 1)) : C("", !0)
|
|
365
|
+
])
|
|
366
|
+
]),
|
|
367
|
+
b(H, {
|
|
368
|
+
"model-value": l.role,
|
|
369
|
+
disabled: ye(l),
|
|
370
|
+
class: "hrbac-share-drawer__row-role",
|
|
371
|
+
onChange: (W) => ve(l, W)
|
|
372
|
+
}, {
|
|
373
|
+
default: o(() => [
|
|
374
|
+
(s(!0), h(D, null, A(pe(l), (W) => (s(), j(x, {
|
|
375
|
+
key: W.value,
|
|
376
|
+
label: W.label,
|
|
377
|
+
value: W.value,
|
|
378
|
+
disabled: W.disabled
|
|
379
|
+
}, null, 8, ["label", "value", "disabled"]))), 128)),
|
|
380
|
+
me(l) ? (s(), j(x, {
|
|
381
|
+
key: 0,
|
|
382
|
+
label: "转移所有权",
|
|
383
|
+
value: "__transfer__"
|
|
384
|
+
})) : C("", !0),
|
|
385
|
+
he(l) ? (s(), j(x, {
|
|
386
|
+
key: 1,
|
|
387
|
+
label: "移除",
|
|
388
|
+
value: "__remove__"
|
|
389
|
+
})) : C("", !0)
|
|
390
|
+
]),
|
|
391
|
+
_: 2
|
|
392
|
+
}, 1032, ["model-value", "disabled", "onChange"])
|
|
393
|
+
]))), 128))
|
|
394
|
+
])) : (s(), j(Re, {
|
|
395
|
+
key: 1,
|
|
396
|
+
description: R.value.emptyCollaborators,
|
|
397
|
+
class: "hrbac-share-drawer__empty"
|
|
398
|
+
}, null, 8, ["description"]))
|
|
399
|
+
])
|
|
400
|
+
])), [
|
|
401
|
+
[Ve, I.value]
|
|
402
|
+
]),
|
|
403
|
+
b(X, {
|
|
404
|
+
modelValue: S.value,
|
|
405
|
+
"onUpdate:modelValue": a[5] || (a[5] = (l) => S.value = l),
|
|
406
|
+
title: R.value.removeTitle,
|
|
407
|
+
width: "420px",
|
|
408
|
+
"append-to-body": ""
|
|
409
|
+
}, {
|
|
410
|
+
footer: o(() => [
|
|
411
|
+
b(z, {
|
|
412
|
+
onClick: a[4] || (a[4] = (l) => S.value = !1)
|
|
413
|
+
}, {
|
|
414
|
+
default: o(() => [...a[10] || (a[10] = [
|
|
415
|
+
E("取消", -1)
|
|
416
|
+
])]),
|
|
417
|
+
_: 1
|
|
418
|
+
}),
|
|
419
|
+
b(z, {
|
|
420
|
+
type: "danger",
|
|
421
|
+
loading: u.value,
|
|
422
|
+
onClick: be
|
|
423
|
+
}, {
|
|
424
|
+
default: o(() => [...a[11] || (a[11] = [
|
|
425
|
+
E("移除", -1)
|
|
426
|
+
])]),
|
|
427
|
+
_: 1
|
|
428
|
+
}, 8, ["loading"])
|
|
429
|
+
]),
|
|
430
|
+
default: o(() => [
|
|
431
|
+
c("p", Qe, [
|
|
432
|
+
E(_(R.value.removeDescription) + " ", 1),
|
|
433
|
+
d.value ? (s(), h("span", Xe, _(d.value.subjectName), 1)) : C("", !0)
|
|
434
|
+
])
|
|
435
|
+
]),
|
|
436
|
+
_: 1
|
|
437
|
+
}, 8, ["modelValue", "title"]),
|
|
438
|
+
b(X, {
|
|
439
|
+
modelValue: v.value,
|
|
440
|
+
"onUpdate:modelValue": a[8] || (a[8] = (l) => v.value = l),
|
|
441
|
+
title: R.value.transferTitle,
|
|
442
|
+
width: "460px",
|
|
443
|
+
"append-to-body": ""
|
|
444
|
+
}, {
|
|
445
|
+
footer: o(() => [
|
|
446
|
+
b(z, {
|
|
447
|
+
onClick: a[7] || (a[7] = (l) => v.value = !1)
|
|
448
|
+
}, {
|
|
449
|
+
default: o(() => [...a[12] || (a[12] = [
|
|
450
|
+
E("取消", -1)
|
|
451
|
+
])]),
|
|
452
|
+
_: 1
|
|
453
|
+
}),
|
|
454
|
+
b(z, {
|
|
455
|
+
type: "primary",
|
|
456
|
+
loading: u.value,
|
|
457
|
+
onClick: fe
|
|
458
|
+
}, {
|
|
459
|
+
default: o(() => [...a[13] || (a[13] = [
|
|
460
|
+
E("确认转移", -1)
|
|
461
|
+
])]),
|
|
462
|
+
_: 1
|
|
463
|
+
}, 8, ["loading"])
|
|
464
|
+
]),
|
|
465
|
+
default: o(() => [
|
|
466
|
+
c("p", Ze, [
|
|
467
|
+
E(_(R.value.transferDescription) + " ", 1),
|
|
468
|
+
d.value ? (s(), h("span", ea, _(d.value.subjectName), 1)) : C("", !0)
|
|
469
|
+
]),
|
|
470
|
+
b(Ie, {
|
|
471
|
+
"label-position": "left",
|
|
472
|
+
"label-width": "120px"
|
|
473
|
+
}, {
|
|
474
|
+
default: o(() => [
|
|
475
|
+
b(Ee, { label: "原所有者角色" }, {
|
|
476
|
+
default: o(() => [
|
|
477
|
+
b(H, {
|
|
478
|
+
modelValue: K.value,
|
|
479
|
+
"onUpdate:modelValue": a[6] || (a[6] = (l) => K.value = l)
|
|
480
|
+
}, {
|
|
481
|
+
default: o(() => [
|
|
482
|
+
(s(!0), h(D, null, A(Y.value, (l) => (s(), j(x, {
|
|
483
|
+
key: l.value,
|
|
484
|
+
label: l.label,
|
|
485
|
+
value: l.value,
|
|
486
|
+
disabled: l.disabled
|
|
487
|
+
}, null, 8, ["label", "value", "disabled"]))), 128))
|
|
488
|
+
]),
|
|
489
|
+
_: 1
|
|
490
|
+
}, 8, ["modelValue"])
|
|
491
|
+
]),
|
|
492
|
+
_: 1
|
|
493
|
+
})
|
|
494
|
+
]),
|
|
495
|
+
_: 1
|
|
496
|
+
})
|
|
497
|
+
]),
|
|
498
|
+
_: 1
|
|
499
|
+
}, 8, ["modelValue", "title"])
|
|
500
|
+
]),
|
|
501
|
+
_: 1
|
|
502
|
+
}, 8, ["model-value", "size"]);
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
}), ta = (t, f) => {
|
|
506
|
+
const r = t.__vccOpts || t;
|
|
507
|
+
for (const [i, O] of f)
|
|
508
|
+
r[i] = O;
|
|
509
|
+
return r;
|
|
510
|
+
}, ua = /* @__PURE__ */ ta(ra, [["__scopeId", "data-v-cbf40cd5"]]);
|
|
511
|
+
function da(t) {
|
|
512
|
+
const f = n(!1), r = n(!1), i = n(""), O = n("USER"), N = n([]), M = n("VIEWER"), I = n([]), u = n([]), L = T(() => te(I.value)), m = T(() => re(u.value, I.value));
|
|
513
|
+
async function p() {
|
|
514
|
+
f.value = !0;
|
|
515
|
+
try {
|
|
516
|
+
I.value = await t.adapter.listPermissions(t.resourceId);
|
|
517
|
+
} finally {
|
|
518
|
+
f.value = !1;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
async function V() {
|
|
522
|
+
u.value = await t.adapter.searchSubjects({
|
|
523
|
+
subjectType: O.value,
|
|
524
|
+
keyword: i.value,
|
|
525
|
+
resourceId: t.resourceId
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
async function B() {
|
|
529
|
+
if (N.value.length) {
|
|
530
|
+
r.value = !0;
|
|
531
|
+
try {
|
|
532
|
+
await Promise.all(N.value.map((v) => t.adapter.grantPermission({
|
|
533
|
+
resourceId: t.resourceId,
|
|
534
|
+
subjectType: O.value,
|
|
535
|
+
subjectId: v,
|
|
536
|
+
role: M.value
|
|
537
|
+
}))), N.value = [], i.value = "", await p(), await V();
|
|
538
|
+
} finally {
|
|
539
|
+
r.value = !1;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
async function G(v, d) {
|
|
544
|
+
r.value = !0;
|
|
545
|
+
try {
|
|
546
|
+
await t.adapter.updatePermissionRole({
|
|
547
|
+
resourceId: t.resourceId,
|
|
548
|
+
subjectType: v.subjectType,
|
|
549
|
+
subjectId: v.subjectId,
|
|
550
|
+
role: d
|
|
551
|
+
}), await p();
|
|
552
|
+
} finally {
|
|
553
|
+
r.value = !1;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
async function $(v) {
|
|
557
|
+
r.value = !0;
|
|
558
|
+
try {
|
|
559
|
+
await t.adapter.revokePermission({
|
|
560
|
+
resourceId: t.resourceId,
|
|
561
|
+
subjectType: v.subjectType,
|
|
562
|
+
subjectId: v.subjectId
|
|
563
|
+
}), await p(), await V();
|
|
564
|
+
} finally {
|
|
565
|
+
r.value = !1;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
async function S(v, d = "MANAGER") {
|
|
569
|
+
if (t.adapter.transferOwner) {
|
|
570
|
+
r.value = !0;
|
|
571
|
+
try {
|
|
572
|
+
await t.adapter.transferOwner({
|
|
573
|
+
resourceId: t.resourceId,
|
|
574
|
+
subjectType: v.subjectType,
|
|
575
|
+
subjectId: v.subjectId,
|
|
576
|
+
previousOwnerRole: d
|
|
577
|
+
}), await p();
|
|
578
|
+
} finally {
|
|
579
|
+
r.value = !1;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
loading: f,
|
|
585
|
+
saving: r,
|
|
586
|
+
keyword: i,
|
|
587
|
+
subjectType: O,
|
|
588
|
+
selectedSubjectIds: N,
|
|
589
|
+
selectedRole: M,
|
|
590
|
+
permissions: I,
|
|
591
|
+
candidates: u,
|
|
592
|
+
sortedPermissions: L,
|
|
593
|
+
availableCandidates: m,
|
|
594
|
+
loadPermissions: p,
|
|
595
|
+
searchCandidates: V,
|
|
596
|
+
grantSelected: B,
|
|
597
|
+
updateRole: G,
|
|
598
|
+
revoke: $,
|
|
599
|
+
transferOwner: S
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
export {
|
|
603
|
+
ua as HrbacShareDrawer,
|
|
604
|
+
le as buildSubjectKey,
|
|
605
|
+
re as excludeExistingSubjects,
|
|
606
|
+
te as sortSharePermissions,
|
|
607
|
+
da as useHrbacShare
|
|
608
|
+
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.hrbac-share-drawer__header[data-v-cbf40cd5]{display:flex;align-items:center;justify-content:space-between}.hrbac-share-drawer__title[data-v-cbf40cd5]{color:var(--hrbac-share-text-primary, #1f2329);font-size:var(--hrbac-share-font-title, 18px);font-weight:600;line-height:26px}.hrbac-share-drawer__subtitle[data-v-cbf40cd5]{margin-top:4px;color:var(--hrbac-share-text-secondary, #646a73);font-size:var(--hrbac-share-font-body, 14px)}.hrbac-share-drawer__body[data-v-cbf40cd5]{display:flex;flex-direction:column;gap:20px}.hrbac-share-drawer__alert[data-v-cbf40cd5]{margin-bottom:-4px}.hrbac-share-drawer__section[data-v-cbf40cd5]{display:flex;flex-direction:column;gap:12px}.hrbac-share-drawer__section-head[data-v-cbf40cd5]{display:flex;align-items:center;justify-content:space-between;gap:16px}.hrbac-share-drawer__section-title[data-v-cbf40cd5]{color:var(--hrbac-share-text-primary, #1f2329);font-size:var(--hrbac-share-font-body, 14px);font-weight:600}.hrbac-share-drawer__add-row[data-v-cbf40cd5]{display:grid;grid-template-columns:minmax(0,1fr) 120px auto;gap:8px;align-items:center}.hrbac-share-drawer__candidate-select[data-v-cbf40cd5],.hrbac-share-drawer__role-select[data-v-cbf40cd5],.hrbac-share-drawer__row-role[data-v-cbf40cd5],.hrbac-share-drawer__search[data-v-cbf40cd5]{width:100%}.hrbac-share-drawer__candidate-option[data-v-cbf40cd5]{display:flex;align-items:center;justify-content:space-between;gap:12px}.hrbac-share-drawer__candidate-desc[data-v-cbf40cd5],.hrbac-share-drawer__row-desc[data-v-cbf40cd5]{color:var(--hrbac-share-text-secondary, #646a73);font-size:12px}.hrbac-share-drawer__section--list[data-v-cbf40cd5]{min-height:0}.hrbac-share-drawer__search[data-v-cbf40cd5]{max-width:220px}.hrbac-share-drawer__list[data-v-cbf40cd5]{display:flex;max-height:420px;flex-direction:column;overflow:auto;border:1px solid var(--hrbac-share-border, #dee0e3)}.hrbac-share-drawer__row[data-v-cbf40cd5]{display:grid;grid-template-columns:minmax(0,1fr) 148px;gap:12px;align-items:center;padding:12px;border-bottom:1px solid var(--hrbac-share-border, #dee0e3)}.hrbac-share-drawer__row[data-v-cbf40cd5]:last-child{border-bottom:none}.hrbac-share-drawer__row-main[data-v-cbf40cd5]{display:flex;min-width:0;align-items:center;gap:10px}.hrbac-share-drawer__row-name[data-v-cbf40cd5]{overflow:hidden;color:var(--hrbac-share-text-primary, #1f2329);font-size:var(--hrbac-share-font-body, 14px);text-overflow:ellipsis;white-space:nowrap}.hrbac-share-drawer__empty[data-v-cbf40cd5]{border:1px solid var(--hrbac-share-border, #dee0e3)}.hrbac-share-drawer__dialog-text[data-v-cbf40cd5]{margin:0;color:var(--hrbac-share-text-regular, #373c43);line-height:22px}.hrbac-share-drawer__dialog-target[data-v-cbf40cd5]{color:var(--hrbac-share-text-primary, #1f2329);font-weight:600}@media (max-width: 640px){.hrbac-share-drawer__section-head[data-v-cbf40cd5],.hrbac-share-drawer__add-row[data-v-cbf40cd5],.hrbac-share-drawer__row[data-v-cbf40cd5]{display:flex;flex-direction:column;align-items:stretch}.hrbac-share-drawer__search[data-v-cbf40cd5]{max-width:none}}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type HrbacShareSubjectType = 'USER' | 'LINE' | 'SPACE';
|
|
4
|
+
export type HrbacShareRole = 'OWNER' | 'MANAGER' | 'EDITOR' | 'VIEWER';
|
|
5
|
+
export interface HrbacShareResource {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface HrbacShareSubjectRef {
|
|
11
|
+
subjectType: HrbacShareSubjectType;
|
|
12
|
+
subjectId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface HrbacShareSubjectOption extends HrbacShareSubjectRef {
|
|
15
|
+
subjectName: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface HrbacSharePermission extends HrbacShareSubjectOption {
|
|
20
|
+
role: HrbacShareRole;
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
inherited?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface HrbacShareRoleOption {
|
|
25
|
+
label: string;
|
|
26
|
+
value: HrbacShareRole;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface HrbacShareSubjectTypeOption {
|
|
30
|
+
label: string;
|
|
31
|
+
value: HrbacShareSubjectType;
|
|
32
|
+
icon?: Component;
|
|
33
|
+
}
|
|
34
|
+
export interface HrbacShareGrantPayload extends HrbacShareSubjectRef {
|
|
35
|
+
resourceId: string;
|
|
36
|
+
role: Exclude<HrbacShareRole, 'OWNER'>;
|
|
37
|
+
}
|
|
38
|
+
export interface HrbacShareUpdateRolePayload extends HrbacShareSubjectRef {
|
|
39
|
+
resourceId: string;
|
|
40
|
+
role: Exclude<HrbacShareRole, 'OWNER'>;
|
|
41
|
+
}
|
|
42
|
+
export interface HrbacShareRevokePayload extends HrbacShareSubjectRef {
|
|
43
|
+
resourceId: string;
|
|
44
|
+
}
|
|
45
|
+
export interface HrbacShareTransferOwnerPayload extends HrbacShareSubjectRef {
|
|
46
|
+
resourceId: string;
|
|
47
|
+
previousOwnerRole?: Exclude<HrbacShareRole, 'OWNER'>;
|
|
48
|
+
}
|
|
49
|
+
export interface HrbacShareSubjectQuery {
|
|
50
|
+
subjectType: HrbacShareSubjectType;
|
|
51
|
+
keyword: string;
|
|
52
|
+
resourceId: string;
|
|
53
|
+
}
|
|
54
|
+
export interface HrbacShareAdapter {
|
|
55
|
+
listPermissions: (resourceId: string) => Promise<HrbacSharePermission[]>;
|
|
56
|
+
searchSubjects: (query: HrbacShareSubjectQuery) => Promise<HrbacShareSubjectOption[]>;
|
|
57
|
+
grantPermission: (payload: HrbacShareGrantPayload) => Promise<void>;
|
|
58
|
+
updatePermissionRole: (payload: HrbacShareUpdateRolePayload) => Promise<void>;
|
|
59
|
+
revokePermission: (payload: HrbacShareRevokePayload) => Promise<void>;
|
|
60
|
+
transferOwner?: (payload: HrbacShareTransferOwnerPayload) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export interface HrbacShareLabels {
|
|
63
|
+
title?: string;
|
|
64
|
+
addSectionTitle?: string;
|
|
65
|
+
collaboratorTitle?: string;
|
|
66
|
+
readonlyTip?: string;
|
|
67
|
+
emptyCollaborators?: string;
|
|
68
|
+
removeTitle?: string;
|
|
69
|
+
removeDescription?: string;
|
|
70
|
+
transferTitle?: string;
|
|
71
|
+
transferDescription?: string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE7D,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,qBAAqB,CAAA;IAClC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACnE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACnE,IAAI,EAAE,cAAc,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,cAAc,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,qBAAqB,CAAA;IAC5B,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACnE,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;IAC1E,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,qBAAqB,CAAA;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAA;IACxE,cAAc,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAA;IACrF,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACnE,oBAAoB,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7E,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,8BAA8B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3E;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rzyuan/hrbac-share",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue HRBAC share drawer with adapter-based permission operations.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"private": false,
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"build": "vue-tsc --noEmit && vite build"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"element-plus": ">=2.8.0",
|
|
28
|
+
"vue": ">=3.4.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@element-plus/icons-vue": "^2.3.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
35
|
+
"typescript": "^5.3.0",
|
|
36
|
+
"vite": "^5.0.0",
|
|
37
|
+
"vite-plugin-dts": "^3.9.1",
|
|
38
|
+
"vitest": "^1.6.1",
|
|
39
|
+
"vue": "^3.5.30",
|
|
40
|
+
"vue-tsc": "^2.0.0",
|
|
41
|
+
"element-plus": "^2.13.6"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|