2021-09-11 01:15:36 -07:00
< template >
< Modal
2021-10-18 20:57:49 -07:00
: name = "CREDENTIAL_SELECT_MODAL_KEY"
2021-09-11 01:15:36 -07:00
: eventBus = "modalBus"
2021-09-22 00:23:37 -07:00
width = "50%"
: center = "true"
maxWidth = "460px"
2021-09-11 01:15:36 -07:00
>
< template slot = "header" >
2021-11-10 10:41:40 -08:00
< h2 :class ="$style.title" > { { $baseText ( 'credentialSelectModal.addNewCredential' ) } } < / h2 >
2021-09-11 01:15:36 -07:00
< / template >
< template slot = "content" >
2021-10-18 20:57:49 -07:00
< div >
2021-11-10 10:41:40 -08:00
< div :class ="$style.subtitle" > { { $baseText ( 'credentialSelectModal.selectAnAppOrServiceToConnectTo' ) } } < / div >
2021-09-11 01:15:36 -07:00
< n8n -select
filterable
defaultFirstOption
2021-11-10 10:41:40 -08:00
: placeholder = "$baseText('credentialSelectModal.searchForApp')"
2021-09-11 01:15:36 -07:00
size = "xlarge"
ref = "select"
: value = "selected"
@ change = "onSelect"
>
< font -awesome -icon icon = "search" slot = "prefix" / >
< n8n -option
v - for = "credential in allCredentialTypes"
: value = "credential.name"
: key = "credential.name"
: label = "credential.displayName"
filterable
/ >
< / n 8 n - s e l e c t >
< / div >
< / template >
< template slot = "footer" >
< div :class ="$style.footer" >
< n8n -button
2021-11-10 10:41:40 -08:00
: label = "$baseText('credentialSelectModal.continue')"
2021-09-11 01:15:36 -07:00
float = "right"
size = "large"
: disabled = "!selected"
@ click = "openCredentialType"
/ >
< / div >
< / template >
< / Modal >
< / template >
< script lang = "ts" >
import Vue from 'vue' ;
import { mapGetters } from "vuex" ;
import Modal from './Modal.vue' ;
2021-10-18 20:57:49 -07:00
import { CREDENTIAL _SELECT _MODAL _KEY } from '../constants' ;
2021-11-10 10:41:40 -08:00
import mixins from 'vue-typed-mixins' ;
import { renderText } from './mixins/renderText' ;
2021-09-11 01:15:36 -07:00
2021-11-10 10:41:40 -08:00
export default mixins ( renderText ) . extend ( {
2021-09-11 01:15:36 -07:00
name : 'CredentialsSelectModal' ,
components : {
Modal ,
} ,
mounted ( ) {
setTimeout ( ( ) => {
const element = this . $refs . select as HTMLSelectElement ;
if ( element ) {
element . focus ( ) ;
}
} , 0 ) ;
} ,
data ( ) {
return {
modalBus : new Vue ( ) ,
selected : '' ,
2021-10-18 20:57:49 -07:00
CREDENTIAL _SELECT _MODAL _KEY ,
2021-09-11 01:15:36 -07:00
} ;
} ,
computed : {
... mapGetters ( 'credentials' , [ 'allCredentialTypes' ] ) ,
} ,
methods : {
onSelect ( type : string ) {
this . selected = type ;
} ,
openCredentialType ( ) {
this . modalBus . $emit ( 'close' ) ;
this . $store . dispatch ( 'ui/openNewCredential' , { type : this . selected } ) ;
2021-10-18 20:57:49 -07:00
this . $telemetry . track ( 'User opened Credential modal' , { credential _type : this . selected , source : 'primary_menu' , new _credential : true , workflow _id : this . $store . getters . workflowId } ) ;
2021-09-11 01:15:36 -07:00
} ,
} ,
} ) ;
< / script >
< style module lang = "scss" >
. title {
font - size : var ( -- font - size - xl ) ;
line - height : var ( -- font - line - height - regular ) ;
}
. subtitle {
margin - bottom : var ( -- spacing - s ) ;
font - size : var ( -- font - size - m ) ;
line - height : var ( -- font - line - height - xloose ) ;
}
< / style >