Skip to content

Commit 9da26c4

Browse files
之瑛蚂蚁代码服务
authored andcommitted
PullRequest: 1165 fix: 作业与执行记录增加鉴权
Merge branch 'fix/relativeModalAuthCheck of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.4.1 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/1165 Reviewed-by: 晓康 <xxk268858@oceanbase.com> * fix: 作业与执行记录增加鉴权 * fix: 完善权限判断 * refactor: 优化写法
1 parent 8d2b1e3 commit 9da26c4

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

src/component/RelativeResourceModal/index.less

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
align-items: start;
88
flex-direction: column;
99
cursor: pointer;
10-
.title {
10+
.title,
11+
.disabledTitle {
1112
font-size: 12px;
1213
line-height: 20px;
1314
font-weight: 600;
14-
&:hover {
15-
color: var(--text-color-link);
16-
}
15+
}
16+
.title:hover {
17+
color: var(--text-color-link);
18+
}
19+
.disabledTitle {
20+
color: var(--text-color-hint);
21+
cursor: not-allowed;
1722
}
1823
}
1924
.recordScheduleName {
@@ -38,11 +43,14 @@
3843
white-space: nowrap;
3944
overflow: hidden;
4045
text-overflow: ellipsis;
46+
47+
.titleText {
48+
font-weight: 600;
49+
}
4150
}
4251
.disabledTitle {
4352
font-size: 12px;
4453
line-height: 20px;
45-
font-weight: 600;
4654
cursor: not-allowed;
4755
color: var(--text-color-hint);
4856
}

src/component/RelativeResourceModal/index.tsx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ const RelativeResourceModal: React.FC<IRelativeResourceModalProps> = ({
132132
}
133133
}, [open, id, mode]);
134134

135+
// 判断是否可以访问详情:个人空间无权限,否则检查项目权限
136+
const getCanAccessDetail = (record: IResourceDependencyItem): boolean => {
137+
const isPersonalSpace = mode === EEntityType.USER || login.isPrivateSpace();
138+
return isPersonalSpace ? false : !!record?.project?.currentUserResourceRoles?.length;
139+
};
140+
135141
const EResourceTypeConfig = useMemo(
136142
() => ({
137143
[EResourceType.TASKS]: {
@@ -178,25 +184,24 @@ const RelativeResourceModal: React.FC<IRelativeResourceModalProps> = ({
178184
setCurrentRecord(record);
179185
setDetailVisible(true);
180186
};
181-
// 个人空间对应的资源依赖弹窗,不校验项目权限,直接按无权限展示
182-
const isDeleteUser = mode === EEntityType.USER || login.isPrivateSpace();
183-
const hasProjectAuth = isDeleteUser
184-
? false
185-
: !!record?.project?.currentUserResourceRoles?.length;
186-
const hint = isDeleteUser
187+
const canAccessDetail = getCanAccessDetail(record);
188+
const isPersonalSpace = mode === EEntityType.USER || login.isPrivateSpace();
189+
const hint = isPersonalSpace
187190
? '无访问权限,无法查看工单详情'
188191
: formatMessage({
189192
id: 'src.component.RelativeResourceModal.94DC18D3',
190193
defaultMessage: '暂无所属的项目访问权限,无法查看工单详情,请联系管理员',
191194
});
192195
return (
193196
<div className={styles.taskName}>
194-
<Tooltip title={hasProjectAuth ? '' : hint}>
197+
<Tooltip title={canAccessDetail ? '' : hint}>
195198
<div
196-
className={hasProjectAuth ? styles.title : styles.disabledTitle}
197-
onClick={hasProjectAuth ? handleClick : () => {}}
199+
className={canAccessDetail ? styles.title : styles.disabledTitle}
200+
onClick={canAccessDetail ? handleClick : () => {}}
198201
>
199-
<Tooltip title={hasProjectAuth ? text : ''}>{text || '-'}</Tooltip>
202+
<Tooltip title={canAccessDetail ? text : ''}>
203+
<span className={styles.titleText}>{text || '-'}</span>
204+
</Tooltip>
200205
</div>
201206
</Tooltip>
202207
<div>
@@ -247,14 +252,20 @@ const RelativeResourceModal: React.FC<IRelativeResourceModalProps> = ({
247252
key: 'name',
248253
ellipsis: true,
249254
render: (text: string, record: IResourceDependencyItem) => {
255+
const canAccessDetail = getCanAccessDetail(record);
256+
250257
const handleClick = () => {
258+
if (!canAccessDetail) {
259+
return;
260+
}
251261
setCurrentRecord(record);
252262
setScheduleDetailVisible(true);
253263
};
254-
255264
return (
256265
<div className={styles.scheduleName} onClick={handleClick}>
257-
<div className={styles.title}>{text || '-'}</div>
266+
<div className={canAccessDetail ? styles.title : styles.disabledTitle}>
267+
{text || '-'}
268+
</div>
258269
<div>
259270
<TaskTitle record={record} />
260271
</div>
@@ -301,14 +312,19 @@ const RelativeResourceModal: React.FC<IRelativeResourceModalProps> = ({
301312
width: 92,
302313
ellipsis: true,
303314
render: (text: string, record: IResourceDependencyItem) => {
315+
const canAccessDetail = getCanAccessDetail(record);
304316
const handleClick = () => {
317+
if (!canAccessDetail) {
318+
return;
319+
}
305320
setCurrentRecord(record);
306321
setExecuteDetailVisible(true);
307322
};
308-
309323
return (
310324
<div className={styles.taskName} onClick={handleClick}>
311-
{text ? `#${text}` : '-'}
325+
<div className={canAccessDetail ? styles.title : styles.disabledTitle}>
326+
{text ? `#${text}` : '-'}
327+
</div>
312328
</div>
313329
);
314330
},

0 commit comments

Comments
 (0)