Skip to content
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

Display Fix for Marketplaces #712

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Changes from all commits
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
53 changes: 37 additions & 16 deletions client/packages/lowcoder/src/pages/ApplicationV2/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { isFetchingFolderElements } from "../../redux/selectors/folderSelector";
import { checkIsMobile } from "util/commonUtils";
import MarketplaceHeaderImage from "assets/images/marketplaceHeaderImage.jpg";
import { Divider } from "antd";
import { Margin } from "../setting/theme/styledComponents";
import { Margin } from "../setting/theme/styledComponents";

const Wrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -239,6 +239,7 @@ const LayoutSwitcher = styled.div`
}
`;


function showNewUserGuide(user: User) {
return (
user.orgDev &&
Expand Down Expand Up @@ -278,7 +279,7 @@ export function HomeLayout(props: HomeLayoutProps) {
const { breadcrumb = [], elements = [], localMarketplaceApps = [], globalMarketplaceApps = [],mode } = props;
const user = useSelector(getUser);
const isFetching = useSelector(isFetchingFolderElements);

const isSelfHost = window.location.host !== 'app.lowcoder.cloud';
const [filterBy, setFilterBy] = useState<HomeResKey>("All");
const [searchValue, setSearchValue] = useState("");
const [layout, setLayout] = useState<HomeLayoutType>(
Expand All @@ -294,14 +295,16 @@ export function HomeLayout(props: HomeLayoutProps) {
}

var displayElements = elements;
if (mode === "marketplace") {
if (mode === "marketplace" && isSelfHost) {
const markedLocalApps = localMarketplaceApps.map(app => ({ ...app, isLocalMarketplace: true }));
const markedGlobalApps = globalMarketplaceApps.map(app => ({ ...app, isLocalMarketplace: false }));
// Merge local and global apps into the elements array
displayElements = [...markedLocalApps, ...markedGlobalApps];
}

console.log("HomeLayout: displayElements", displayElements);
else if (mode === "marketplace") {
const markedLocalApps = localMarketplaceApps.map(app => ({ ...app, isLocalMarketplace: true }));
displayElements = [...markedLocalApps];
}

const resList: HomeRes[] = displayElements
.filter((e) =>
Expand Down Expand Up @@ -454,19 +457,37 @@ export function HomeLayout(props: HomeLayoutProps) {
<>
{layout === "list" ? (
<>
<h2 style={{padding: "0 36px"}}>{trans("home.localMarketplaceTitle")}</h2>
<HomeTableView resources={resList.filter(app => app.isLocalMarketplace)} />
<Divider style={{padding: "0 36px", margin: "0 36px", width: "calc(100% - 72px) !important"}}/>
<h2 style={{padding: "0 36px"}}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeTableView resources={resList.filter(app => !app.isLocalMarketplace)} />
{isSelfHost ? (
<>
<h2 style={{ padding: "0 36px" }}>{trans("home.localMarketplaceTitle")}</h2>
<HomeTableView resources={resList.filter(app => app.isLocalMarketplace)} />
<Divider style={{ padding: "0 36px", margin: "0 36px", width: "calc(100% - 72px) !important" }} />
<h2 style={{ padding: "0 36px" }}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeTableView resources={resList.filter(app => !app.isLocalMarketplace)} />
</>
) : (
<>
<h2 style={{padding: "0 36px"}}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeTableView resources={resList.filter(app => app.isLocalMarketplace)} />
</>
)}
</>
) : (
<>
<h2 style={{padding: "0 36px"}}>{trans("home.localMarketplaceTitle")}</h2>
<HomeCardView resources={resList.filter(app => app.isLocalMarketplace)} />
<Divider style={{padding: "0 36px", margin: "12px 36px", width: "calc(100% - 72px) !important"}}/>
<h2 style={{padding: "0 36px"}}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeCardView resources={resList.filter(app => !app.isLocalMarketplace)} />
<>
{isSelfHost ? (
<>
<h2 style={{padding: "0 36px"}}>{trans("home.localMarketplaceTitle")}</h2>
<HomeCardView resources={resList.filter(app => app.isLocalMarketplace)} />
<Divider style={{padding: "0 36px", margin: "12px 36px", width: "calc(100% - 72px) !important"}}/>
<h2 style={{padding: "0 36px"}}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeCardView resources={resList.filter(app => !app.isLocalMarketplace)} />
</>
) : (
<>
<h2 style={{padding: "0 36px"}}>{trans("home.globalMarketplaceTitle")}</h2>
<HomeCardView resources={resList.filter(app => app.isLocalMarketplace)} />
</>
)}
</>
)}
</>
Expand Down
Loading