@@ -2,23 +2,39 @@ import React, { ChangeEvent, FormEvent, useState, useEffect } from 'react'
2
2
import * as l10n from '@vscode/l10n'
3
3
import { VSCodeButton } from '@vscode/webview-ui-toolkit/react'
4
4
5
- import { KeyTypes , AddListFormConfig as config } from 'uiSrc/constants'
5
+ import { HEAD_DESTINATION , KeyTypes , ListElementDestination , TAIL_DESTINATION , AddListFormConfig as config } from 'uiSrc/constants'
6
6
import { getRequiredFieldsText , stringToBuffer } from 'uiSrc/utils'
7
7
import { Maybe } from 'uiSrc/interfaces'
8
8
import { useKeysApi , useKeysInContext } from 'uiSrc/modules/keys-tree/hooks/useKeys'
9
- import { InputText , Tooltip } from 'uiSrc/ui'
9
+ import { InputText , Select , SelectOption , Tooltip } from 'uiSrc/ui'
10
10
import { CreateListWithExpireDto } from 'uiSrc/modules/keys-tree/hooks/interface'
11
11
import { AddItemsActions } from 'uiSrc/components'
12
12
13
+ import styles from '../../styles.module.scss'
14
+
13
15
export interface Props {
14
16
keyName : string
15
17
keyTTL : Maybe < number >
16
18
onClose : ( isCancelled ?: boolean , keyType ?: KeyTypes ) => void
17
19
}
18
20
21
+ const optionsDestinations : SelectOption [ ] = [
22
+ {
23
+ value : TAIL_DESTINATION ,
24
+ label : l10n . t ( 'Push to tail' ) ,
25
+ testid : TAIL_DESTINATION ,
26
+ } ,
27
+ {
28
+ value : HEAD_DESTINATION ,
29
+ label : l10n . t ( 'Push to head' ) ,
30
+ testid : HEAD_DESTINATION ,
31
+ } ,
32
+ ]
33
+
19
34
export const AddKeyList = ( props : Props ) => {
20
35
const { keyName = '' , keyTTL, onClose } = props
21
36
const [ elements , setElements ] = useState < string [ ] > ( [ '' ] )
37
+ const [ destination , setDestination ] = useState < ListElementDestination > ( TAIL_DESTINATION )
22
38
const [ isFormValid , setIsFormValid ] = useState < boolean > ( false )
23
39
24
40
const keysApi = useKeysApi ( )
@@ -60,6 +76,7 @@ export const AddKeyList = (props: Props) => {
60
76
const submitData = ( ) : void => {
61
77
const data : CreateListWithExpireDto = {
62
78
keyName : stringToBuffer ( keyName ) ,
79
+ destination,
63
80
elements : elements . map ( ( el ) => stringToBuffer ( el ) ) ,
64
81
}
65
82
if ( keyTTL !== undefined ) {
@@ -74,6 +91,17 @@ export const AddKeyList = (props: Props) => {
74
91
< >
75
92
< form onSubmit = { onFormSubmit } className = "key-footer-items-container pl-0 h-full" >
76
93
< h3 className = "font-bold uppercase pb-3" > { l10n . t ( 'Element' ) } </ h3 >
94
+ < div className = "w-1/3 mr-2 mb-3" >
95
+ < Select
96
+ position = "below"
97
+ options = { optionsDestinations }
98
+ containerClassName = { styles . select }
99
+ itemClassName = { styles . selectOption }
100
+ idSelected = { destination }
101
+ onChange = { ( value ) => setDestination ( value as ListElementDestination ) }
102
+ testid = "destination-select"
103
+ />
104
+ </ div >
77
105
{ elements . map ( ( item , index ) => (
78
106
< div key = { index } >
79
107
< div className = "flex items-center mb-3" >
0 commit comments