Skip to content

Commit 606a9d1

Browse files
update app editor to view marketplace app
1 parent 3ff918e commit 606a9d1

File tree

8 files changed

+81
-37
lines changed

8 files changed

+81
-37
lines changed

client/packages/lowcoder/src/pages/ApplicationV2/HomeLayout.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ export interface HomeRes {
238238
isEditable?: boolean;
239239
isManageable: boolean;
240240
isDeletable: boolean;
241+
isMarketplace?: boolean;
241242
}
242243

243244
export type HomeBreadcrumbType = { text: string; path: string };
244245

245-
export type HomeLayoutMode = "view" | "trash" | "module" | "folder" | "folders";
246+
export type HomeLayoutMode = "view" | "trash" | "module" | "folder" | "folders" | "marketplace";
246247

247248
export interface HomeLayoutProps {
248249
breadcrumb?: HomeBreadcrumbType[];
@@ -306,11 +307,12 @@ export function HomeLayout(props: HomeLayoutProps) {
306307
id: e.applicationId,
307308
name: e.name,
308309
type: HomeResTypeEnum[HomeResTypeEnum[e.applicationType] as HomeResKey],
309-
creator: e.createBy,
310+
creator: e?.creatorEmail ?? e.createBy,
310311
lastModifyTime: e.lastModifyTime,
311-
isEditable: canEditApp(user, e),
312-
isManageable: canManageApp(user, e),
313-
isDeletable: canEditApp(user, e),
312+
isEditable: mode !== 'marketplace' && canEditApp(user, e),
313+
isManageable: mode !== 'marketplace' && canManageApp(user, e),
314+
isDeletable: mode !== 'marketplace' && canEditApp(user, e),
315+
isMarketplace: mode === 'marketplace',
314316
}
315317
);
316318

