api-client/components/app/Shortcuts.vue

163 lines
4 KiB
Vue
Raw Normal View History

2020-12-11 10:29:03 +00:00
<template>
2021-07-24 16:46:48 +00:00
<AppSlideOver :show="show" @close="close()">
<template #content>
<div
class="
bg-primary
border-b border-dividerLight
flex
p-2
top-0
z-10
2021-07-24 16:46:48 +00:00
items-center
sticky
justify-between
"
>
<h3 class="ml-2 heading">{{ $t("shortcuts") }}</h3>
<div>
<ButtonSecondary to="/settings" icon="tune" />
<ButtonSecondary icon="close" @click.native="close()" />
</div>
2020-12-11 10:29:03 +00:00
</div>
<!-- <div class="search-wrapper">
2021-07-26 07:10:02 +00:00
<input
v-model="filterText"
type="search"
class="bg-primaryLight border-b border-dividerLight flex font-semibold font-mono w-full py-2 pr-2 pl-8 focus:outline-none truncate"
2021-07-26 07:10:02 +00:00
:placeholder="$t('search')"
/>
</div> -->
<div
class="
divide-y divide-dividerLight
flex flex-col flex-1
overflow-auto
hide-scrollbar
"
>
2021-07-09 17:19:45 +00:00
<div
v-for="(map, mapIndex) in mappings"
:key="`map-${mapIndex}`"
class="space-y-4 p-4"
2021-07-09 17:19:45 +00:00
>
<h5 class="font-bold text-secondaryDark text-sm">
{{ map.section }}
</h5>
<div
v-for="(shortcut, shortcutIndex) in map.shortcuts"
:key="`map-${mapIndex}-shortcut-${shortcutIndex}`"
class="flex items-center"
2021-07-09 17:19:45 +00:00
>
<span class="flex flex-1 text-secondaryLight mr-4">
{{ shortcut.label }}
</span>
<span
v-for="(key, keyIndex) in shortcut.keys"
:key="`map-${mapIndex}-shortcut-${shortcutIndex}-key-${keyIndex}`"
class="shortcut-key"
>
{{ key }}
</span>
</div>
2020-12-11 16:54:34 +00:00
</div>
2020-12-11 10:29:03 +00:00
</div>
</template>
2021-07-24 16:46:48 +00:00
</AppSlideOver>
2020-12-11 10:29:03 +00:00
</template>
<script>
import {
getPlatformSpecialKey,
getPlatformAlternateKey,
} from "~/helpers/platformutils"
2020-12-11 10:29:03 +00:00
export default {
props: {
show: Boolean,
},
2021-07-09 17:19:45 +00:00
data() {
return {
2021-07-26 07:10:02 +00:00
filterText: "",
mappings: [
2021-07-09 17:19:45 +00:00
{
section: "General",
shortcuts: [
{
keys: [getPlatformSpecialKey(), "G"],
label: this.$t("send_request"),
},
{
keys: [getPlatformSpecialKey(), "S"],
label: this.$t("save_to_collections"),
},
{
keys: [getPlatformSpecialKey(), "K"],
label: this.$t("copy_request_link"),
},
{
keys: [getPlatformSpecialKey(), "I"],
label: this.$t("reset_request"),
},
],
2021-07-09 17:19:45 +00:00
},
{
section: "Request",
shortcuts: [
{
keys: [getPlatformAlternateKey(), "↑"],
label: this.$t("select_next_method"),
},
{
keys: [getPlatformAlternateKey(), "↓"],
label: this.$t("select_previous_method"),
},
{
keys: [getPlatformAlternateKey(), "G"],
label: this.$t("select_get_method"),
},
{
keys: [getPlatformAlternateKey(), "H"],
label: this.$t("select_head_method"),
},
{
keys: [getPlatformAlternateKey(), "P"],
label: this.$t("select_post_method"),
},
{
keys: [getPlatformAlternateKey(), "U"],
label: this.$t("select_put_method"),
},
{
keys: [getPlatformAlternateKey(), "X"],
label: this.$t("select_delete_method"),
},
],
2021-07-09 17:19:45 +00:00
},
],
}
},
2021-07-24 16:46:48 +00:00
watch: {
$route() {
this.$emit("close")
},
},
2020-12-11 10:29:03 +00:00
methods: {
2021-07-24 16:46:48 +00:00
close() {
this.$emit("close")
2020-12-11 10:29:03 +00:00
},
},
}
</script>
<style lang="scss" scoped>
.shortcut-key {
@apply bg-dividerLight;
@apply rounded;
@apply ml-2;
@apply py-1;
@apply px-2;
@apply inline-flex;
}
</style>