Skip to content

Commit

Permalink
PullRequest: 495 Fixes oceanbase/odc#3105
Browse files Browse the repository at this point in the history
Merge branch 'fix/dev-4.3.1-3105 of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.1

https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/495


Signed-off-by: 晓康 <[email protected]>


* Fixes oceanbase/odc#3105
  • Loading branch information
yezaoshu committed Aug 6, 2024
1 parent 571246b commit b40ca0e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/common/network/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getProject(id: number): Promise<IProject> {
return res?.data;
}

export async function getProjectHistoryInfo(id: number): Promise<IProject> {
export async function getProjectWithErrorCatch(id: number): Promise<IProject> {
const res = await request.get(`/api/v2/collaboration/projects/${id}`, {
params: {
ignoreError: true,
Expand Down
10 changes: 5 additions & 5 deletions src/component/Task/DetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -144,10 +144,10 @@ const DetailModal: React.FC<IProps> = 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));
};

Expand Down
3 changes: 1 addition & 2 deletions src/component/Task/component/ActionBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const ActionBar: React.FC<IProps> = 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);
Expand Down Expand Up @@ -843,7 +842,7 @@ const ActionBar: React.FC<IProps> = inject(
handleApproval(false);
},
};
const isOperator = isOwner || isCandidateApprovers;
const isOperator = isOwner || isTaskProjectOwner;
switch (status) {
case TaskStatus.APPROVING: {
if (isOperator && isApprover) {
Expand Down
4 changes: 2 additions & 2 deletions src/service/projectHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit b40ca0e

Please sign in to comment.