Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error message styling #153

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions web/admin/components/icon/cross-octagon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-x-octagon"
>
<polygon
points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"
></polygon>
<line x1="15" y1="9" x2="9" y2="15"></line>
<line x1="9" y1="9" x2="15" y2="15"></line>
</svg>
</template>
9 changes: 7 additions & 2 deletions web/admin/components/shared/card.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<script setup lang="ts">
defineProps<{ noPadding?: boolean }>();
defineProps<{ noPadding?: boolean; variant?: "error" }>();
</script>

<template>
<div
class="border border-gray-300 dark:border-gray-700 rounded-lg"
:class="{ 'px-4 py-3': !noPadding }"
:class="{
'px-4 py-3': !noPadding,
'bg-red-600 bg-opacity-50': variant === 'error',
'flex gap-2 items-center': variant,
}"
>
<icon-cross-octagon v-if="variant === 'error'" />
<slot />
</div>
</template>
4 changes: 2 additions & 2 deletions web/admin/pages/audit-log.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
const api = await useAPI();

const error = ref<string>(null);
const error = ref<string>();

const { auditEvents } = await api.listAuditEvents({}).catch((err) => {
error.value = err.rawMessage;
Expand All @@ -14,7 +14,7 @@ const { auditEvents } = await api.listAuditEvents({}).catch((err) => {

<template>
<div>
<shared-card v-if="error">{{ error }}</shared-card>
<shared-card v-if="error" variant="error">{{ error }}</shared-card>
<div v-else>
<h1 class="text-xl font-bold">Audit log</h1>
<p class="text-gray-600 dark:text-gray-400">
Expand Down
6 changes: 3 additions & 3 deletions web/admin/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Actor, ActorStatus } from "../../proto/bff/v1/moderation_service_pb";
const api = await useAPI();
const pending = ref(0);
const actor = ref<Actor>();
const error = ref<string>(null);
const error = ref<string>();

const nextActor = async () => {
error.value = null;
error.value = "";

const queue = await api
.listActors({ filterStatus: ActorStatus.PENDING })
Expand All @@ -27,7 +27,7 @@ await nextActor();
</script>

<template>
<shared-card v-if="error">{{ error }}</shared-card>
<shared-card v-if="error" variant="error">{{ error }}</shared-card>
<user-card
v-else-if="actor"
:did="actor.did"
Expand Down
10 changes: 5 additions & 5 deletions web/admin/pages/users/[did].vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/act

const api = await useAPI();

const error = ref<string>(null);
const error = ref<string>();

const subject = ref() as Ref<ProfileViewDetailed>;
const agent = newAgent();
Expand All @@ -19,7 +19,7 @@ async function loadProfile() {
const auditEvents: Ref<AuditEvent[]> = ref([]);

async function loadEvents() {
error.value = null;
error.value = "";

const response = await api
.listAuditEvents({
Expand All @@ -35,15 +35,15 @@ async function loadEvents() {
}

async function comment(comment: string) {
error.value = null;
error.value = "";

await api
.createCommentAuditEvent({
subjectDid: subject.value.did,
comment,
})
.catch((err) => {
error.value = { rawMessage: err.rawMessage };
error.value = err.rawMessage;
});

if (!error.value) await loadEvents();
Expand All @@ -59,7 +59,7 @@ await refresh();

<template>
<div>
<shared-card v-if="error">{{ error }}</shared-card>
<shared-card v-if="error" variant="error">{{ error }}</shared-card>
<div v-else>
<user-card
class="mb-5"
Expand Down