Skip to content

Dev > Main - Bugfixes - preparation for v2.4.3 #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix infinite loop issue on accessing app view page without permission
  • Loading branch information
raheeliftikhar5 committed Jul 8, 2024
commit 9e14af4c219e455d2972e6b122d19c8afda10040
38 changes: 31 additions & 7 deletions client/packages/lowcoder/src/pages/editor/AppEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppPathParams, AppTypeEnum } from "constants/applicationConstants";
import { Suspense, lazy, useEffect, useRef, useState } from "react";
import { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router";
import { AppSummaryInfo, fetchApplicationInfo } from "redux/reduxActions/applicationActions";
Expand Down Expand Up @@ -30,6 +30,7 @@ import EditorSkeletonView from "./editorSkeletonView";
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
import history from "util/history";
import Flex from "antd/es/flex";

const AppSnapshot = lazy(() => {
return import("pages/editor/appSnapshot")
Expand All @@ -56,6 +57,7 @@ export default function AppEditor() {
const orgId = currentUser.currentOrgId;
const firstRendered = useRef(false);
const [isDataSourcePluginRegistered, setIsDataSourcePluginRegistered] = useState(false);
const [appError, setAppError] = useState('');

setGlobalSettings({ applicationId, isViewMode: paramViewMode === "view" });

Expand Down Expand Up @@ -132,15 +134,37 @@ export default function AppEditor() {
setAppInfo(info);
fetchJSDataSourceByApp();
},
onError: (errorMessage) => {
setAppError(errorMessage);
}
})
);
}, [viewMode, applicationId, dispatch]);
const fallbackUI = (
<div style={{display:'flex', height:'100%', width:'100%', alignItems:'center',justifyContent:'center', gap:'8px',marginTop:'10px'}}>
<p style={{margin:0}}>Something went wrong while displaying this webpage</p>
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Go to Apps</button>
</div>
);

const fallbackUI = useMemo(() => (
<Flex align="center" justify="center" vertical style={{
height: '300px',
width: '400px',
margin: '0 auto',
}}>
<h4 style={{margin: 0}}>Something went wrong while displaying this webpage</h4>
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Go to Apps</button>
</Flex>
), []);

if (Boolean(appError)) {
return (
<Flex align="center" justify="center" vertical style={{
height: '300px',
width: '400px',
margin: '0 auto',
}}>
<h4>{appError}</h4>
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Back to Home</button>
</Flex>
)
}

return (
<ErrorBoundary fallback={fallbackUI}>
{showAppSnapshot ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export type FetchAppInfoPayload = {
applicationId: string;
type: ApplicationDSLType;
onSuccess?: (info: AppSummaryInfo) => void;
onError?: (error: string) => void;
};
export const fetchApplicationInfo = (payload: FetchAppInfoPayload) => ({
type: ReduxActionTypes.FETCH_APPLICATION_DETAIL,
Expand Down
3 changes: 2 additions & 1 deletion client/packages/lowcoder/src/redux/sagas/applicationSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ export function* fetchApplicationDetailSaga(action: ReduxAction<FetchAppInfoPayl
return;
} else if (!isValidResponse) {
if (response.data.code === SERVER_ERROR_CODES.NO_PERMISSION_TO_REQUEST_APP) {
history.push(BASE_URL);
// history.push(BASE_URL);
action.payload.onError?.(response.data.message);
}
throw Error(response.data.message);
}
Expand Down
Loading