aboutsummaryrefslogtreecommitdiff
path: root/extension/src/entries/popup/Components/IdentitySelection.vue
blob: 99d8e34d6bb17ccf4999bff953385b083007f7a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<template>
    <div class="text-left">
       <div class="w-full">
            <div class="">
                <select class="w-full input" 
                :disabled="waiting"
                :value="selected?.Id"
                @change.prevent="onSelected"
                >
                    <option disabled value="">Select an identity</option>
                    <option v-for="key in allKeys" :value="key.Id">{{ key.UserName }}</option>
                </select>
            </div>
       </div>
       
    </div>
</template>

<script setup lang="ts">
import { find } from 'lodash'
import { computed } from "vue";
import { useStore } from "../../store";
import { useWait } from '@vnuge/vnlib.browser'
import { storeToRefs } from 'pinia';

const { waiting } = useWait();
const store = useStore();
const { selectedKey, allKeys } = storeToRefs(store);

const onSelected = async ({target}) =>{
    //Select the key of the given id
    const selected = find(allKeys.value, {Id: target.value})
    if(selected){
        await store.selectKey(selected)
    }
}

const selected = computed(() => selectedKey?.value || { Id:"" })

</script>