@@ -387,7 +389,7 @@ export function HomeLayout(props: HomeLayoutProps) {
387389
onChange={(e) => setSearchValue(e.target.value)}
388390
style={{ width: "192px", height: "32px", margin: "0" }}
389391
/>
390-
{mode !== "trash" && user.orgDev && (
392+
{mode !== "trash" && mode !== "marketplace" && user.orgDev && (
391393
<CreateDropdown defaultVisible={showNewUserGuide(user)} mode={mode} />
392394
)}
393395
</OperationRightWrapper>
@@ -421,11 +423,13 @@ export function HomeLayout(props: HomeLayoutProps) {
421423
<div style={{ marginBottom: "16px" }}>
422424
{mode === "trash"
423425
? trans("home.trashEmpty")
426+
: mode === "marketplace"
427+
? "No apps in marketplace yet"
424428
: user.orgDev
425429
? trans("home.projectEmptyCanAdd")
426430
: trans("home.projectEmpty")}
427431
</div>
428-
{mode !== "trash" && user.orgDev && <CreateDropdown mode={mode} />}
432+
{mode !== "trash" && mode !== "marketplace" && user.orgDev && <CreateDropdown mode={mode} />}
429433
</EmptyView>
430434
)}
431435
</>

client/packages/lowcoder/src/pages/ApplicationV2/HomeResCard.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
handleAppEditClick,
1212
handleAppViewClick,
1313
handleFolderViewClick,
14+
handleMarketplaceAppViewClick,
1415
HomeResInfo,
1516
} from "../../util/homeResUtils";
1617
import { HomeResOptions } from "./HomeResOptions";
@@ -167,6 +168,7 @@ export function HomeResCard(props: { res: HomeRes; onMove: (res: HomeRes) => voi
167168
)}
168169
<CardInfo
169170
onClick={(e) => {
171+
console.log(res.isMarketplace);
170172
if (appNameEditing) {
171173
return;
172174
}
@@ -177,6 +179,10 @@ export function HomeResCard(props: { res: HomeRes; onMove: (res: HomeRes) => voi
177179
history.push(APPLICATION_VIEW_URL(res.id, "view"));
178180
return;
179181
}
182+
if(res.isMarketplace) {
183+
handleMarketplaceAppViewClick(res.id);
184+
return;
185+
}
180186
res.isEditable ? handleAppEditClick(e, res.id) : handleAppViewClick(res.id);
181187
}
182188
}}
@@ -211,6 +217,8 @@ export function HomeResCard(props: { res: HomeRes; onMove: (res: HomeRes) => voi
211217
onClick={() =>
212218
res.type === HomeResTypeEnum.Folder
213219
? handleFolderViewClick(res.id)
220+
: res.isMarketplace
221+
? handleMarketplaceAppViewClick(res.id)
214222
: handleAppViewClick(res.id)
215223
}
216224
>

client/packages/lowcoder/src/pages/ApplicationV2/HomeTableView.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
handleAppEditClick,
88
handleAppViewClick,
99
handleFolderViewClick,
10+
handleMarketplaceAppViewClick,
1011
HomeResInfo,
1112
} from "../../util/homeResUtils";
1213
import { HomeResTypeEnum } from "../../types/homeRes";
@@ -75,6 +76,8 @@ export const HomeTableView = (props: { resources: HomeRes[] }) => {
7576
}
7677
if (item.type === HomeResTypeEnum.Folder) {
7778
handleFolderViewClick(item.id);
79+
} else if(item.isMarketplace) {
80+
handleMarketplaceAppViewClick(item.id);
7881
} else {
7982
item.isEditable ? handleAppEditClick(e, item.id) : handleAppViewClick(item.id);
8083
}
@@ -209,6 +212,8 @@ export const HomeTableView = (props: { resources: HomeRes[] }) => {
209212
e.stopPropagation();
210213
return item.type === HomeResTypeEnum.Folder
211214
? handleFolderViewClick(item.id)
215+
: item.isMarketplace
216+
? handleMarketplaceAppViewClick(item.id)
212217
: handleAppViewClick(item.id);
213218
}}
214219
style={{ marginRight: "52px" }}

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

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "lowcoder-design";
1212
import { trans, transToNode } from "i18n";
1313
import { exportApplicationAsJSONFile } from "pages/ApplicationV2/components/AppImport";
14-
import { useContext, useState } from "react";
14+
import { useContext, useMemo, useState } from "react";
1515
import { useDispatch, useSelector } from "react-redux";
1616
import { currentApplication } from "redux/selectors/applicationSelector";
1717
import { showAppSnapshotSelector } from "redux/selectors/appSnapshotSelector";
@@ -23,6 +23,8 @@ import { recycleApplication } from "redux/reduxActions/applicationActions";
2323
import { CopyModal } from "./copyModal";
2424
import { ExternalEditorContext } from "util/context/ExternalEditorContext";
2525
import { messageInstance } from "lowcoder-design";
26+
import { getUser } from "redux/selectors/usersSelectors";
27+
import { canEditApp } from "util/permissionUtils";
2628

2729
const PackUpIconStyled = styled(PackUpIcon)`
2830
transform: rotate(180deg);
@@ -68,6 +70,7 @@ export const TypeName = {
6870
};
6971

7072
export function HeaderStartDropdown(props: { setEdit: () => void }) {
73+
const user = useSelector(getUser);
7174
const showAppSnapshot = useSelector(showAppSnapshotSelector);
7275
const applicationId = useApplicationId();
7376
const application = useSelector(currentApplication);
@@ -76,6 +79,37 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
7679
const { appType } = useContext(ExternalEditorContext);
7780
const isModule = appType === AppTypeEnum.Module;
7881

82+
const isEditable = canEditApp(user, application);
83+
84+
const menuItems = useMemo(() => ([
85+
{
86+
key: "edit",
87+
label: <CommonTextLabel>{trans("header.editName")}</CommonTextLabel>,
88+
visible: isEditable,
89+
},
90+
{
91+
key: "export",
92+
label: <CommonTextLabel>{trans("header.export")}</CommonTextLabel>,
93+
visible: true,
94+
},
95+
{
96+
key: "duplicate",
97+
label: (
98+
<CommonTextLabel>
99+
{trans("header.duplicate", {
100+
type: TypeName[application?.applicationType!]?.toLowerCase(),
101+
})}
102+
</CommonTextLabel>
103+
),
104+
visible: true,
105+
},
106+
{
107+
key: "delete",
108+
label: <CommonTextLabelDelete>{trans("home.moveToTrash")}</CommonTextLabelDelete>,
109+
visible: isEditable,
110+
},
111+
]), [isEditable]);
112+
79113
return (
80114
<>
81115
<DropdownStyled
@@ -115,30 +149,7 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
115149
});
116150
}
117151
}}
118-
items={[
119-
{
120-
key: "edit",
121-
label: <CommonTextLabel>{trans("header.editName")}</CommonTextLabel>,
122-
},
123-
{
124-
key: "export",
125-
label: <CommonTextLabel>{trans("header.export")}</CommonTextLabel>,
126-
},
127-
{
128-
key: "duplicate",
129-
label: (
130-
<CommonTextLabel>
131-
{trans("header.duplicate", {
132-
type: TypeName[application?.applicationType!]?.toLowerCase(),
133-
})}
134-
</CommonTextLabel>
135-
),
136-
},
137-
{
138-
key: "delete",
139-
label: <CommonTextLabelDelete>{trans("home.moveToTrash")}</CommonTextLabelDelete>,
140-
},
141-
]}
152+
items={menuItems.filter(item => item.visible)}
142153
/>
143154
)}
144155
>

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { Logo } from "@lowcoder-ee/assets/images";
1717
import { AppPermissionDialog } from "../../components/PermissionDialog/AppPermissionDialog";
1818
import { useState } from "react";
1919
import { getBrandingConfig } from "../../redux/selectors/configSelectors";
20+
import { HeaderStartDropdown } from "./headerStartDropdown";
21+
import { useParams } from "react-router";
22+
import { AppPathParams } from "constants/applicationConstants";
2023

2124
const HeaderFont = styled.div<{ $bgColor: string }>`
2225
font-weight: 500;
@@ -125,21 +128,32 @@ export function HeaderProfile(props: { user: User }) {
125128
}
126129

127130
export const PreviewHeader = () => {
131+
const params = useParams<AppPathParams>();
128132
const user = useSelector(getUser);
129133
const application = useSelector(currentApplication);
130134
const applicationId = useApplicationId();
131135
const templateId = useSelector(getTemplateId);
132136
const brandingConfig = useSelector(getBrandingConfig);
133137
const [permissionDialogVisible, setPermissionDialogVisible] = useState(false);
138+
const isViewMarketplaceMode = params.viewMode === 'view_marketplace';
134139

135140
const headerStart = (
136141
<>
137142
<StyledLink onClick={() => history.push(ALL_APPLICATIONS_URL)}>
138143
<LogoIcon branding={true} />
139144
</StyledLink>
140-
<HeaderFont $bgColor={brandingConfig?.headerColor ?? "#2c2c2c"}>
141-
{application && application.name}
142-
</HeaderFont>
145+
{isViewMarketplaceMode && (
146+
<HeaderStartDropdown
147+
setEdit={() => {
148+
149+
}}
150+
/>
151+
)}
152+
{!isViewMarketplaceMode && (
153+
<HeaderFont $bgColor={brandingConfig?.headerColor ?? "#2c2c2c"}>
154+
{application && application.name}
155+
</HeaderFont>
156+
)}
143157
</>
144158
);
145159

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function AppEditor() {
3333
const isUserViewMode = useUserViewMode();
3434
const params = useParams<AppPathParams>();
3535
const applicationId = params.applicationId;
36-
const viewMode = params.viewMode === "view" ? "published" : "editing";
36+
const viewMode = params.viewMode === "view" ? "published" : params.viewMode === "view_marketplace" ? "view_marketplace" : "editing";
3737
const currentUser = useSelector(getUser);
3838
const dispatch = useDispatch();
3939
const fetchOrgGroupsFinished = useSelector(getFetchOrgGroupsFinished);

client/packages/lowcoder/src/util/homeResUtils.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ export const handleAppEditClick = (e: any, id: string): void => {
5858

5959
export const handleAppViewClick = (id: string) => window.open(APPLICATION_VIEW_URL(id, "view"));
6060

61+
export const handleMarketplaceAppViewClick = (id: string) => window.open(APPLICATION_VIEW_URL(id, "view_marketplace"));
62+
6163
export const handleFolderViewClick = (id: string) => history.push(buildFolderUrl(id));

client/packages/lowcoder/src/util/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function isUserViewMode(params?: AppPathParams) {
2525
return false;
2626
}
2727
const { viewMode } = params;
28-
return viewMode === "preview" || viewMode === "view";
28+
return viewMode === "preview" || viewMode === "view" || viewMode === "view_marketplace";
2929
}
3030

3131
/**

0 commit comments

Comments
 (0)