Skip to content

Commit

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

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


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


* Fixes oceanbase/odc#3023
  • Loading branch information
UnknownAdventurer committed Jul 29, 2024
1 parent 4ea3890 commit 09c91b0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 39 deletions.
31 changes: 17 additions & 14 deletions src/component/Task/MutipleAsyncTask/CreateModal/DatabaseQueue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,25 @@ export const DatabaseQueueSelect: React.FC<{
true,
true,
);
setDatabaseOptions(
databaseList?.contents?.map((item) => {
const statusInfo = datasourceStatus.statusMap.get(item?.dataSource?.id);
return {
label: item?.name,
value: item?.id,
environment: item?.environment,
dataSource: item?.dataSource,
existed: item?.existed,
unauthorized: !item?.authorizedPermissionTypes?.includes(DatabasePermissionType.CHANGE),
expired: checkDbExpiredByDataSourceStatus(statusInfo?.status),
};
}),
);
if (databaseList?.contents?.length) {
setDefaultDatasource(databaseList?.contents?.[0]?.dataSource);
await datasourceStatus.asyncUpdateStatus([
...new Set(databaseList?.contents?.map((item) => item.dataSource?.id)),
]);
setDatabaseOptions(
databaseList?.contents?.map((item) => {
const statusInfo = datasourceStatus.statusMap.get(item?.dataSource?.id);
return {
label: item?.name,
value: item?.id,
environment: item?.environment,
dataSource: item?.dataSource,
existed: item?.existed,
unauthorized: !item?.authorizedPermissionTypes?.includes(DatabasePermissionType.CHANGE),
expired: checkDbExpiredByDataSourceStatus(statusInfo?.status),
};
}),
);
}
databaseList?.contents?.forEach((db) => {
databaseIdMap.set(db.id, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,25 @@ const EditTemplate: React.FC<{
true,
true,
);

setDatabaseOptions(
databaseList?.contents?.map((item) => {
const statusInfo = datasourceStatus.statusMap.get(item?.dataSource?.id);
return {
label: item?.name,
value: item?.id,
environment: item?.environment,
dataSource: item?.dataSource,
existed: item?.existed,
unauthorized: !item?.authorizedPermissionTypes?.includes(DatabasePermissionType.CHANGE),
expired: checkDbExpiredByDataSourceStatus(statusInfo?.status),
};
}),
);
if (databaseList?.contents?.length) {
await datasourceStatus.asyncUpdateStatus([
...new Set(databaseList?.contents?.map((item) => item?.dataSource?.id)),
]);
setDatabaseOptions(
databaseList?.contents?.map((item) => {
const statusInfo = datasourceStatus.statusMap.get(item?.dataSource?.id);
return {
label: item?.name,
value: item?.id,
environment: item?.environment,
dataSource: item?.dataSource,
existed: item?.existed,
unauthorized: !item?.authorizedPermissionTypes?.includes(DatabasePermissionType.CHANGE),
expired: checkDbExpiredByDataSourceStatus(statusInfo?.status),
};
}),
);
}
};
const initTemplate = async (templateId: number) => {
const response = await detailTemplate(templateId, login?.organizationId?.toString());
Expand Down
2 changes: 1 addition & 1 deletion src/page/Project/Database/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
true,
);
if (res) {
datasourceStatus.asyncUpdateStatus(res?.contents?.map((item) => item?.dataSource?.id));
await datasourceStatus.asyncUpdateStatus(res?.contents?.map((item) => item?.dataSource?.id));
setData(res?.contents);
setTotal(res?.page?.totalElements);
}
Expand Down
15 changes: 9 additions & 6 deletions src/page/Workspace/SideBar/ResourceTree/DatabaseTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ const DatabaseTree: React.FC<IProps> = function ({ openSelectPanel }) {
async function reloadDatabase() {
await reloadDatabaseList();
}
async function handleDatabase() {
setDatabases(databaseList?.filter((item) => !!item?.authorizedPermissionTypes?.length));
const ids: Set<number> = new Set();
databaseList.forEach((d) => {
ids.add(d.dataSource?.id);
});
await datasourceStatus.asyncUpdateStatus(Array.from(ids));
}

useEffect(() => {
if (selectDatasourceId || selectProjectId) {
Expand All @@ -54,12 +62,7 @@ const DatabaseTree: React.FC<IProps> = function ({ openSelectPanel }) {

useEffect(() => {
if (databaseList?.length) {
setDatabases(databaseList?.filter((item) => !!item?.authorizedPermissionTypes?.length));
const ids: Set<number> = new Set();
databaseList.forEach((d) => {
ids.add(d.dataSource?.id);
});
datasourceStatus.asyncUpdateStatus(Array.from(ids));
handleDatabase();
}
}, [databaseList]);

Expand Down
2 changes: 1 addition & 1 deletion src/page/Workspace/context/WorkspaceStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function WorkspaceStore({ children }) {
const reloadDatasourceList = useCallback(async () => {
const data = await fetchDatasource();
setDatasourceList(data?.contents || []);
datasourceStatus.asyncUpdateStatus(data?.contents?.map((a) => a.id));
await datasourceStatus.asyncUpdateStatus(data?.contents?.map((a) => a.id));
}, []);

const reloadProjectList = useCallback(async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/store/datasourceStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export class DataSourceStatusStore {
}
}

public asyncUpdateStatus(ids: IDatasource['id'][]) {
public async asyncUpdateStatus(ids: IDatasource['id'][]) {
ids?.forEach((id) => {
this.queue.add(id);
});
if (this.status === 'stop') {
this.status = 'running';
this.fetchStatus();
await this.fetchStatus();
}
}

Expand Down

0 comments on commit 09c91b0

Please sign in to comment.