-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sidharth Mohanty <[email protected]>
- Loading branch information
1 parent
a01277e
commit 445f023
Showing
21 changed files
with
629 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 45 additions & 29 deletions
74
system-apps/app-store/webClient/src/components/UI/AppCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,52 @@ | ||
import React from 'react'; | ||
import { trunc } from '../../utils'; | ||
import { ASSETS_URL } from '../../constants'; | ||
import { Link } from 'react-router-dom'; | ||
import React from "react"; | ||
import { trunc } from "../../utils"; | ||
import { ASSETS_URL } from "../../constants"; | ||
import { Link } from "react-router-dom"; | ||
|
||
type AppProps = { | ||
name: string; | ||
icon: string; | ||
description: string; | ||
publisher: string; | ||
id: string; | ||
name: string; | ||
icon: string; | ||
description: string; | ||
publisher: string; | ||
id: string; | ||
installed: boolean; | ||
}; | ||
|
||
const App: React.FC<AppProps> = ({ name, icon, description, publisher, id }) => { | ||
return ( | ||
<Link to={`/app/${id}`} className={'appContainer'}> | ||
<img className={'appIcon'} src={icon} alt={name} /> | ||
<div className={'appInfoContainer'}> | ||
<div className={'appNameContainer'}> | ||
<span className={'appPublisher'}> | ||
{publisher} | ||
</span> | ||
<span className={'appName'}>{name}</span></div> | ||
<span className={'appDescription'}>{trunc(description, 36)}</span> | ||
<button className={'installButton'}> | ||
<img src={ASSETS_URL + '/download.svg'} width={12} height={12} style={{ | ||
marginRight: '4px', | ||
}} /> | ||
Install | ||
</button> | ||
</div> | ||
</Link> | ||
); | ||
const App: React.FC<AppProps> = ({ | ||
name, | ||
icon, | ||
description, | ||
publisher, | ||
id, | ||
installed, | ||
}) => { | ||
return ( | ||
<Link to={`/app/${id}`} className={"appContainer"}> | ||
<img className={"appIcon"} src={icon} alt={name} /> | ||
<div className={"appInfoContainer"}> | ||
<div className={"appNameContainer"}> | ||
<span className={"appPublisher"}>{publisher}</span> | ||
<span className={"appName"}>{name}</span> | ||
</div> | ||
<span className={"appDescription"}>{trunc(description, 36)}</span> | ||
<button className={"installButton"} disabled={installed}> | ||
<img | ||
src={ | ||
installed | ||
? ASSETS_URL + "/installed.svg" | ||
: ASSETS_URL + "/download.svg" | ||
} | ||
width={14} | ||
height={14} | ||
style={{ | ||
marginRight: "4px", | ||
}} | ||
/> | ||
{installed ? "Installed" : "Install"} | ||
</button> | ||
</div> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { createContext, useContext, useState, useEffect } from "react"; | ||
|
||
type AppsContextType = { | ||
apps: any[]; | ||
}; | ||
|
||
const AppsContext = createContext<AppsContextType | null>(null); | ||
|
||
export const useAppsCtx = () => useContext(AppsContext); | ||
|
||
const AppsProvider: React.FC = ({ children }) => { | ||
const [apps, setApps] = useState([]); | ||
const [installedApps, setInstalledApps] = useState([]); | ||
|
||
// fetch default apps | ||
useEffect(() => { | ||
const fetchApps = async () => { | ||
// TODO: using mock server, need to use nodeserver | ||
const allAppsResponse = await fetch( | ||
"http://localhost:8000/appstore/api/apps" | ||
); | ||
const data = await allAppsResponse.json(); | ||
const installedAppsResponse = await fetch("/plugins?type=all"); | ||
const { pluginDefinitions } = await installedAppsResponse.json(); | ||
const serializedApps = data.map((app) => { | ||
const installedApp = pluginDefinitions.find( | ||
(installedApp) => installedApp.identifier === app.identifier | ||
); | ||
if (installedApp) { | ||
return { | ||
...app, | ||
installed: true, | ||
}; | ||
} | ||
return { | ||
...app, | ||
installed: false, | ||
}; | ||
}); | ||
setInstalledApps(serializedApps.filter((app) => app.installed)); | ||
setApps(serializedApps); | ||
}; | ||
fetchApps(); | ||
}, []); | ||
|
||
return ( | ||
<AppsContext.Provider | ||
value={{ | ||
apps, | ||
installedApps, | ||
}} | ||
> | ||
{children} | ||
</AppsContext.Provider> | ||
); | ||
}; | ||
|
||
export default AppsProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.