Skip to content

Commit

Permalink
Remove close button from banner and move to a page action
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac committed Jan 31, 2025
1 parent 478e195 commit 845af74
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 45 deletions.
1 change: 1 addition & 0 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ nav:
header:
setLoginPage: Set as login page
restoreCards: Restore hidden cards
showHideBanner: Show/Hide Banner
userMenu:
preferences: Preferences
accountAndKeys: Account & API Keys
Expand Down
42 changes: 0 additions & 42 deletions shell/components/BannerGraphic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ export default {
data-testid="banner-title"
class="title"
/>
<div
v-if="pref"
class="close-button"
data-testid="graphic-banner-close"
tabindex="0"
:aria-label="t('generic.close')"
role="button"
@click="hide()"
@keyup.enter="hide()"
@keyup.space="hide()"
>
<i class="icon icon-close" />
</div>
</div>
</template>

Expand All @@ -74,35 +61,6 @@ export default {
.banner-graphic {
position: relative;
.close-button {
position: absolute;
visibility: hidden;
&:focus-visible {
@include focus-outline;
outline-offset: 2px;
}
}
&:hover .close-button {
visibility: visible;
position: absolute;
right: 4px;
top: 4px;
font-size: 16px;
padding: 4px;
display: flex;
align-items: center;
cursor: pointer;
opacity: 0.4;
&:hover {
background-color: var(--accent-btn-hover);
color: var(--accent-btn-hover-text);
opacity: 1;
}
}
.graphic {
display: flex;
flex-direction: column;
Expand Down
1 change: 1 addition & 0 deletions shell/config/page-actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const RESET_CARDS_ACTION = 'reset-homepage-cards';
export const SET_LOGIN_ACTION = 'set-as-login';
export const ADD_CUSTOM_NAV_LINK = 'add-custom-nav-link';
export const SHOW_HIDE_BANNER_ACTION = 'toggle-homepage-banner';
31 changes: 28 additions & 3 deletions shell/pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { filterHiddenLocalCluster, filterOnlyKubernetesClusters, paginationFilte
import TabTitle from '@shell/components/TabTitle.vue';
import { ActionFindPageArgs } from '@shell/types/store/dashboard-store.types';
import { RESET_CARDS_ACTION, SET_LOGIN_ACTION } from '@shell/config/page-actions';
import { RESET_CARDS_ACTION, SET_LOGIN_ACTION, SHOW_HIDE_BANNER_ACTION } from '@shell/config/page-actions';
import { STEVE_NAME_COL, STEVE_STATE_COL } from '@shell/config/pagination-table-headers';
import { PaginationParamFilter, FilterArgs, PaginationFilterField, PaginationArgs } from '@shell/types/store/pagination.types';
import ProvCluster from '@shell/models/provisioning.cattle.io.cluster';
Expand Down Expand Up @@ -57,6 +57,10 @@ export default defineComponent({
action: SET_LOGIN_ACTION
},
{ separator: true },
{
labelKey: 'nav.header.showHideBanner',
action: SHOW_HIDE_BANNER_ACTION
},
{
labelKey: 'nav.header.restoreCards',
action: RESET_CARDS_ACTION
Expand Down Expand Up @@ -368,7 +372,11 @@ export default defineComponent({
this.resetCards();
break;
case SET_LOGIN_ACTION:
case SHOW_HIDE_BANNER_ACTION:
this.toggleBanner();
break;
case SET_LOGIN_ACTION:

Check warning on line 379 in shell/pages/home.vue

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8
this.afterLoginRoute = 'home';
break;
Expand Down Expand Up @@ -407,10 +415,27 @@ export default defineComponent({
},
async resetCards() {
await this.$store.dispatch('prefs/set', { key: HIDE_HOME_PAGE_CARDS, value: {} });
const value = this.$store.getters['prefs/get'](HIDE_HOME_PAGE_CARDS) || {};
delete value.setLoginPage;
await this.$store.dispatch('prefs/set', { key: HIDE_HOME_PAGE_CARDS, value });
await this.$store.dispatch('prefs/set', { key: READ_WHATS_NEW, value: '' });
},
async toggleBanner() {
const value = this.$store.getters['prefs/get'](HIDE_HOME_PAGE_CARDS) || {};
if (value.welcomeBanner) {
delete value.welcomeBanner;
} else {
value.welcomeBanner = true;
}
await this.$store.dispatch('prefs/set', { key: HIDE_HOME_PAGE_CARDS, value });
},
async closeSetLoginBanner(retry = 0) {
let value = this.$store.getters['prefs/get'](HIDE_HOME_PAGE_CARDS);
Expand Down

0 comments on commit 845af74

Please sign in to comment.