Skip to content

Commit

Permalink
Rename message status to level
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jan 25, 2024
1 parent 0f37915 commit 3067ff3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/corpus/sources/SourceView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function loadPlain() {
<MessageAlert
v-if="sources && !metadata"
:message="$t('source.notfound')"
status="error"
level="error"
/>
<table v-if="metadata" class="w-full mt-4">
<tbody>
Expand Down
4 changes: 2 additions & 2 deletions src/message/MessageToasts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ watch(
<template>
<aside class="container max-w-3xl my-4 sticky top-2 z-50">
<div
v-for="{ key, message, status } in alerts"
v-for="{ key, message, level } in alerts"
:key="message"
class="opacity-80 rounded-lg my-2 text-white p-2 shadow-lg flex items-start"
:class="status == 'error' ? ['bg-red-500'] : ['bg-gray-400']"
:class="level == 'error' ? ['bg-red-500'] : ['bg-gray-400']"
>
<div class="flex-1 px-2">
{{ message }}
Expand Down
10 changes: 5 additions & 5 deletions src/message/messenger.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import type { AxiosError } from "axios";
export type Alert = {
key: string;
message: string;
status: Status;
level: MessageLevel;
};

export type Status = "error" | "success" | "debug";
export type MessageLevel = "error" | "success" | "debug";

const alerts = ref<Alert[]>([]);

export default function useMessenger() {
const { t, locale, messages } = useI18n();

function alert(message: string, status?: Status) {
if (message && status !== "success") {
function alert(message: string, level?: MessageLevel) {
if (message && level !== "success") {
// Add message.
alerts.value.push({
key: randomString(),
message,
status: status || "debug",
level: level || "debug",
});
}
}
Expand Down

0 comments on commit 3067ff3

Please sign in to comment.