@@ -20,6 +20,9 @@ import { useFetcherWithOperation } from '../hooks/useFetcherWithOperation'
20
20
import React from 'react'
21
21
import { when } from '../util/react-conditionals'
22
22
import moment from 'moment'
23
+ import { useProjectEditorLink } from '../util/links'
24
+ import { button } from '../styles/button.css'
25
+ import { useCopyProjectLinkToClipboard } from '../util/copyProjectLink'
23
26
24
27
export function SharingDialog ( {
25
28
project,
@@ -86,6 +89,10 @@ export function SharingDialog({
86
89
changeProjectAccessLevel = { changeProjectAccessLevel }
87
90
/>
88
91
</ Flex >
92
+ { when (
93
+ accessLevel === AccessLevel . COLLABORATIVE || accessLevel === AccessLevel . PUBLIC ,
94
+ < ProjectLink projectId = { project . proj_id } /> ,
95
+ ) }
89
96
{ when (
90
97
accessRequests . length > 0 ,
91
98
< >
@@ -200,3 +207,40 @@ function VisibilityDropdown({
200
207
</ DropdownMenu . Root >
201
208
)
202
209
}
210
+
211
+ const ProjectLink = React . memo ( ( { projectId } : { projectId : string } ) => {
212
+ const projectLinkRef = React . useRef < HTMLInputElement | null > ( null )
213
+
214
+ const projectLink = useProjectEditorLink ( )
215
+ const copyProjectLink = useCopyProjectLinkToClipboard ( )
216
+
217
+ const onClickCopyProjectLink = React . useCallback ( ( ) => {
218
+ copyProjectLink ( projectId )
219
+ projectLinkRef . current ?. select ( )
220
+ } , [ projectId , copyProjectLink ] )
221
+
222
+ return (
223
+ < Flex style = { { gap : 10 , alignItems : 'stretch' } } >
224
+ < input
225
+ ref = { projectLinkRef }
226
+ type = 'text'
227
+ value = { projectLink ( projectId ) }
228
+ readOnly = { true }
229
+ style = { {
230
+ flex : 1 ,
231
+ fontSize : 13 ,
232
+ padding : '0px 4px' ,
233
+ cursor : 'default' ,
234
+ } }
235
+ />
236
+ < button
237
+ className = { button ( { color : 'subtle' } ) }
238
+ style = { { fontSize : 13 } }
239
+ onClick = { onClickCopyProjectLink }
240
+ >
241
+ Copy
242
+ </ button >
243
+ </ Flex >
244
+ )
245
+ } )
246
+ ProjectLink . displayName = 'ProjectLink'
0 commit comments