11import React , { useContext } from 'react' ;
22import Grid from '@mui/material/Grid' ;
33import { ImageContext } from './ImageContext' ;
4- import { HeaderTitle , MetPageGridContainer , MetParagraph , PrimaryButton } from 'components/shared/common' ;
4+ import { MetHeader1 , MetHeader3 , MetPageGridContainer , MetParagraph , PrimaryButton } from 'components/shared/common' ;
55import ImageUpload from '../ImageUpload' ;
66import { IconButton , Stack , TextField } from '@mui/material' ;
7- import { Search as SearchIcon , OpenInNew as OpenInNewIcon } from '@mui/icons-material' ;
7+ import { Search as SearchIcon } from '@mui/icons-material' ;
88import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline' ;
9+ import ContentCopyIcon from '@mui/icons-material/ContentCopy' ;
910import MetTable from 'components/shared/common/Table' ;
1011import { HeadCell , PaginationOptions } from 'components/shared/common/Table/types' ;
1112import { ImageInfo } from 'models/image' ;
@@ -36,7 +37,6 @@ const ImageListing = () => {
3637 const { roles } = useAppSelector ( ( state ) => state . user ) ;
3738
3839 const authorized = roles . includes ( USER_ROLES . CREATE_IMAGES ) ;
39-
4040 const headCells : HeadCell < ImageInfo > [ ] = [
4141 {
4242 key : 'url' ,
@@ -78,42 +78,24 @@ const ImageListing = () => {
7878 </ Grid >
7979 ) ;
8080 } ,
81+ customStyle : { whiteSpace : 'nowrap' } ,
8182 } ,
8283 {
8384 key : 'url' ,
84- label : 'Image URL' ,
85+ label : 'Copy URL' ,
8586 disablePadding : true ,
8687 allowSort : true ,
8788 numeric : false ,
8889 renderCell : ( row : ImageInfo ) => (
8990 < Grid container direction = { 'row' } gap = { 1 } alignItems = { 'center' } >
90- < Grid item > { row . url } </ Grid >
9191 < Grid item >
9292 < IconButton
9393 onClick = { ( ) => {
94- const url = imageToDisplay ?. url ?? '' ;
95- const newWindow = window . open ( ) ;
96- if ( newWindow ) {
97- newWindow . document . write ( `
98- <!DOCTYPE html>
99- <html>
100- <head>
101- <title>Image</title>
102- <style>
103- body { margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; }
104- img { max-width: 100%; max-height: 100vh; object-fit: contain; }
105- </style>
106- </head>
107- <body>
108- <img src="${ url } " alt="Image" />
109- </body>
110- </html>
111- ` ) ;
112- newWindow . document . close ( ) ;
113- }
94+ const url = row ?. url ?? '' ;
95+ navigator . clipboard . writeText ( url ) ;
11496 } }
11597 >
116- < OpenInNewIcon />
98+ < ContentCopyIcon />
11799 </ IconButton >
118100 </ Grid >
119101 </ Grid >
@@ -149,7 +131,7 @@ const ImageListing = () => {
149131 rowSpacing = { 1 }
150132 >
151133 < Grid item xs = { 12 } >
152- < HeaderTitle sx = { { fontSize : '1.5rem' } } > Image URL Generator</ HeaderTitle >
134+ < MetHeader1 > Image URL Generator</ MetHeader1 >
153135 </ Grid >
154136 < Grid item xs = { 12 } >
155137 < ImageUpload
@@ -180,7 +162,6 @@ const ImageListing = () => {
180162 < Then >
181163 < Grid item xs = { 6 } >
182164 < Stack direction = "row" spacing = { 2 } alignItems = "center" justifyContent = "space-between" >
183- < CheckCircleOutlineIcon color = "success" />
184165 < img
185166 src = { imageToDisplay ?. url }
186167 style = { {
@@ -190,6 +171,7 @@ const ImageListing = () => {
190171 height : 'auto' ,
191172 } }
192173 />
174+ < CheckCircleOutlineIcon color = "success" />
193175 < MetParagraph > { imageToDisplay ?. display_name } has been successfully uploaded</ MetParagraph >
194176 </ Stack >
195177 </ Grid >
@@ -201,32 +183,16 @@ const ImageListing = () => {
201183 justifyContent = "right"
202184 sx = { { height : 100 } }
203185 >
204- < IconButton
186+ < PrimaryButton
205187 onClick = { ( ) => {
206188 const url = imageToDisplay ?. url ?? '' ;
207- const newWindow = window . open ( ) ;
208- if ( newWindow ) {
209- newWindow . document . write ( `
210- <!DOCTYPE html>
211- <html>
212- <head>
213- <title>Image</title>
214- <style>
215- body { margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; }
216- img { max-width: 100%; max-height: 100vh; object-fit: contain; }
217- </style>
218- </head>
219- <body>
220- <img src="${ url } " alt="Image" />
221- </body>
222- </html>
223- ` ) ;
224- newWindow . document . close ( ) ;
225- }
189+ navigator . clipboard . writeText ( url ) ;
226190 } }
191+ startIcon = { < ContentCopyIcon /> }
192+ size = "small"
227193 >
228- < OpenInNewIcon />
229- </ IconButton >
194+ Copy URL
195+ </ PrimaryButton >
230196 </ Stack >
231197 </ Grid >
232198 </ Then >
@@ -235,7 +201,7 @@ const ImageListing = () => {
235201 </ Else >
236202 </ If >
237203 < Grid item xs = { 12 } >
238- < HeaderTitle sx = { { fontSize : '1.17em' } } > Uploaded Files</ HeaderTitle >
204+ < MetHeader3 > Uploaded Files</ MetHeader3 >
239205 </ Grid >
240206 < Grid item xs = { 12 } >
241207 < Stack direction = "row" spacing = { 1 } alignItems = "center" >
0 commit comments