Skip to content
Merged
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
29 changes: 28 additions & 1 deletion resources/js/components/NoticeDialog.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Link } from '@inertiajs/vue3';
import { X } from 'lucide-vue-next';
import { onMounted, ref, watch } from 'vue';

Expand All @@ -8,6 +9,16 @@ const props = defineProps({

const isVisible = ref(false);

const isInternalLink = (url?: string | null) => {
if (!url) {
return false;
}

const trimmed = url.trim();

return trimmed.startsWith('/') && !trimmed.startsWith('//');
};

const getStorageKey = () => {
return props.notice?.updated_at
? `session_notice_${props.notice.updated_at}`
Expand Down Expand Up @@ -95,11 +106,27 @@ const close = () => {
</p>

<div class="mt-6 flex gap-3">
<Link
v-if="
notice.show_button &&
notice.button_link &&
isInternalLink(notice.button_link)
"
:href="notice.button_link"
@click="close"
class="flex-1 rounded-xl bg-slate-900 px-4 py-2.5 text-center text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-indigo-600 dark:hover:bg-indigo-500"
>
{{ notice.button_title || 'Learn more' }}
</Link>

<a
v-if="notice.show_button && notice.button_link"
v-else-if="
notice.show_button && notice.button_link
"
:href="notice.button_link"
target="_blank"
rel="noopener noreferrer"
@click="close"
class="flex-1 rounded-xl bg-slate-900 px-4 py-2.5 text-center text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-indigo-600 dark:hover:bg-indigo-500"
>
{{ notice.button_title || 'Learn more' }}
Expand Down