2023-03-06 09:57:25 +00:00
|
|
|
import { useAppListContext } from "@dashboard/apps/context";
|
|
|
|
import { GetV2SaleorAppsResponse } from "@dashboard/apps/marketplace.types";
|
|
|
|
import { getAppDetails } from "@dashboard/apps/utils";
|
2023-01-19 11:54:57 +00:00
|
|
|
import { AppInstallationFragment } from "@dashboard/graphql";
|
2023-02-20 15:21:28 +00:00
|
|
|
import { Box } from "@saleor/macaw-ui/next";
|
2023-01-10 10:04:30 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import AppListCardActions from "./AppListCardActions";
|
|
|
|
import AppListCardDescription from "./AppListCardDescription";
|
|
|
|
import AppListCardIntegrations from "./AppListCardIntegrations";
|
|
|
|
import AppListCardLinks from "./AppListCardLinks";
|
|
|
|
|
|
|
|
interface AppListCardProps {
|
|
|
|
app: GetV2SaleorAppsResponse.SaleorApp;
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation?: AppInstallationFragment;
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage?: (manifestUrl: string) => void;
|
2023-02-07 10:59:06 +00:00
|
|
|
navigateToGithubForkPage?: (githubForkUrl: string) => void;
|
2023-01-10 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const AppListCard: React.FC<AppListCardProps> = ({
|
|
|
|
app,
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation,
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage,
|
2023-02-07 10:59:06 +00:00
|
|
|
navigateToGithubForkPage,
|
2023-01-10 10:04:30 +00:00
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
2023-01-19 11:54:57 +00:00
|
|
|
const { retryAppInstallation, removeAppInstallation } = useAppListContext();
|
2023-01-10 10:04:30 +00:00
|
|
|
|
2023-01-19 11:54:57 +00:00
|
|
|
const details = getAppDetails({
|
2023-01-10 10:04:30 +00:00
|
|
|
intl,
|
|
|
|
app,
|
2023-01-19 11:54:57 +00:00
|
|
|
appInstallation,
|
2023-01-10 10:04:30 +00:00
|
|
|
navigateToAppInstallPage,
|
2023-02-07 10:59:06 +00:00
|
|
|
navigateToGithubForkPage,
|
2023-01-19 11:54:57 +00:00
|
|
|
retryAppInstallation,
|
|
|
|
removeAppInstallation,
|
|
|
|
});
|
2023-01-10 10:04:30 +00:00
|
|
|
|
|
|
|
return (
|
2023-02-20 15:21:28 +00:00
|
|
|
<Box
|
|
|
|
display="flex"
|
|
|
|
flexDirection="column"
|
|
|
|
justifyContent="space-between"
|
|
|
|
borderStyle="solid"
|
|
|
|
borderWidth={1}
|
|
|
|
padding={8}
|
|
|
|
borderRadius={3}
|
|
|
|
borderColor="neutralPlain"
|
|
|
|
>
|
|
|
|
<Box>
|
|
|
|
<AppListCardDescription app={app} />
|
|
|
|
<AppListCardLinks links={details.links} />
|
2023-03-10 08:08:08 +00:00
|
|
|
<AppListCardIntegrations app={app} />
|
2023-02-20 15:21:28 +00:00
|
|
|
</Box>
|
|
|
|
<Box>
|
2023-01-10 10:04:30 +00:00
|
|
|
<AppListCardActions
|
|
|
|
releaseDate={details.releaseDate}
|
2023-01-19 11:54:57 +00:00
|
|
|
installationPending={details.installationPending}
|
2023-01-10 10:04:30 +00:00
|
|
|
installHandler={details.installHandler}
|
2023-02-07 10:59:06 +00:00
|
|
|
githubForkHandler={details.githubForkHandler}
|
2023-01-19 11:54:57 +00:00
|
|
|
retryInstallHandler={details.retryInstallHandler}
|
|
|
|
removeInstallHandler={details.removeInstallHandler}
|
2023-01-10 10:04:30 +00:00
|
|
|
/>
|
2023-02-20 15:21:28 +00:00
|
|
|
</Box>
|
|
|
|
</Box>
|
2023-01-10 10:04:30 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
AppListCard.displayName = "AppListCard";
|
|
|
|
export default AppListCard;
|