Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita087797

Browse files
separate marketplace apps in self hosting env
1 parent5295375 commita087797

File tree

8 files changed

+114
-20
lines changed

8 files changed

+114
-20
lines changed
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 16 additions & 0 deletions
Loading

‎client/packages/lowcoder-design/src/icons/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ export { ReactComponent as HomeQueryLibraryIcon } from "./icon-application-query
177177
export{ReactComponentasHomeDataSourceIcon}from"./icon-application-datasource.svg";
178178
export{ReactComponentasRecyclerIcon}from"./icon-application-recycler.svg";
179179
export{ReactComponentasMarketplaceIcon}from"./icon-application-marketplace.svg";
180+
export{ReactComponentasLowcoderMarketplaceIcon}from"./icon-lowcoder-marketplace.svg";
180181
export{ReactComponentasHomeActiveIcon}from"./icon-application-home-active.svg";
181182
export{ReactComponentasHomeModuleActiveIcon}from"./icon-application-module-active.svg";
182183
export{ReactComponentasHomeQueryLibraryActiveIcon}from"./icon-application-query-library-active.svg";
183184
export{ReactComponentasHomeDataSourceActiveIcon}from"./icon-application-datasource-active.svg";
184185
export{ReactComponentasRecyclerActiveIcon}from"./icon-application-recycler-active.svg";
185186
export{ReactComponentasMarketplaceActiveIcon}from"./icon-application-marketplace-active.svg";
187+
export{ReactComponentasLowcoderMarketplaceActiveIcon}from"./icon-lowcoder-marketplace-active.svg";
186188
export{ReactComponentasFavoritesIcon}from"./icon-application-favorites.svg";
187189
export{ReactComponentasHomeSettingIcon}from"./icon-application-setting.svg";
188190
export{ReactComponentasFolderIcon}from"./icon-application-folder.svg";

‎client/packages/lowcoder/src/app.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
IMPORT_APP_FROM_TEMPLATE_URL,
1515
INVITE_LANDING_URL,
1616
isAuthUnRequired,
17+
MARKETPLACE_TYPE_URL,
1718
MARKETPLACE_URL,
1819
ORG_AUTH_LOGIN_URL,
1920
ORG_AUTH_REGISTER_URL,

‎client/packages/lowcoder/src/constants/applicationConstants.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,5 @@ export type AppSnapshotList = {
115115
count:number;// total count
116116
list:AppSnapshot[];
117117
};
118+
119+
exporttypeMarketplaceType="local"|"lowcoder";

‎client/packages/lowcoder/src/constants/routesURL.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{AppViewMode}from"constants/applicationConstants";
1+
import{AppViewMode,MarketplaceType}from"constants/applicationConstants";
22
import{LocationDescriptor}from"history";
33
import{UserGuideLocationState}from"pages/tutorials/tutorialsConstant";
44
import{DatasourceType}from"@lowcoder-ee/constants/queryConstants";
@@ -43,10 +43,14 @@ export const LDAP_AUTH_LOGIN_URL = `${USER_AUTH_URL}/ldap/login`;
4343
exportconstINVITE_LANDING_URL="/invite/:invitationId";
4444
exportconstORG_AUTH_LOGIN_URL=`/org/:orgId/auth/login`;
4545
exportconstORG_AUTH_REGISTER_URL=`/org/:orgId/auth/register`;
46+
exportconstMARKETPLACE_TYPE_URL=`${MARKETPLACE_URL}/:marketplaceType`;
4647

4748
exportconstAPPLICATION_VIEW_URL=(appId:string,viewMode:AppViewMode)=>
4849
`${ALL_APPLICATIONS_URL}/${appId}/${viewMode}`;
4950

