Skip to content

Commit 95167a0

Browse files
8Qbitebkr
authored andcommitted
Enhance EcosystemUpdateIndicator with retry functionality and styling updates
- Refactored EcosystemUpdateIndicator to include a button for retrying ecosystem updates when an error occurs. - Added tooltip support for better user guidance on retry actions. - Updated styles for error indicators in both dark and light themes to improve visibility and user experience. - Introduced a new action in the EcosystemUpdateModule to handle ecosystem schema updates.
1 parent 8a12d0b commit 95167a0

4 files changed

Lines changed: 67 additions & 4 deletions

File tree

src/components/navigation/EcosystemUpdateIndicator.vue

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
<template>
22
<Teleport to="#activity-bar">
3-
<div :class="['status-indicator', { 'status-indicator--error': status.isError }]">
3+
<button
4+
v-if="status.onClick"
5+
type="button"
6+
:class="['activity-bar__action', 'status-indicator', { 'status-indicator--error-action': status.isError }]"
7+
:title="status.tooltip"
8+
@click="status.onClick"
9+
>
10+
<i :class="status.iconClass"></i>
11+
<span class="status-indicator__text">{{ status.text }}</span>
12+
</button>
13+
<div
14+
v-else
15+
:class="['status-indicator', { 'status-indicator--error': status.isError }]"
16+
>
417
<i :class="status.iconClass"></i>
518
<span class="status-indicator__text">{{ status.text }}</span>
619
</div>
@@ -14,12 +27,18 @@ import { State } from '../../store';
1427
1528
const store = getStore<State>();
1629
30+
function retryEcosystemUpdate() {
31+
store.dispatch('ecosystemUpdate/updateEcosystemSchema');
32+
}
33+
1734
const status = computed(() => {
1835
if (store.state.ecosystemUpdate.isInProgress) {
1936
return {
2037
text: "Updating game list",
2138
iconClass: "fas fa-sync-alt fa-spin",
2239
isError: false,
40+
onClick: undefined,
41+
tooltip: undefined,
2342
};
2443
}
2544
@@ -29,13 +48,17 @@ const status = computed(() => {
2948
text: errorMessage,
3049
iconClass: "fas fa-exclamation-circle",
3150
isError: true,
51+
onClick: retryEcosystemUpdate,
52+
tooltip: "Retry game list update",
3253
};
3354
}
3455
3556
return {
3657
text: "You have the latest game list",
3758
iconClass: "fas fa-check",
3859
isError: false,
60+
onClick: undefined,
61+
tooltip: undefined,
3962
};
4063
});
4164
</script>
@@ -57,7 +80,20 @@ const status = computed(() => {
5780
line-height: 1.5;
5881
}
5982
60-
.status-indicator--error {
61-
color: var(--notification-danger, #cc0f35);
83+
.activity-bar__action .status-indicator__text {
84+
padding: 0;
85+
}
86+
87+
.status-indicator--error-action {
88+
margin-left: auto;
89+
color: var(--ecosystem-update-error-text, #a3162f);
90+
background: var(--ecosystem-update-error-background, #fbe4e7);
91+
border: 1px solid var(--ecosystem-update-error-border, #efc2ca);
92+
}
93+
94+
.status-indicator--error-action:hover {
95+
background: var(--ecosystem-update-error-background, #fbe4e7);
96+
border-color: var(--ecosystem-update-error-border, #efc2ca);
97+
color: var(--ecosystem-update-error-text, #a3162f);
6298
}
6399
</style>

src/css/scheme/dark.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272

7373
--code-font-color: #ffb583;
7474
--preview-panel-background-color: #1b2837;
75+
--ecosystem-update-error-text: #ffc5cf;
76+
--ecosystem-update-error-background: #4a1f2a;
77+
--ecosystem-update-error-border: #6d3240;
7578
}
7679

7780
html.html--dark {

src/css/scheme/light.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
--nav-hr-background-color: #ededed;
66
--nav-active-color: rgba(132, 152, 184, 0.2);
77
--nav-active-text-color: #000000;
8+
--ecosystem-update-error-text: #9f1239;
9+
--ecosystem-update-error-background: #fce7ec;
10+
--ecosystem-update-error-border: #f6cbd5;
811
}
912

1013
// custom vars

src/store/modules/EcosystemUpdateModule.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { GetterTree, MutationTree } from 'vuex';
1+
import { ActionTree, GetterTree, MutationTree } from 'vuex';
22

33
import { State as RootState } from '../../store';
4+
import { EcosystemSchema } from '../../model/schema/ThunderstoreSchema';
45

56
export interface EcosystemUpdateState {
67
isInProgress: boolean;
@@ -36,4 +37,24 @@ export const EcosystemUpdateModule = {
3637
state.error = error instanceof Error ? error : new Error(String(error));
3738
},
3839
},
40+
41+
actions: <ActionTree<EcosystemUpdateState, RootState>>{
42+
async updateEcosystemSchema({ commit, state }) {
43+
if (state.isInProgress) {
44+
return;
45+
}
46+
47+
commit('startUpdate');
48+
49+
try {
50+
// Re-evaluate the ecosystem schema. Future remote refresh
51+
// logic should be plugged in here.
52+
void EcosystemSchema.supportedGames;
53+
} catch (e) {
54+
commit('setError', e instanceof Error ? e : new Error(String(e)));
55+
} finally {
56+
commit('finishUpdate');
57+
}
58+
},
59+
},
3960
};

0 commit comments

Comments
 (0)