Skip to content

Commit 39bc978

Browse files
committed
fix: table change page size bug & public app view bug
1 parent 0136502 commit 39bc978

File tree

4 files changed

+53
-65
lines changed

4 files changed

+53
-65
lines changed

client/packages/openblocks/src/comps/comps/tableComp/tableComp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
502502
input.showSizeChanger.value,
503503
input.pageSize.value,
504504
input.pageSizeOptions.value,
505-
input.changeablePageSize.value
505+
input.changeablePageSize
506506
);
507507
},
508508
trans("table.pageSizeDesc")
@@ -557,7 +557,7 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
557557
input.showSizeChanger.value,
558558
input.pageSize.value,
559559
input.pageSizeOptions.value,
560-
input.changeablePageSize.value
560+
input.changeablePageSize
561561
) *
562562
(input.pageNo - 1)
563563
);

client/packages/openblocks/src/comps/queries/queryComp/queryPropertyView.tsx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { EditorContext } from "../../editorState";
33
import { BottomTabs } from "pages/editor/bottom/BottomTabs";
44
import { useSelector } from "react-redux";
55
import { getDataSource, getDataSourceTypes } from "redux/selectors/datasourceSelectors";
6-
import { InputStatus } from "antd/es/_util/statusUtils";
76
import {
87
changeValueAction,
98
deferAction,
@@ -27,7 +26,7 @@ import { PreparedStatementConfig } from "../../../api/datasourceApi";
2726
import { BottomResTypeEnum } from "types/bottomRes";
2827
import { PageType } from "../../../constants/pageConstants";
2928
import { trans } from "i18n";
30-
import { manualTriggerResource } from "@openblocks-ee/constants/queryConstants";
29+
import { manualTriggerResource, ResourceType } from "@openblocks-ee/constants/queryConstants";
3130
import {
3231
OPENBLOCKS_API_ID,
3332
QUICK_GRAPHQL_ID,
@@ -41,7 +40,6 @@ export function QueryPropertyView(props: { comp: InstanceType<typeof QueryComp>
4140

4241
const editorState = useContext(EditorContext);
4342
const datasource = useSelector(getDataSource);
44-
const datasourceTypes = useSelector(getDataSourceTypes);
4543

4644
const children = comp.children;
4745
const dispatch = comp.dispatch;
@@ -50,24 +48,7 @@ export function QueryPropertyView(props: { comp: InstanceType<typeof QueryComp>
5048
const datasourceConfig = datasource.find((d) => d.datasource.id === datasourceId)?.datasource
5149
.datasourceConfig;
5250

53-
const datasourceStatus: InputStatus = useMemo(() => {
54-
if (
55-
datasourceType === "js" ||
56-
datasourceType === "libraryQuery" ||
57-
datasourceId === QUICK_REST_API_ID ||
58-
datasourceId === QUICK_GRAPHQL_ID ||
59-
datasourceId === OPENBLOCKS_API_ID
60-
) {
61-
return "";
62-
}
63-
if (
64-
datasource.find((info) => info.datasource.id === datasourceId) &&
65-
datasourceTypes.find((type) => type.id === datasourceType)
66-
) {
67-
return "";
68-
}
69-
return "error";
70-
}, [datasource, datasourceTypes, datasourceId, datasourceType]);
51+
const datasourceStatus = useDatasourceStatus(datasourceId, datasourceType);
7152

7253
return (
7354
<BottomTabs
@@ -77,7 +58,7 @@ export function QueryPropertyView(props: { comp: InstanceType<typeof QueryComp>
7758
{
7859
key: "general",
7960
title: trans("query.generalTab"),
80-
children: <QueryGeneralPropertyView comp={comp} datasourceStatus={datasourceStatus} />,
61+
children: <QueryGeneralPropertyView comp={comp} />,
8162
},
8263
{
8364
key: "notification",
@@ -160,10 +141,9 @@ export function QueryPropertyView(props: { comp: InstanceType<typeof QueryComp>
160141

161142
export const QueryGeneralPropertyView = (props: {
162143
comp: InstanceType<typeof QueryComp>;
163-
datasourceStatus?: InputStatus;
164144
placement?: PageType;
165145
}) => {
166-
const { datasourceStatus = "", comp, placement = "editor" } = props;
146+
const { comp, placement = "editor" } = props;
167147
const editorState = useContext(EditorContext);
168148
const datasource = useSelector(getDataSource);
169149

@@ -174,6 +154,8 @@ export const QueryGeneralPropertyView = (props: {
174154
const datasourceConfig = datasource.find((d) => d.datasource.id === datasourceId)?.datasource
175155
.datasourceConfig;
176156

157+
const datasourceStatus = useDatasourceStatus(datasourceId, datasourceType);
158+
177159
// transfer old quick REST API datasource to new
178160
const oldQuickRestId = useMemo(
179161
() =>
@@ -361,3 +343,27 @@ export const QueryGeneralPropertyView = (props: {
361343
</QueryPropertyViewWrapper>
362344
);
363345
};
346+
347+
function useDatasourceStatus(datasourceId: string, datasourceType: ResourceType) {
348+
const datasource = useSelector(getDataSource);
349+
const datasourceTypes = useSelector(getDataSourceTypes);
350+
351+
return useMemo(() => {
352+
if (
353+
datasourceType === "js" ||
354+
datasourceType === "libraryQuery" ||
355+
datasourceId === QUICK_REST_API_ID ||
356+
datasourceId === QUICK_GRAPHQL_ID ||
357+
datasourceId === OPENBLOCKS_API_ID
358+
) {
359+
return "";
360+
}
361+
if (
362+
datasource.find((info) => info.datasource.id === datasourceId) &&
363+
datasourceTypes.find((type) => type.id === datasourceType)
364+
) {
365+
return "";
366+
}
367+
return "error";
368+
}, [datasource, datasourceTypes, datasourceId, datasourceType]);
369+
}

client/packages/openblocks/src/pages/editor/AppEditor.tsx

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,48 +68,30 @@ export default function AppEditor() {
6868

6969
// fetch dataSource and plugin
7070
useEffect(() => {
71-
if (orgId) {
72-
if (params.viewMode === "edit") {
73-
dispatch(
74-
fetchDataSourceTypes({
75-
organizationId: orgId,
76-
onSuccess: (dataSourceTypes) => {
77-
dataSourceTypes.forEach((dataSourceType) => {
78-
const { definition } = dataSourceType;
79-
if (!definition) {
80-
return;
81-
}
82-
registryDataSourcePlugin(definition.id, definition);
83-
});
84-
setIsDataSourcePluginRegistered(true);
85-
},
86-
})
87-
);
88-
dispatch(fetchFolderElements({}));
89-
}
90-
}
91-
}, [dispatch, orgId, params.viewMode]);
92-
93-
useEffect(() => {
94-
if (!applicationId) {
95-
return;
96-
}
9771
dispatch(
98-
fetchDataSourceByApp({
99-
applicationId: applicationId,
100-
onSuccess: (dataSources) => {
101-
if (params.viewMode !== "edit") {
102-
dataSources.forEach((dataSource) => {
103-
const plugin = dataSource.datasource.pluginDefinition;
104-
if (plugin) {
105-
registryDataSourcePlugin(plugin.id, plugin);
106-
}
107-
});
108-
setIsDataSourcePluginRegistered(true);
109-
}
72+
fetchDataSourceTypes({
73+
organizationId: "fake",
74+
onSuccess: (dataSourceTypes) => {
75+
dataSourceTypes.forEach((dataSourceType) => {
76+
const { definition } = dataSourceType;
77+
if (!definition) {
78+
return;
79+
}
80+
registryDataSourcePlugin(definition.id, definition);
81+
});
82+
setIsDataSourcePluginRegistered(true);
11083
},
11184
})
11285
);
86+
if (params.viewMode === "edit") {
87+
dispatch(fetchFolderElements({}));
88+
}
89+
}, [dispatch, params.viewMode]);
90+
91+
useEffect(() => {
92+
if (applicationId && params.viewMode === "edit") {
93+
dispatch(fetchDataSourceByApp({ applicationId: applicationId }));
94+
}
11395
}, [dispatch, applicationId, params.viewMode]);
11496

11597
useEffect(() => {

client/packages/openblocks/src/util/bottomResUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getBottomResIconInnerByUrl(type: ResourceType, url: string) {
5353
if (!fullUrl.startsWith("http")) {
5454
fullUrl = `${REACT_APP_API_HOST}/node-service/plugin-icons/${url}`;
5555
}
56-
return <img src={fullUrl} alt="" />;
56+
return <img style={{ width: "100%", height: "100%" }} src={fullUrl} alt="" />;
5757
}
5858

5959
export type BottomResType =

0 commit comments

Comments
 (0)