Skip to content

Commit

Permalink
[chore]:(PermissionControl、usePermission) Rename props and function p…
Browse files Browse the repository at this point in the history
…arameters
  • Loading branch information
LZS911 committed Nov 4, 2024
1 parent 345592d commit 9c917c4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/shared/lib/global/PermissionControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const PermissionControl: React.FC<PermissionControlProps> = ({
permission,
children,
projectID,
dbServiceID
authDataSourceId
}) => {
const { checkActionPermission } = usePermission(projectID);

if (checkActionPermission(permission, undefined, dbServiceID)) {
if (checkActionPermission(permission, undefined, authDataSourceId)) {
return <>{children}</>;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/global/PermissionControl/index.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export type PermissionControlProps = {
permission: PermissionsConstantType;
children: ReactNode;
projectID?: string;
dbServiceID?: string;
authDataSourceId?: string;
};
10 changes: 5 additions & 5 deletions packages/shared/lib/global/usePermission/usePermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const usePermission = (targetProjectID?: string) => {
const checkDbServicePermission = useCallback(
(
opPermissionType: OpPermissionItemOpPermissionTypeEnum,
dbServiceId?: string
authDataSourceId?: string
) => {
if (userOperationPermissions) {
const { is_admin, op_permission_list } = userOperationPermissions;
Expand All @@ -64,8 +64,8 @@ const usePermission = (targetProjectID?: string) => {
if (
permission.range_type ===
OpPermissionItemRangeTypeEnum.db_service &&
(dbServiceId
? permission.range_uids?.includes(dbServiceId)
(authDataSourceId
? permission.range_uids?.includes(authDataSourceId)
: permission.range_uids?.length) &&
permission.op_permission_type === opPermissionType
) {
Expand Down Expand Up @@ -120,7 +120,7 @@ const usePermission = (targetProjectID?: string) => {
<T = Record<string, string>>(
requiredPermission: PermissionsConstantType,
record?: T,
dbServiceId?: string
authDataSourceId?: string
): boolean => {
const permissionDetails = PERMISSION_MANIFEST[requiredPermission];
// 检查项目是否已冻结
Expand All @@ -145,7 +145,7 @@ const usePermission = (targetProjectID?: string) => {
opType,
fieldName
? (record as Record<string, string>)?.[fieldName]
: dbServiceId
: authDataSourceId
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const CreateWorkflowForModifiedSqlAction = (
PERMISSIONS.ACTIONS.SQLE.DATA_SOURCE_COMPARISON
.CREATE_MODIFIED_SQL_WORKFLOW
}
dbServiceID={instanceId}
authDataSourceId={instanceId}
>
<ActionButton
actionType="navigate-link"
Expand Down

0 comments on commit 9c917c4

Please sign in to comment.