51+
exportconstMARKETPLACE_URL_BY_TYPE=(type:MarketplaceType)=>
52+
`${MARKETPLACE_URL}/${type}`;
53+
5054
exportconstisAuthUnRequired=(pathname:string):boolean=>{
5155
return(
5256
pathname.startsWith("/invite/")||

‎client/packages/lowcoder/src/pages/ApplicationV2/MarketplaceView.tsx‎

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,66 @@
11
import{useEffect,useState}from"react";
2-
import{useDispatch,useSelector}from"react-redux";
32
import{HomeLayout}from"./HomeLayout";
4-
import{MARKETPLACE_URL}from"constants/routesURL";
5-
import{marketplaceSelector}from"redux/selectors/applicationSelector";
6-
import{fetchAllMarketplaceApps}from"redux/reduxActions/applicationActions";
3+
import{MARKETPLACE_TYPE_URL,MARKETPLACE_URL}from"constants/routesURL";
74
import{trans}from"../../i18n";
5+
importaxios,{AxiosResponse}from"axios";
6+
importApplicationApifrom"@lowcoder-ee/api/applicationApi";
7+
import{ApplicationMeta,MarketplaceType}from"@lowcoder-ee/constants/applicationConstants";
8+
import{GenericApiResponse}from"@lowcoder-ee/api/apiResponses";
9+
import{validateResponse}from"@lowcoder-ee/api/apiUtils";
10+
import{messageInstance}from"lowcoder-design";
11+
import{matchPath}from"react-router";
12+
importlogfrom"loglevel";
813

914
exportfunctionMarketplaceView(){
10-
const[haveFetchedApps,setHaveFetchApps]=useState<boolean>(false);
15+
const[marketplaceApps,setMarketplaceApps]=useState<Array<ApplicationMeta>>([]);
16+
constmarketplaceType=matchPath<{marketplaceType?:MarketplaceType}>(window.location.pathname,MARKETPLACE_TYPE_URL)?.params
17+
.marketplaceType;
18+
constisLowcoderMarketplace=marketplaceType==='lowcoder';
19+
constmarketplaceBreadcrumbText=!marketplaceType?.length
20+
?trans("home.marketplace")
21+
:marketplaceType==='lowcoder'
22+
?`${trans("home.marketplace")} (Lowcoder)`
23+
:`${trans("home.marketplace")} (Local)`;
1124

12-
constdispatch=useDispatch();
13-
constmarketplaceApps=useSelector(marketplaceSelector);
25+
constfetchLowcoderMarketplaceApps=()=>{
26+
consthttp=axios.create({
27+
baseURL:'https://api-service.lowcoder.cloud',
28+
withCredentials:false,
29+
});
30+
returnhttp.get(`/api/v1/applications/marketplace-apps`);
31+
};
1432

15-
useEffect(()=>{
16-
if(!marketplaceApps.length&&!haveFetchedApps){
17-
dispatch(fetchAllMarketplaceApps());
18-
setHaveFetchApps(true);
33+
constfetchLocalMarketplaceApps=()=>{
34+
returnApplicationApi.fetchAllMarketplaceApps()
35+
}
36+
37+
constfetchMarketplaceApps=async()=>{
38+
try{
39+
letresponse:AxiosResponse<GenericApiResponse<ApplicationMeta[]>>;
40+
if(isLowcoderMarketplace){
41+
response=awaitfetchLowcoderMarketplaceApps();
42+
}else{
43+
response=awaitfetchLocalMarketplaceApps();
44+
}
45+
46+
constisValidResponse:boolean=validateResponse(response);
47+
if(isValidResponse){
48+
setMarketplaceApps(response.data.data);
49+
}
50+
}catch(error:any){
51+
messageInstance.error(error.message);
52+
log.debug("fetch marketplace apps error: ",error);
1953
}
20-
},[]);
54+
}
2155

2256
useEffect(()=>{
23-
if(marketplaceApps.length){
24-
setHaveFetchApps(true);
25-
}
26-
},[marketplaceApps])
57+
fetchMarketplaceApps();
58+
},[marketplaceType]);
2759

2860
return(
2961
<HomeLayout
3062
elements={marketplaceApps}
31-
breadcrumb={[{text:trans("home.marketplace"),path:MARKETPLACE_URL}]}
63+
breadcrumb={[{text:marketplaceBreadcrumbText,path:MARKETPLACE_URL}]}
3264
mode={"marketplace"}
3365
/>
3466
);

‎client/packages/lowcoder/src/pages/ApplicationV2/index.tsx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
FOLDER_URL_PREFIX,
66
FOLDERS_URL,
77
MARKETPLACE_URL,
8+
MARKETPLACE_URL_BY_TYPE,
89
MODULE_APPLICATIONS_URL,
910
QUERY_LIBRARY_URL,
1011
SETTING,
@@ -33,6 +34,8 @@ import {
3334
RecyclerIcon,
3435
MarketplaceIcon,
3536
MarketplaceActiveIcon,
37+
LowcoderMarketplaceActiveIcon,
38+
LowcoderMarketplaceIcon,
3639
}from"lowcoder-design";
3740
importReact,{useEffect,useState}from"react";
3841
import{fetchAllApplications,fetchHomeData}from"redux/reduxActions/applicationActions";
@@ -245,6 +248,7 @@ export default function ApplicationHome() {
245248
constallAppCount=allApplications.length;
246249
constallFoldersCount=allFolders.length;
247250
constorgHomeId="root";
251+
constisSelfHost=window.location.host!=='app.lowcoder.cloud';
248252

249253
consthandleFolderCreate=useCreateFolder();
250254

@@ -357,8 +361,16 @@ export default function ApplicationHome() {
357361
visible:({ user})=>user.orgDev,
358362
},
359363
{
360-
text:<TabLabel>{trans("home.marketplace")}</TabLabel>,
361-
routePath:MARKETPLACE_URL,
364+
text:(
365+
<TabLabel>
366+
{
367+
isSelfHost
368+
?`${trans("home.marketplace")} (Local)`
369+
:trans("home.marketplace")
370+
}
371+
</TabLabel>
372+
),
373+
routePath:isSelfHost ?MARKETPLACE_URL_BY_TYPE('local') :MARKETPLACE_URL,
362374
routePathExact:false,
363375
routeComp:MarketplaceView,
364376
icon:({ selected, ...otherProps})=>
@@ -369,6 +381,19 @@ export default function ApplicationHome() {
369381
),
370382
visible:({ user})=>user.orgDev,
371383
},
384+
{
385+
text:<TabLabel>{`${trans("home.marketplace")} (Lowcoder)`}</TabLabel>,
386+
routePath:MARKETPLACE_URL_BY_TYPE('lowcoder'),
387+
routePathExact:false,
388+
routeComp:MarketplaceView,
389+
icon:({ selected, ...otherProps})=>
390+
selected ?(
391+
<LowcoderMarketplaceActiveIcon{...otherProps}/>
392+
) :(
393+
<LowcoderMarketplaceIcon{...otherProps}/>
394+
),
395+
visible:({ user})=>user.orgDev&&isSelfHost,
396+
},
372397
{
373398
text:<TabLabel>{trans("home.trash")}</TabLabel>,
374399
routePath:TRASH_URL,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp