mirror of https://github.com/rancher/dashboard.git
Replace action menu with new component
Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
This commit is contained in:
parent
7cad4da149
commit
21170cab29
|
|
@ -649,31 +649,6 @@ export default {
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<rc-dropdown>
|
||||
<template #popper>
|
||||
<rc-dropdown-collection>
|
||||
<rc-dropdown-item>
|
||||
Set as login page
|
||||
</rc-dropdown-item>
|
||||
<hr
|
||||
role="separator"
|
||||
aria-orientation="horizontal"
|
||||
>
|
||||
<rc-dropdown-item>
|
||||
Restore hidden cards
|
||||
</rc-dropdown-item>
|
||||
<rc-dropdown-item>
|
||||
Preferences
|
||||
</rc-dropdown-item>
|
||||
<rc-dropdown-item>
|
||||
Account & API Keys
|
||||
</rc-dropdown-item>
|
||||
<rc-dropdown-item>
|
||||
Logout
|
||||
</rc-dropdown-item>
|
||||
</rc-dropdown-collection>
|
||||
</template>
|
||||
</rc-dropdown>
|
||||
<header-page-action-menu v-if="showPageActions" />
|
||||
|
||||
<div class="header-spacer" />
|
||||
|
|
@ -922,6 +897,7 @@ export default {
|
|||
|
||||
.rd-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
padding: 0;
|
||||
|
||||
|
|
@ -1043,10 +1019,6 @@ export default {
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.user.user-menu {
|
||||
padding-top: 9.5px;
|
||||
}
|
||||
|
||||
> .user {
|
||||
outline: none;
|
||||
width: var(--header-height);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
import { useStore } from 'vuex';
|
||||
import { useClickOutside } from '@shell/composables/useClickOutside';
|
||||
import RcDropdown from '@shell/components/RcDropdown.vue';
|
||||
import RcDropdownCollection from '@shell/components/RcDropdownCollection.vue';
|
||||
import RcDropdownItem from '@shell/components/RcDropdownItem.vue';
|
||||
import RcDropdownSeparator from '@shell/components/RcDropdownSeparator.vue';
|
||||
import RcDropdownTrigger from '@shell/components/RcDropdownTrigger.vue';
|
||||
|
||||
const isPageActionMenuOpen = ref(false);
|
||||
|
||||
|
|
@ -15,141 +19,33 @@ const pageAction = (action: string) => {
|
|||
store.dispatch('handlePageAction', action);
|
||||
showPageActionsMenu(false);
|
||||
};
|
||||
|
||||
const target = ref(null);
|
||||
|
||||
useClickOutside(target, () => showPageActionsMenu(false));
|
||||
|
||||
const handleBlurEvent = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Tab') {
|
||||
showPageActionsMenu(false);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dropdown
|
||||
class="actions"
|
||||
:triggers="[]"
|
||||
:shown="isPageActionMenuOpen"
|
||||
:autoHide="false"
|
||||
:flip="false"
|
||||
:placement="'bottom-end'"
|
||||
:distance="-6"
|
||||
:container="'.page-actions'"
|
||||
>
|
||||
<i
|
||||
data-testid="page-actions-menu"
|
||||
class="icon icon-actions"
|
||||
tabindex="0"
|
||||
@keydown="handleBlurEvent"
|
||||
@click="showPageActionsMenu(true)"
|
||||
@focus.capture="showPageActionsMenu(true)"
|
||||
/>
|
||||
|
||||
<rc-dropdown>
|
||||
<rc-dropdown-trigger tertiary>
|
||||
<i
|
||||
data-testid="page-actions-menu"
|
||||
class="icon icon-actions"
|
||||
/>
|
||||
</rc-dropdown-trigger>
|
||||
<template #popper>
|
||||
<div
|
||||
ref="target"
|
||||
class="user-menu"
|
||||
>
|
||||
<ul
|
||||
data-testid="page-actions-dropdown"
|
||||
class="list-unstyled dropdown"
|
||||
<rc-dropdown-collection>
|
||||
<template
|
||||
v-for="(a) in pageActions"
|
||||
:key="a.label"
|
||||
>
|
||||
<li
|
||||
v-for="(a) in pageActions"
|
||||
:key="a.label"
|
||||
class="user-menu-item"
|
||||
<rc-dropdown-item
|
||||
v-if="!a.separator"
|
||||
@click="pageAction(a)"
|
||||
>
|
||||
<a
|
||||
v-if="!a.separator"
|
||||
@click="pageAction(a)"
|
||||
>{{ a.labelKey ? t(a.labelKey) : a.label }}</a>
|
||||
<div
|
||||
v-else
|
||||
class="menu-separator"
|
||||
>
|
||||
<div class="menu-separator-line" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{ a.labelKey ? t(a.labelKey) : a.label }}
|
||||
</rc-dropdown-item>
|
||||
<rc-dropdown-separator
|
||||
v-else
|
||||
/>
|
||||
</template>
|
||||
</rc-dropdown-collection>
|
||||
</template>
|
||||
</v-dropdown>
|
||||
<div class="page-actions">
|
||||
<!--Empty container for mounting popper content-->
|
||||
</div>
|
||||
</rc-dropdown>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-actions :deep(.v-popper__popper) {
|
||||
.v-popper__wrapper {
|
||||
.v-popper__arrow-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.v-popper__inner {
|
||||
padding: 10px 0 10px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.icon-actions:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.user-menu-item {
|
||||
a, &.no-link > span {
|
||||
cursor: pointer;
|
||||
padding: 0px 10px;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--dropdown-hover-bg);
|
||||
color: var(--dropdown-hover-text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
// When the menu item is focused, pop the margin and compensate the padding, so that
|
||||
// the focus border appears within the menu
|
||||
&:focus {
|
||||
margin: 0 2px;
|
||||
padding: 10px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&.no-link > span {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
color: var(--link);
|
||||
}
|
||||
|
||||
div.menu-separator {
|
||||
cursor: default;
|
||||
padding: 4px 0;
|
||||
|
||||
.menu-separator-line {
|
||||
background-color: var(--border);
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list-unstyled {
|
||||
li {
|
||||
a {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
&.user-info {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
padding: 10px 20px;
|
||||
border-bottom: solid 1px var(--border);
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue