Skip to content

Commit

Permalink
switch to useOverlay
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Mar 1, 2025
1 parent 93fd297 commit 759c205
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 21 deletions.
9 changes: 4 additions & 5 deletions apps/shelve/app/components/ConfirmModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ type ConfirmModalProps = {
defineProps<ConfirmModalProps>()
const modal = useModal()
const emit = defineEmits(['success', 'cancel'])
const emit = defineEmits<{ close: [boolean], success: [void], cancel: [void] }>()
function onSuccess() {
emit('success')
modal.close()
emit('close', false)
}
function onCancel() {
modal.close()
emit('close', false)
}
</script>

<template>
<UModal :title :description>
<UModal :close="{ onClick: () => emit('close', false) }" :title :description>
<template #footer>
<div class="flex w-full justify-end gap-2">
<UButton variant="ghost" @click="onCancel">
Expand Down
1 change: 1 addition & 0 deletions apps/shelve/app/components/layout/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ defineShortcuts({
<input
id="search-input"
v-model="searchQuery"
autocomplete="off"
type="text"
placeholder="Search..."
class="bg-transparent border-none outline-none size-full text-(--ui-text-highlighted) placeholder:text-(--ui-text-muted)"
Expand Down
7 changes: 5 additions & 2 deletions apps/shelve/app/components/variable/Selector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const selectedVariables = defineModel<Variable[]>({ required: true })
const { deleteVariables } = useVariablesService()
const loading = ref(false)
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
const teamEnv = useEnvironments()
function selectAllVisible() {
Expand All @@ -27,7 +30,7 @@ async function deleteSelectedVariables() {
}
function openDeleteModal() {
modal.open(ConfirmModal, {
modal.open({
title: 'Are you sure?',
description: `You are about to delete ${selectedVariables.value.length} variable${selectedVariables.value.length > 1 ? 's' : '' }, this action cannot be undone`,
danger: true,
Expand Down
6 changes: 4 additions & 2 deletions apps/shelve/app/pages/[teamSlug]/environments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ async function deleteEnv(env: Environment) {
await fetchEnvironments()
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
function openDeleteModal(env: Environment) {
if (environments.value.length === 1) {
toast.error('You cannot delete the last environment')
return
}
modal.open(ConfirmModal, {
modal.open({
title: 'Are you sure?',
description: `You are about to delete ${env.name}. This action cannot be undone and all variables associated with this environment will be lost.`,
danger: true,
Expand Down
5 changes: 3 additions & 2 deletions apps/shelve/app/pages/[teamSlug]/members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function changeMemberRole(memberId: number, role: TeamRole) {
})
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
const items = (row: Member) => [
[
Expand Down Expand Up @@ -70,7 +71,7 @@ const items = (row: Member) => [
toast.error('Cannot delete team owner')
return
}
modal.open(ConfirmModal, {
modal.open({
title: 'Are you sure?',
description: `You are about to remove ${row.user.username} from the team.`,
danger: true,
Expand Down
6 changes: 4 additions & 2 deletions apps/shelve/app/pages/[teamSlug]/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ function updateCurrentTeam() {
updateLoading.value = false
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
function deleteCurrentTeam() {
modal.open(ConfirmModal, {
modal.open({
title: 'Delete Team',
description: 'Are you sure you want to delete this team?',
danger: true,
Expand Down
5 changes: 3 additions & 2 deletions apps/shelve/app/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ const columns: TableColumn<User>[] = [
},
]
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
const items = (row: User) => [
[
Expand Down Expand Up @@ -139,7 +140,7 @@ const items = (row: User) => [
toast.error('Cannot delete admin')
return
}
modal.open(ConfirmModal, {
modal.open({
title: 'Are you sure?',
description: `You are about to delete ${row.username ? row.username : row.email}, this action cannot be undone.`,
danger: true,
Expand Down
6 changes: 4 additions & 2 deletions apps/shelve/app/pages/user/integrations/github.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ const manifest = {
}
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
function openDeleteModal(slug: string) {
modal.open(ConfirmModal, {
modal.open({
title: 'Delete Github App',
description: `You are about to delete ${slug}. This action cannot be undone.`,
danger: true,
Expand Down
6 changes: 4 additions & 2 deletions apps/shelve/app/pages/user/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ async function deleteUser() {
await useRouter().push('/login')
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
function deleteAccount() {
modal.open(ConfirmModal, {
modal.open({
title: 'Delete my account',
description: `You are about to delete ${user.value!.username}. This action cannot be undone and all data associated with this account will be lost.`,
danger: true,
Expand Down
5 changes: 3 additions & 2 deletions apps/shelve/app/pages/user/tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const items = (row: Token) => [
label: 'Delete',
icon: 'lucide:trash',
onSelect: () => {
modal.open(ConfirmModal, {
modal.open({
title: 'Are you sure?',
description: `You are about to delete ${row.name} token which is currently ${isTokenActive(row.updatedAt) ? 'active' : 'inactive'}, this action cannot be undone.`,
danger: true,
Expand Down Expand Up @@ -76,7 +76,8 @@ async function fetchTokens() {
loading.value = false
}
const modal = useModal()
const overlay = useOverlay()
const modal = overlay.create(ConfirmModal)
async function deleteToken(token: Token) {
await $fetch(`/api/tokens/${token.id}`, {
Expand Down

0 comments on commit 759c205

Please sign in to comment.