aboutsummaryrefslogtreecommitdiff
path: root/extension/src/entries/popup/Components/IdentitySelection.vue
blob: eb08fb1b60e4e66a0d2c703ef6bc8b85f3af2551 (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
41
42
43
44
<template>
    <div class="text-left">
       <div class="flex flex-row w-full gap-1">
            <div class="flex-1">
                <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 class="my-auto">
                <button class="btn sm borderless" @click="store.refreshIdentities()">
                    <fa-icon icon="refresh" class="" />
                </button>
            </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>