File tree 5 files changed +35
-4
lines changed
modules/object-record/record-field/meta-types/input/components
twenty-ui/src/display/icon/components
5 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 82
82
"STORYBOOK_SCOPE" : " pages"
83
83
}
84
84
},
85
- "performance" : {
85
+ "performance" : {
86
86
"env" : {
87
87
"NODE_OPTIONS" : " --max_old_space_size=5000" ,
88
88
"STORYBOOK_SCOPE" : " performance"
124
124
"modules" : { "env" : { "STORYBOOK_SCOPE" : " modules" } },
125
125
"pages" : { "env" : { "STORYBOOK_SCOPE" : " pages" } },
126
126
"performance" : { "env" : { "STORYBOOK_SCOPE" : " performance" } }
127
-
128
127
}
129
128
},
130
129
"storybook:test:nocoverage" : {
133
132
"modules" : { "env" : { "STORYBOOK_SCOPE" : " modules" } },
134
133
"pages" : { "env" : { "STORYBOOK_SCOPE" : " pages" } },
135
134
"performance" : { "env" : { "STORYBOOK_SCOPE" : " performance" } }
136
-
137
135
}
138
136
},
139
137
"storybook:static:test" : {
Original file line number Diff line number Diff line change @@ -539,6 +539,7 @@ export type RelationConnection = {
539
539
export type RelationDefinition = {
540
540
__typename ?: 'RelationDefinition' ;
541
541
direction : RelationDefinitionType ;
542
+ relationId : Scalars [ 'UUID' ] ;
542
543
sourceFieldMetadata : Field ;
543
544
sourceObjectMetadata : Object ;
544
545
targetFieldMetadata : Field ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
14
14
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem' ;
15
15
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys' ;
16
16
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside' ;
17
+ import { moveArrayItem } from '~/utils/array/moveArrayItem' ;
17
18
import { toSpliced } from '~/utils/array/toSpliced' ;
18
19
import { isDefined } from '~/utils/isDefined' ;
19
20
@@ -86,6 +87,19 @@ export const LinksFieldInput = ({
86
87
) ;
87
88
} ;
88
89
90
+ const handleSetPrimaryLink = ( index : number ) => {
91
+ const nextLinks = moveArrayItem ( links , { fromIndex : index , toIndex : 0 } ) ;
92
+ const [ nextPrimaryLink , ...nextSecondaryLinks ] = nextLinks ;
93
+
94
+ onSubmit ?.( ( ) =>
95
+ persistLinksField ( {
96
+ primaryLinkUrl : nextPrimaryLink . url ?? '' ,
97
+ primaryLinkLabel : nextPrimaryLink . label ?? '' ,
98
+ secondaryLinks : nextSecondaryLinks ,
99
+ } ) ,
100
+ ) ;
101
+ } ;
102
+
89
103
const handleDeleteLink = ( index : number ) => {
90
104
onSubmit ?.( ( ) =>
91
105
persistLinksField ( {
@@ -110,6 +124,7 @@ export const LinksFieldInput = ({
110
124
dropdownId = { `${ hotkeyScope } -links-${ index } ` }
111
125
isPrimary = { index === 0 }
112
126
label = { label }
127
+ onSetAsPrimary = { ( ) => handleSetPrimaryLink ( index ) }
113
128
onDelete = { ( ) => handleDeleteLink ( index ) }
114
129
url = { url }
115
130
/>
Original file line number Diff line number Diff line change
1
+ import { useEffect } from 'react' ;
1
2
import styled from '@emotion/styled' ;
2
3
import {
3
4
IconBookmark ,
5
+ IconBookmarkPlus ,
4
6
IconComponent ,
5
7
IconDotsVertical ,
6
8
IconTrash ,
@@ -16,6 +18,7 @@ type LinksFieldMenuItemProps = {
16
18
dropdownId : string ;
17
19
isPrimary ?: boolean ;
18
20
label : string ;
21
+ onSetAsPrimary : ( ) => void ;
19
22
onDelete : ( ) => void ;
20
23
url : string ;
21
24
} ;
@@ -30,10 +33,18 @@ export const LinksFieldMenuItem = ({
30
33
dropdownId,
31
34
isPrimary,
32
35
label,
36
+ onSetAsPrimary,
33
37
onDelete,
34
38
url,
35
39
} : LinksFieldMenuItemProps ) => {
36
- const { isDropdownOpen } = useDropdown ( dropdownId ) ;
40
+ const { isDropdownOpen, closeDropdown } = useDropdown ( dropdownId ) ;
41
+
42
+ // Make sure dropdown closes on unmount.
43
+ useEffect ( ( ) => {
44
+ if ( isDropdownOpen ) {
45
+ return ( ) => closeDropdown ( ) ;
46
+ }
47
+ } , [ closeDropdown , isDropdownOpen ] ) ;
37
48
38
49
return (
39
50
< MenuItem
@@ -55,6 +66,11 @@ export const LinksFieldMenuItem = ({
55
66
clickableComponent = { iconButton }
56
67
dropdownComponents = {
57
68
< DropdownMenuItemsContainer >
69
+ < MenuItem
70
+ LeftIcon = { IconBookmarkPlus }
71
+ text = "Set as Primary"
72
+ onClick = { onSetAsPrimary }
73
+ />
58
74
< MenuItem
59
75
accent = "danger"
60
76
LeftIcon = { IconTrash }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export {
20
20
IconBolt ,
21
21
IconBook2 ,
22
22
IconBookmark ,
23
+ IconBookmarkPlus ,
23
24
IconBox ,
24
25
IconBrandGithub ,
25
26
IconBrandGoogle ,
You can’t perform that action at this time.
0 commit comments