From b40ca0edadcb8460478c2b8b68df2dfb2fe67088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=95=85=E6=99=9A?= Date: Tue, 6 Aug 2024 20:02:33 +0800 Subject: [PATCH] PullRequest: 495 Fixes oceanbase/odc#3105 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge branch 'fix/dev-4.3.1-3105 of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.1 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/495 Signed-off-by: 晓康 * Fixes oceanbase/odc#3105 --- src/common/network/project.ts | 2 +- src/component/Task/DetailModal.tsx | 10 +++++----- src/component/Task/component/ActionBar/index.tsx | 3 +-- src/service/projectHistory.ts | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/common/network/project.ts b/src/common/network/project.ts index df265c394..4c140d2f4 100644 --- a/src/common/network/project.ts +++ b/src/common/network/project.ts @@ -51,7 +51,7 @@ export async function getProject(id: number): Promise { return res?.data; } -export async function getProjectHistoryInfo(id: number): Promise { +export async function getProjectWithErrorCatch(id: number): Promise { const res = await request.get(`/api/v2/collaboration/projects/${id}`, { params: { ignoreError: true, diff --git a/src/component/Task/DetailModal.tsx b/src/component/Task/DetailModal.tsx index 1515e18f7..42f2fd96b 100644 --- a/src/component/Task/DetailModal.tsx +++ b/src/component/Task/DetailModal.tsx @@ -66,7 +66,7 @@ import { ApplyDatabasePermissionTaskContent } from './ApplyDatabasePermission'; import { ApplyTablePermissionTaskContent } from './ApplyTablePermission'; import { StructureComparisonTaskContent } from './StructureComparisonTask'; import { MutipleAsyncTaskContent } from './MutipleAsyncTask'; -import { getProject } from '@/common/network/project'; +import { getProjectWithErrorCatch } from '@/common/network/project'; import { ProjectRole } from '@/d.ts/project'; import userStore from '@/store/login'; import { isNumber } from 'lodash'; @@ -144,10 +144,10 @@ const DetailModal: React.FC = React.memo((props) => { setIsTaskProjectOwner(false); return; } - const res = await getProject(projectId); - const userRoleList = res?.members - ?.filter((i) => i.id === userStore?.user?.id) - ?.map((j) => j.role); + + const res = await getProjectWithErrorCatch(projectId); + const userRoleList = + res?.members?.filter((i) => i.id === userStore?.user?.id)?.map((j) => j.role) || []; setIsTaskProjectOwner(userRoleList.includes(ProjectRole.OWNER)); }; diff --git a/src/component/Task/component/ActionBar/index.tsx b/src/component/Task/component/ActionBar/index.tsx index 53a6e7535..2af62d443 100644 --- a/src/component/Task/component/ActionBar/index.tsx +++ b/src/component/Task/component/ActionBar/index.tsx @@ -92,7 +92,6 @@ const ActionBar: React.FC = inject( } = props; const isOwner = user?.id === task?.creator?.id; const isApprover = task?.approvable; - const isCandidateApprovers = task?.candidateApprovers; const isOwnerAndApprover = isOwner && isApprover; const [activeBtnKey, setActiveBtnKey] = useState(null); const [openRollback, setOpenRollback] = useState(false); @@ -843,7 +842,7 @@ const ActionBar: React.FC = inject( handleApproval(false); }, }; - const isOperator = isOwner || isCandidateApprovers; + const isOperator = isOwner || isTaskProjectOwner; switch (status) { case TaskStatus.APPROVING: { if (isOperator && isApprover) { diff --git a/src/service/projectHistory.ts b/src/service/projectHistory.ts index ff6b931d7..e1dcc109b 100644 --- a/src/service/projectHistory.ts +++ b/src/service/projectHistory.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { getProjectHistoryInfo } from '@/common/network/project'; +import { getProjectWithErrorCatch } from '@/common/network/project'; import login from '@/store/login'; import logger from '@/util/logger'; import { safeParseJson } from '@/util/utils'; @@ -54,7 +54,7 @@ export async function toDefaultProjectPage() { if (!projectId) { history.push('/project'); } else { - const project = await getProjectHistoryInfo(projectId); + const project = await getProjectWithErrorCatch(projectId); const isProjectAvailable = project && !project?.archived; isProjectAvailable ? history.push(`/project/${projectId}/database`) : history.push('/project'); }