added tags detail

This commit is contained in:
CodeServer 2022-04-12 10:18:56 +01:00
parent 455b0b383e
commit 238913697b
4 changed files with 148 additions and 22 deletions

View File

@ -1,13 +1,16 @@
import React from "react"; import React from "react";
import { useLocation, Link } from "react-router-dom"; import { useLocation, Link } from "react-router-dom";
import { ListItemButton, Button, Box, Card, CardContent, Typography, CardActions, Grid, List, ListItemText, Snackbar, Alert, Tooltip } from "@mui/material"; import { ListItemButton, Button, Box, Card, CardContent, Typography, CardActions, Grid, List, ListItemText, Snackbar, Alert, Tooltip, Collapse } from "@mui/material";
import AccessTimeIcon from '@mui/icons-material/AccessTime'; import AccessTimeIcon from '@mui/icons-material/AccessTime';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
import useRepositories from "../../hooks/useRepositories"; import useRepositories from "../../hooks/useRepositories";
import Tag from "../../interfaces/Tag"; import Tag from "../../interfaces/Tag";
import Repository from "../../interfaces/Repositoriy"; import Repository from "../../interfaces/Repositoriy";
import { getHostNameFromURL, printSize, printTimePassed, PrintOSIcon, toUpperFirst, printMonth } from "../../utils"; import { getHostNameFromURL, printSize, printTimePassed, PrintOSIcon, toUpperFirst, printMonth } from "../../utils";
import RepoNotFound from "./RepoNotFound" import RepoNotFound from "./RepoNotFound"
import Loading from "../Loading"; import Loading from "../Loading";
import { digestDisplay } from "../../interfaces/Utils";
const RepositoryInfo: React.FC = () => { const RepositoryInfo: React.FC = () => {
const location = useLocation(); const location = useLocation();
@ -15,15 +18,26 @@ const RepositoryInfo: React.FC = () => {
const { isFetched, repositories } = useRepositories(); const { isFetched, repositories } = useRepositories();
const [hideTags, setHideTags] = React.useState(true); const [hideTags, setHideTags] = React.useState(true);
const [snackbarOpen, setSnackbarOpen] = React.useState(false); const [snackbarOpen, setSnackbarOpen] = React.useState(false);
const [showDetails, setShowDetails] = React.useState(false);
const repository = repositories.find((element) => (element.name === path.slice(12,path.length))); const repository = repositories.find((element) => (element.name === path.slice(12,path.length)));
const generatePushCommand = (hostName: string) => { const generatePushCommand = (hostName: string, tagName: string) => {
return "docker push " + hostName + "/" + (repository?.name ? repository?.name : "") + ":tagname"; return "docker push " + hostName + "/" + (repository?.name ? repository?.name : "") + ":" + tagName;
} }
const handleClick = () => { const generatePullCommand = (hostName: string, tagName: string) => {
return "docker pull " + hostName + "/" + (repository?.name ? repository?.name : "") + ":" + tagName;
}
const handlePushClick = () => {
const hostName = getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : ""); const hostName = getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : "");
navigator.clipboard.writeText(generatePushCommand(hostName)); navigator.clipboard.writeText(generatePushCommand(hostName,"tagname"));
setSnackbarOpen(true);
};
const handlePullClick = (tagName: string) => {
const hostName = getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : "");
navigator.clipboard.writeText(generatePullCommand(hostName,tagName));
setSnackbarOpen(true); setSnackbarOpen(true);
}; };
@ -34,6 +48,10 @@ const RepositoryInfo: React.FC = () => {
const toggleHide = () => { const toggleHide = () => {
setHideTags(!hideTags); setHideTags(!hideTags);
} }
const toggleCollapse = () => {
setShowDetails((prev) => !prev);
};
return (isFetched ? ( return (isFetched ? (
repository ? ( repository ? (
@ -61,7 +79,7 @@ const RepositoryInfo: React.FC = () => {
<Typography className="lines" variant="body2"> <Typography className="lines" variant="body2">
To push a new tag to this repository, To push a new tag to this repository,
</Typography> </Typography>
<Box className="commandDisplay" onClick={handleClick} component="span" sx={{ display: 'block', bgcolor: '#445d6e', color: 'white', borderColor: '#445d6e' }}>{generatePushCommand(getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : ""))}</Box> <Box className="commandDisplay" onClick={handlePushClick} component="span" sx={{ display: 'block', bgcolor: '#445d6e', color: 'white', borderColor: '#445d6e' }}>{generatePushCommand(getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : ""),"tagname")}</Box>
</Box> </Box>
</Grid> </Grid>
</Grid> </Grid>
@ -70,7 +88,7 @@ const RepositoryInfo: React.FC = () => {
<Button size="small">Learn More</Button> <Button size="small">Learn More</Button>
</CardActions> */} </CardActions> */}
</Card> </Card>
<Card className="tagsDetail" variant="outlined"> <Card className="tagsOverview" variant="outlined">
<CardContent> <CardContent>
<Typography className="lines" variant="h6"> <Typography className="lines" variant="h6">
Tags Tags
@ -107,7 +125,7 @@ const RepositoryInfo: React.FC = () => {
return result; return result;
} }
}).slice(0,((hideTags && repository.tags.length > 4) ? 3 : repository.tags.length)).map((tag) => ( }).slice(0,((hideTags && repository.tags.length > 4) ? 3 : repository.tags.length)).map((tag) => (
<Grid container> <Grid className="lines" container>
<Grid item sm={5}> <Grid item sm={5}>
<ListItemText primary={tag.label} /> <ListItemText primary={tag.label} />
</Grid> </Grid>
@ -159,11 +177,75 @@ const RepositoryInfo: React.FC = () => {
)} )}
</List> </List>
</CardContent> </CardContent>
</Card>
<Card className="detailsCard" variant="outlined">
<CardActions> <CardActions>
<Button size="small">Details</Button> <Button startIcon={showDetails ? <ExpandLessIcon /> : <ExpandMoreIcon />} onClick={toggleCollapse} size="small">Tag Details</Button>
</CardActions> </CardActions>
</Card> </Card>
<Snackbar open={snackbarOpen} autoHideDuration={6000} onClose={handleClose}> <Collapse className="tagsDetail" in={showDetails}>
{repository.tags.map((tag) => (
<Card className="tagCard" variant="outlined">
<CardContent>
<Grid container>
<Grid item lg={6} md={12}>
<Typography className="lines" variant="h5" component="div" color="#94a1aa">
TAG
</Typography>
<Typography className="lines" variant="h5" component="div" color="#007bff">
{tag.label}
</Typography>
<Typography className="lines" sx={{ mb: 1.5 }}>
Last updated: <b>{(tag.created ? printTimePassed(tag.created) : "")}</b>
</Typography>
</Grid>
<Grid item lg={6} md={12}>
<Box sx={{ display: "flex", flexDirection: "column" }}>
<Typography className="lines" variant="h6">
To pull this image,
</Typography>
<Box className="commandDisplay" onClick={() => (handlePullClick(tag.label))} component="span" sx={{ display: 'block', bgcolor: '#445d6e', color: 'white', borderColor: '#445d6e' }}>{generatePullCommand(getHostNameFromURL(process.env.REGISTRY_URL ? process.env.REGISTRY_URL : ""),tag.label)}</Box>
</Box>
</Grid>
<Grid item lg={12} md={12}>
<Grid className="lines" container>
<Grid item sm={5}>
<ListItemText primary="DIGEST" />
</Grid>
<Grid item sm={4}>
<ListItemText primary="OS/ARCH" />
</Grid>
<Grid item sm={3}>
<ListItemText style={{display:'flex', justifyContent:'flex-end'}} primary="SIZE" />
</Grid>
</Grid>
<List>
<ListItemButton
className="lines"
component={Link}
to={"/repository/" + repository.name + "/" + tag.label}
>
<Grid container>
<Grid item sm={5}>
<ListItemText style={{color: '#007bff'}} primary={digestDisplay(tag.digest)} />
</Grid>
<Grid item sm={4}>
<ListItemText primary={tag.os + "/" +tag.architecture} />
</Grid>
<Grid item sm={3}>
<ListItemText style={{display:'flex', justifyContent:'flex-end'}} primary={tag.size ? printSize(tag.size) : "---"} />
</Grid>
</Grid>
</ListItemButton>
</List>
</Grid>
</Grid>
</CardContent>
</Card>
))}
</Collapse>
<Snackbar open={snackbarOpen} autoHideDuration={1500} onClose={handleClose}>
<Alert onClose={handleClose} severity="success" sx={{ width: '100%' }}> <Alert onClose={handleClose} severity="success" sx={{ width: '100%' }}>
Copied! Copied!
</Alert> </Alert>

View File

@ -14,9 +14,10 @@
border-radius: 5px border-radius: 5px
padding: 0 15px padding: 0 15px
margin-top: 5px margin-top: 5px
.tagsDetail cursor: pointer
.tagsOverview
margin: 5% margin: 5%
padding: 15px padding: 0 15px
.iconWrapper .iconWrapper
height: 24px height: 24px
width: 24px width: 24px
@ -24,12 +25,29 @@
height: 24px height: 24px
width: 24px width: 24px
.lines .lines
margin-bottom: 10px margin-top: 10px
.moreBtn .moreBtn
margin-top: 10px
color: #1976d2 color: #1976d2
cursor: pointer cursor: pointer
.moreBtn:focus .moreBtn:focus
color: purple color: purple
.detailsCard
margin: 0 5%
padding: 0 15px
.tagCard
margin: 5%
padding: 15px
.commandDisplay
line-height: 200%
border-radius: 5px
padding: 0 15px
margin-top: 5px
cursor: pointer
.lines
margin-top: 10px
padding-left: 0
padding-right: 0
@media (max-width: 1199px) @media (max-width: 1199px)
.repositoryInfo .repositoryInfo

View File

@ -48,36 +48,62 @@ a {
border-radius: 5px; border-radius: 5px;
padding: 0 15px; padding: 0 15px;
margin-top: 5px; margin-top: 5px;
cursor: pointer;
} }
.repositoryInfo .tagsDetail { .repositoryInfo .tagsOverview {
margin: 5%; margin: 5%;
padding: 15px; padding: 0 15px;
} }
.repositoryInfo .tagsDetail .iconWrapper { .repositoryInfo .tagsOverview .iconWrapper {
height: 24px; height: 24px;
width: 24px; width: 24px;
} }
.repositoryInfo .tagsDetail .icon { .repositoryInfo .tagsOverview .icon {
height: 24px; height: 24px;
width: 24px; width: 24px;
} }
.repositoryInfo .tagsDetail .lines { .repositoryInfo .tagsOverview .lines {
margin-bottom: 10px; margin-top: 10px;
} }
.repositoryInfo .tagsDetail .moreBtn { .repositoryInfo .tagsOverview .moreBtn {
margin-top: 10px;
color: #1976d2; color: #1976d2;
cursor: pointer; cursor: pointer;
} }
.repositoryInfo .tagsDetail .moreBtn:focus { .repositoryInfo .tagsOverview .moreBtn:focus {
color: purple; color: purple;
} }
.repositoryInfo .detailsCard {
margin: 0 5%;
padding: 0 15px;
}
.repositoryInfo .tagCard {
margin: 5%;
padding: 15px;
}
.repositoryInfo .tagCard .commandDisplay {
line-height: 200%;
border-radius: 5px;
padding: 0 15px;
margin-top: 5px;
cursor: pointer;
}
.repositoryInfo .tagCard .lines {
margin-top: 10px;
padding-left: 0;
padding-right: 0;
}
@media (max-width: 1199px) { @media (max-width: 1199px) {
.repositoryInfo { .repositoryInfo {
max-width: 90%; max-width: 90%;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AG8CA,AAAA,WAAW,CAAC;EACR,KAAK,EAAE,IAAI;CAAG;;AAElB,AAAA,CAAC,CAAC;EACE,eAAe,EAAE,IAAI;CAAG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