Skip to content

Commit

Permalink
Testing: hook some of the new functionality in to the frontend
Browse files Browse the repository at this point in the history
NOT finished, and contains some testing code.
  • Loading branch information
JSKitty committed Nov 18, 2024
1 parent acb7102 commit 1f821a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
9 changes: 9 additions & 0 deletions scripts/alerts/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const props = defineProps({
message: String,
level: String,
notificationCount: Number,
actionName: String,
});
const { message, level } = toRefs(props);
Expand Down Expand Up @@ -49,5 +50,13 @@ const icon = computed(() => {
CLOSE
</button>
</div>
<div v-if="actionName" style="display: flex; flex-direction: column">
<button
class="btn btn-notification-close"
@click="$emit('hideAlert')"
>
{{ actionName }}
</button>
</div>
</div>
</template>
2 changes: 2 additions & 0 deletions scripts/alerts/Alerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ watch(alerts, () => {
message: `${previousAlert.message}`,
show,
count,
actionName: previousAlert.actionName,
// Store original message so we can use it as key.
// This skips the animation in case of multiple errors
original: previousAlert.message,
Expand Down Expand Up @@ -57,6 +58,7 @@ watch(alerts, () => {
:message="alert.value.message"
:level="alert.value.level"
:notificationCount="alert.value.count"
:actionName="alert.value.actionName"
@hideAlert="alert.value.show = false"
/>
</div>
Expand Down
12 changes: 10 additions & 2 deletions scripts/composables/use_alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ export const useAlerts = defineStore('alerts', () => {
* @param {'success'|'info'|'warning'} type - The alert level
* @param {string} message - The message to relay to the user
* @param {number?} timeout - The time in `ms` until the alert expires (Defaults to never expiring)
* @param {string?} actionName - The button title of an optional Action to perform
* @param {function?} actionFunc - The function to execute if the Action button is used
*/
const createAlert = (type, message, timeout) => {
alertController.createAlert(type, message, timeout);
const createAlert = (type, message, timeout, actionName, actionFunc) => {
alertController.createAlert(
type,
message,
timeout,
actionName,
actionFunc
);
};

alertController.subscribe(() => {
Expand Down
7 changes: 6 additions & 1 deletion scripts/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ async function importWallet({
// Start syncing in the background
wallet.sync().then(() => {
createAlert('success', translation.syncStatusFinished, 12500);
createAlert(
'success',
translation.syncStatusFinished,
12500,
'Test Button'
);
});
getEventEmitter().emit('wallet-import');
return true;
Expand Down

0 comments on commit 1f821a4

Please sign in to comment.