Add style to deployment logs dialog

This commit is contained in:
Neeraj 2024-10-18 10:47:10 +05:30 committed by IshaVenikar
parent 94a6c66c36
commit 1b2d49c2e9

View File

@ -1,4 +1,4 @@
import { useCallback } from 'react'; import { useCallback, useState } from 'react';
import { import {
Deployment, Deployment,
DeploymentStatus, DeploymentStatus,
@ -15,15 +15,32 @@ import {
LoadingIcon, LoadingIcon,
WarningIcon, WarningIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import {
Dialog,
DialogTitle,
DialogContent,
DialogActions,
} from '@mui/material';
import { Heading } from 'components/shared/Heading'; import { Heading } from 'components/shared/Heading';
import { OverflownText } from 'components/shared/OverflownText'; import { OverflownText } from 'components/shared/OverflownText';
import { Tag, TagTheme } from 'components/shared/Tag'; import { Tag, TagTheme } from 'components/shared/Tag';
import { Button } from 'components/shared/Button';
import { getInitials } from 'utils/geInitials'; import { getInitials } from 'utils/geInitials';
import { relativeTimeMs } from 'utils/time'; import { relativeTimeMs } from 'utils/time';
import { SHORT_COMMIT_HASH_LENGTH } from '../../../../constants'; import { SHORT_COMMIT_HASH_LENGTH } from '../../../../constants';
import { formatAddress } from '../../../../utils/format'; import { formatAddress } from '../../../../utils/format';
import { DeploymentMenu } from './DeploymentMenu'; import { DeploymentMenu } from './DeploymentMenu';
const DEPLOYMENT_LOGS_STYLE = {
backgroundColor: "rgba(0,0,0, .9)",
padding: "2em",
borderRadius: "0.5em",
marginLeft: "0.5em",
marginRight: "0.5em",
color: "gray",
fontSize: "small",
};
interface DeployDetailsCardProps { interface DeployDetailsCardProps {
deployment: Deployment; deployment: Deployment;
currentDeployment: Deployment; currentDeployment: Deployment;
@ -48,6 +65,12 @@ const DeploymentDetailsCard = ({
project, project,
prodBranchDomains, prodBranchDomains,
}: DeployDetailsCardProps) => { }: DeployDetailsCardProps) => {
const [openDialog, setOpenDialog] = useState<boolean>(false);
const handleOpenDialog = () => setOpenDialog(true);
const handleCloseDialog = () => setOpenDialog(false);
const [deploymentLogs, setDeploymentLogs] = useState<string>();
const getIconByDeploymentStatus = (status: DeploymentStatus) => { const getIconByDeploymentStatus = (status: DeploymentStatus) => {
if ( if (
status === DeploymentStatus.Building || status === DeploymentStatus.Building ||
@ -75,7 +98,10 @@ const DeploymentDetailsCard = ({
onClick={async()=> { onClick={async()=> {
let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}` let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`
const res = await fetch(url); const res = await fetch(url);
console.log(">>>>RESPONSE",await res.text()) const logs = await res.text()
// console.log(">>>>RESPONSE",await res.text())
setDeploymentLogs(logs)
handleOpenDialog()
}} }}
> >
{deployment.status} {deployment.status}
@ -172,6 +198,15 @@ const DeploymentDetailsCard = ({
prodBranchDomains={prodBranchDomains} prodBranchDomains={prodBranchDomains}
/> />
</div> </div>
<Dialog open={openDialog} onClose={handleCloseDialog} fullWidth maxWidth="md">
<DialogTitle>Deployment logs</DialogTitle>
<DialogContent style={DEPLOYMENT_LOGS_STYLE} >
{deploymentLogs && <pre >{deploymentLogs}</pre>}
</DialogContent>
<DialogActions>
<Button onClick={handleCloseDialog}>Close</Button>
</DialogActions>
</Dialog>
</div> </div>
); );
}; };