2023-01-16 09:45:12 +00:00
|
|
|
import { Button } from "@dashboard/components/Button";
|
|
|
|
import Hr from "@dashboard/components/Hr";
|
2023-01-19 11:54:57 +00:00
|
|
|
import { AppInstallationFragment } from "@dashboard/graphql";
|
2023-01-16 09:45:12 +00:00
|
|
|
import { buttonMessages } from "@dashboard/intl";
|
2023-01-19 11:54:57 +00:00
|
|
|
import { appInstallationStatusMessages } from "@dashboard/new-apps/messages";
|
2023-01-10 10:04:30 +00:00
|
|
|
import { CardActions, Typography } from "@material-ui/core";
|
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage } from "react-intl";
|
|
|
|
|
2023-01-19 11:54:57 +00:00
|
|
|
import InstallErrorAction from "./ErrorInstallAction";
|
2023-01-10 10:04:30 +00:00
|
|
|
import { messages } from "./messages";
|
|
|
|
import { useActionsStyles } from "./styles";
|
|
|
|
|
|
|
|
interface AppListCardActionsProps {
|
|
|
|
releaseDate: string | undefined;
|
2023-01-19 11:54:57 +00:00
|
|
|
installationPending?: boolean;
|
|
|
|
appInstallation?: AppInstallationFragment;
|
2023-01-10 10:04:30 +00:00
|
|
|
installHandler?: () => void;
|
2023-02-07 10:59:06 +00:00
|
|
|
githubForkHandler?: () => void;
|
2023-01-19 11:54:57 +00:00
|
|
|
retryInstallHandler?: () => void;
|
|
|
|
removeInstallHandler?: () => void;
|
2023-01-10 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const AppListCardActions: React.FC<AppListCardActionsProps> = ({
|
|
|
|
releaseDate,
|
2023-01-19 11:54:57 +00:00
|
|
|
installationPending = false,
|
|
|
|
appInstallation,
|
2023-01-10 10:04:30 +00:00
|
|
|
installHandler,
|
2023-02-07 10:59:06 +00:00
|
|
|
githubForkHandler,
|
2023-01-19 11:54:57 +00:00
|
|
|
retryInstallHandler,
|
|
|
|
removeInstallHandler,
|
2023-01-10 10:04:30 +00:00
|
|
|
}) => {
|
|
|
|
const classes = useActionsStyles();
|
|
|
|
|
2023-01-19 11:54:57 +00:00
|
|
|
if (
|
|
|
|
!installHandler &&
|
2023-02-07 10:59:06 +00:00
|
|
|
!githubForkHandler &&
|
2023-01-19 11:54:57 +00:00
|
|
|
!releaseDate &&
|
|
|
|
!retryInstallHandler &&
|
|
|
|
!removeInstallHandler &&
|
|
|
|
!installationPending
|
|
|
|
) {
|
2023-01-10 10:04:30 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Hr />
|
|
|
|
<CardActions className={classes.cardActions}>
|
2023-02-07 10:59:06 +00:00
|
|
|
{githubForkHandler && (
|
2023-01-10 10:04:30 +00:00
|
|
|
<Button
|
|
|
|
variant="secondary"
|
2023-02-07 10:59:06 +00:00
|
|
|
onClick={githubForkHandler}
|
|
|
|
data-test-id="app-fork-on-github-button"
|
2023-01-10 10:04:30 +00:00
|
|
|
>
|
2023-02-07 10:59:06 +00:00
|
|
|
<FormattedMessage {...messages.forkOnGithub} />
|
2023-01-10 10:04:30 +00:00
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
{installHandler && (
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
onClick={installHandler}
|
|
|
|
data-test-id="app-install-button"
|
|
|
|
>
|
|
|
|
<FormattedMessage {...buttonMessages.install} />
|
|
|
|
</Button>
|
|
|
|
)}
|
2023-01-19 11:54:57 +00:00
|
|
|
{installationPending && (
|
|
|
|
<Typography
|
|
|
|
className={classes.cardActionsText}
|
|
|
|
data-test-id="app-installation-pending"
|
|
|
|
>
|
|
|
|
<FormattedMessage {...appInstallationStatusMessages.pending} />
|
|
|
|
</Typography>
|
|
|
|
)}
|
|
|
|
<InstallErrorAction
|
|
|
|
appInstallation={appInstallation}
|
|
|
|
retryInstall={retryInstallHandler}
|
|
|
|
removeInstall={removeInstallHandler}
|
|
|
|
/>
|
2023-01-10 10:04:30 +00:00
|
|
|
{releaseDate && (
|
|
|
|
<Typography className={classes.releaseDate}>
|
|
|
|
<FormattedMessage
|
|
|
|
{...messages.releaseComingSoon}
|
|
|
|
values={{
|
|
|
|
releaseDate,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
)}
|
|
|
|
</CardActions>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
AppListCardActions.displayName = "AppListCardActions";
|
|
|
|
export default AppListCardActions;
|