File tree Expand file tree Collapse file tree 2 files changed +68
-53
lines changed
packages/plugin-search/src/Search/ui Expand file tree Collapse file tree 2 files changed +68
-53
lines changed Original file line number Diff line number Diff line change
1
+ 'use client'
2
+
3
+ import type { FormState } from 'payload/types'
4
+
5
+ import { useWatchForm } from '@payloadcms/ui/forms/Form'
6
+ import { useConfig } from '@payloadcms/ui/providers/Config'
7
+ import React from 'react'
8
+ // TODO: fix this import to work in dev mode within the monorepo in a way that is backwards compatible with 1.x
9
+ // import CopyToClipboard from 'payload/dist/admin/components/elements/CopyToClipboard'
10
+
11
+ type FieldsWithDoc = FormState & {
12
+ doc : {
13
+ value : {
14
+ relationTo : string
15
+ value : string
16
+ }
17
+ }
18
+ }
19
+
20
+ export const LinkToDocClient : React . FC = ( ) => {
21
+ const form = useWatchForm ( )
22
+ const fields = form . fields as FieldsWithDoc
23
+
24
+ const {
25
+ doc : {
26
+ value : { relationTo, value : docId } ,
27
+ } ,
28
+ } = fields
29
+
30
+ const config = useConfig ( )
31
+
32
+ const {
33
+ routes : {
34
+ admin : adminRoute , // already includes leading slash
35
+ } ,
36
+ serverURL,
37
+ } = config
38
+
39
+ const href = `${ serverURL } ${ adminRoute } /collections/${ relationTo } /${ docId } `
40
+
41
+ return (
42
+ < div >
43
+ < div >
44
+ < span
45
+ className = "label"
46
+ style = { {
47
+ color : '#9A9A9A' ,
48
+ } }
49
+ >
50
+ Doc URL
51
+ </ span >
52
+ { /* <CopyToClipboard value={href} /> */ }
53
+ </ div >
54
+ < div
55
+ style = { {
56
+ fontWeight : '600' ,
57
+ overflow : 'hidden' ,
58
+ textOverflow : 'ellipsis' ,
59
+ } }
60
+ >
61
+ < a href = { href } > { href } </ a >
62
+ </ div >
63
+ </ div >
64
+ )
65
+ }
Original file line number Diff line number Diff line change 1
- import type { FormState , UIField } from 'payload/types'
1
+ import type { UIField } from 'payload/types'
2
2
3
- import { useWatchForm } from '@payloadcms/ui/forms/Form'
4
- import { useConfig } from '@payloadcms/ui/providers/Config'
5
3
import React from 'react'
6
- // TODO: fix this import to work in dev mode within the monorepo in a way that is backwards compatible with 1.x
7
- // import CopyToClipboard from 'payload/dist/admin/components/elements/CopyToClipboard'
8
4
9
- type FieldsWithDoc = FormState & {
10
- doc : {
11
- value : {
12
- relationTo : string
13
- value : string
14
- }
15
- }
16
- }
5
+ import { LinkToDocClient } from './index.client.js'
17
6
18
7
export const LinkToDoc : React . FC < UIField > = ( ) => {
19
- const form = useWatchForm ( )
20
- const fields = form . fields as FieldsWithDoc
21
-
22
- const {
23
- doc : {
24
- value : { relationTo, value : docId } ,
25
- } ,
26
- } = fields
27
-
28
- const config = useConfig ( )
29
-
30
- const {
31
- routes : {
32
- admin : adminRoute , // already includes leading slash
33
- } ,
34
- serverURL,
35
- } = config
36
-
37
- const href = `${ serverURL } ${ adminRoute } /collections/${ relationTo } /${ docId } `
38
-
39
8
return (
40
9
< div >
41
- < div >
42
- < span
43
- className = "label"
44
- style = { {
45
- color : '#9A9A9A' ,
46
- } }
47
- >
48
- Doc URL
49
- </ span >
50
- { /* <CopyToClipboard value={href} /> */ }
51
- </ div >
52
- < div
53
- style = { {
54
- fontWeight : '600' ,
55
- overflow : 'hidden' ,
56
- textOverflow : 'ellipsis' ,
57
- } }
58
- >
59
- < a href = { href } > { href } </ a >
60
- </ div >
10
+ < LinkToDocClient />
61
11
</ div >
62
12
)
63
13
}
You can’t perform that action at this time.
0 commit comments