Skip to content

Commit 031ac84

Browse files
minimize /permission requests
1 parent 5b45716 commit 031ac84

File tree

3 files changed

+70
-63
lines changed

3 files changed

+70
-63
lines changed

client/packages/lowcoder/src/components/PermissionDialog/AppPermissionDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { SHARE_TITLE } from "../../constants/apiConstants";
3131
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
3232
import { default as Divider } from "antd/es/divider";
3333

34-
export const AppPermissionDialog = (props: {
34+
export const AppPermissionDialog = React.memo((props: {
3535
applicationId: string;
3636
visible: boolean;
3737
onVisibleChange: (visible: boolean) => void;
@@ -148,7 +148,7 @@ export const AppPermissionDialog = (props: {
148148
}
149149
/>
150150
);
151-
};
151+
});
152152

153153
const InviteInputBtn = styled.div`
154154
display: flex;

client/packages/lowcoder/src/pages/common/header.tsx

Lines changed: 66 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from "lowcoder-design";
2626
import { trans } from "i18n";
2727
import dayjs from "dayjs";
28-
import { useContext, useState } from "react";
28+
import { useContext, useEffect, useMemo, useState } from "react";
2929
import { useDispatch, useSelector } from "react-redux";
3030
import {
3131
publishApplication,
@@ -453,67 +453,74 @@ export default function Header(props: HeaderProps) {
453453
</>
454454
);
455455

456-
const headerEnd = showAppSnapshot ? (
457-
<HeaderProfile user={user} />
458-
) : (
459-
<>
460-
{applicationId && (
461-
<AppPermissionDialog
462-
applicationId={applicationId}
463-
visible={permissionDialogVisible}
464-
onVisibleChange={(visible) =>
465-
!visible && setPermissionDialogVisible(false)
466-
}
467-
/>
468-
)}
469-
{canManageApp(user, application) && (
470-
<GrayBtn onClick={() => setPermissionDialogVisible(true)}>
471-
{SHARE_TITLE}
472-
</GrayBtn>
473-
)}
474-
<PreviewBtn buttonType="primary" onClick={() => preview(applicationId)}>
475-
{trans("header.preview")}
476-
</PreviewBtn>
477-
478-
<Dropdown
479-
className="cypress-header-dropdown"
480-
placement="bottomRight"
481-
trigger={["click"]}
482-
dropdownRender={() => (
483-
<DropdownMenuStyled
484-
style={{ minWidth: "110px", borderRadius: "4px" }}
485-
onClick={(e) => {
486-
if (e.key === "deploy") {
487-
dispatch(publishApplication({ applicationId }));
488-
} else if (e.key === "snapshot") {
489-
dispatch(setShowAppSnapshot(true));
490-
}
491-
}}
492-
items={[
493-
{
494-
key: "deploy",
495-
label: (
496-
<CommonTextLabel>{trans("header.deploy")}</CommonTextLabel>
497-
),
498-
},
499-
{
500-
key: "snapshot",
501-
label: (
502-
<CommonTextLabel>{trans("header.snapshot")}</CommonTextLabel>
503-
),
504-
},
505-
]}
456+
const headerEnd = useMemo(() => {
457+
return showAppSnapshot ? (
458+
<HeaderProfile user={user} />
459+
) : (
460+
<>
461+
{applicationId && (
462+
<AppPermissionDialog
463+
applicationId={applicationId}
464+
visible={permissionDialogVisible}
465+
onVisibleChange={(visible) =>
466+
!visible && setPermissionDialogVisible(false)
467+
}
506468
/>
507469
)}
508-
>
509-
<PackUpBtn buttonType="primary">
510-
<PackUpIcon />
511-
</PackUpBtn>
512-
</Dropdown>
470+
{canManageApp(user, application) && (
471+
<GrayBtn onClick={() => setPermissionDialogVisible(true)}>
472+
{SHARE_TITLE}
473+
</GrayBtn>
474+
)}
475+
<PreviewBtn buttonType="primary" onClick={() => preview(applicationId)}>
476+
{trans("header.preview")}
477+
</PreviewBtn>
478+
479+
<Dropdown
480+
className="cypress-header-dropdown"
481+
placement="bottomRight"
482+
trigger={["click"]}
483+
dropdownRender={() => (
484+
<DropdownMenuStyled
485+
style={{ minWidth: "110px", borderRadius: "4px" }}
486+
onClick={(e) => {
487+
if (e.key === "deploy") {
488+
dispatch(publishApplication({ applicationId }));
489+
} else if (e.key === "snapshot") {
490+
dispatch(setShowAppSnapshot(true));
491+
}
492+
}}
493+
items={[
494+
{
495+
key: "deploy",
496+
label: (
497+
<CommonTextLabel>{trans("header.deploy")}</CommonTextLabel>
498+
),
499+
},
500+
{
501+
key: "snapshot",
502+
label: (
503+
<CommonTextLabel>{trans("header.snapshot")}</CommonTextLabel>
504+
),
505+
},
506+
]}
507+
/>
508+
)}
509+
>
510+
<PackUpBtn buttonType="primary">
511+
<PackUpIcon />
512+
</PackUpBtn>
513+
</Dropdown>
513514

514-
<HeaderProfile user={user} />
515-
</>
516-
);
515+
<HeaderProfile user={user} />
516+
</>
517+
);
518+
}, [
519+
user,
520+
showAppSnapshot,
521+
applicationId,
522+
permissionDialogVisible,
523+
]);
517524

518525
return (
519526
<LayoutHeader

client/packages/lowcoder/src/pages/editor/editorSkeletonView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ export default function EditorSkeletonView() {
5959
return (
6060
<>
6161
<Height100Div>
62-
<Header
62+
{/* <Header
6363
panelStatus={panelStatus}
6464
togglePanel={_.noop}
6565
editorModeStatus={editorModeStatus}
6666
toggleEditorModeStatus={_.noop}
67-
/>
67+
/> */}
6868
<Body>
6969
<SiderStyled />
7070
{panelStatus.left && (

0 commit comments

Comments
 (0)