Skip to content

Commit

Permalink
chore: v1.5.0 (#177)
Browse files Browse the repository at this point in the history
close #176 
close #117
close #173
close #180

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent 0edaa60 commit 0a8f5bd
Show file tree
Hide file tree
Showing 54 changed files with 696 additions and 273 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
4 changes: 0 additions & 4 deletions apps/app/app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ const reduceMotion = useCookie<boolean>('reduceMotion', {
})
if (import.meta.client) setPrefersReducedMotion(reduceMotion.value)
useSession().refresh()
</script>

<template>
Expand All @@ -61,4 +58,3 @@ useSession().refresh()
</Body>
</Html>
</template>

12 changes: 7 additions & 5 deletions apps/app/app/components/DropdownMenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { publicUser } from '@shelve/types'
import { type publicUser, Role } from '@shelve/types'
import type { Ref } from 'vue'
const navigations = getNavigation('app')
Expand All @@ -19,7 +19,7 @@ const adminNavItem = adminNavigations.map((nav) => {
}
})
const user = useCurrentUser() as Ref<publicUser>
const { loggedIn, user, clear } = useUserSession()
const items = [
[
Expand All @@ -30,13 +30,15 @@ const items = [
}
],
navItem,
adminNavItem,
[
{
label: 'Sign out',
icon: 'heroicons:arrow-left-on-rectangle',
iconClass: 'text-red-500 dark:text-red-500',
click: () => useSession().clear()
click: () => {
navigateTo('/')
clear()
}
}
]
]
Expand All @@ -45,7 +47,7 @@ const items = [
<template>
<div class="flex items-center justify-center">
<UDropdown
v-if="user"
v-if="loggedIn"
:items
:ui="{
background: 'backdrop-blur-md border dark:bg-gray-950/50 dark:border-gray-400/10 bg-white',
Expand Down
5 changes: 4 additions & 1 deletion apps/app/app/components/layout/AuthFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
<span class="text-sm text-tertiary">
Want to go back to homepage ?
<NuxtLink to="/" class="text-primary ml-1 transition duration-300 ease-in-out hover:text-accent">
Go to homepage
Click here
</NuxtLink>
</span>
<SettingThemeToggle />
</div>
<div id="password-mode-toggle">
<!-- password-mode-toggle -->
</div>
</footer>
</div>
</template>
7 changes: 3 additions & 4 deletions apps/app/app/components/layout/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
const navigation = getNavigation('home')
const user = useCurrentUser()
</script>

<template>
Expand All @@ -21,14 +20,14 @@ const user = useCurrentUser()
</div>
<div class="hidden items-center gap-5 sm:flex">
<LandingGithubStar />
<ClientOnly>
<AuthState>
<DropdownMenu />
<template #fallback>
<template #placeholder>
<NuxtLink to="/login" class="btn-primary">
Login
</NuxtLink>
</template>
</ClientOnly>
</AuthState>
</div>
</nav>
</div>
Expand Down
6 changes: 4 additions & 2 deletions apps/app/app/components/layout/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
const { isAdmin } = useSession()
import { Role } from '@shelve/types'
const { user } = useUserSession()
const navigations = getNavigation('app')
const adminNavigations = getNavigation('admin')
Expand Down Expand Up @@ -44,7 +46,7 @@ watch(() => route.path, handleProjectNavigation, { immediate: true })
</div>

<!-- Admin -->
<div v-if="isAdmin" class="flex flex-col gap-2">
<div v-if="user && user.role === Role.ADMIN" class="flex flex-col gap-2">
<UDivider class="my-3" />
<div class="text-xs font-medium text-neutral-500 dark:text-neutral-400">
Admin
Expand Down
2 changes: 1 addition & 1 deletion apps/app/app/components/project/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function importProject() {
size="xs"
icon="heroicons:plus-20-solid"
:loading="projectLoading"
label="Add project"
label="Create project"
@click="isOpen = true"
/>

Expand Down
2 changes: 1 addition & 1 deletion apps/app/app/components/project/MainSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const showDelete = ref(false)
const projectName = ref('')
const project = toRef(props, 'project') as Ref<Project>
const { projectId } = useRoute().params as { projectId: string }
const user = useCurrentUser()
const { user } = useUserSession()
const {
updateProject,
Expand Down
2 changes: 1 addition & 1 deletion apps/app/app/components/team/Members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
removeMember,
} = useTeams()
const user = useCurrentUser()
const { user } = useUserSession()
const roles = [
{
Expand Down
54 changes: 54 additions & 0 deletions apps/app/app/components/token/Create.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script setup lang="ts">
import type { Token } from '@shelve/types'
const tokenName = ref('')
const loading = ref(false)
const emits = defineEmits(['create'])
async function createToken() {
loading.value = true
try {
await $fetch<Token>('/api/tokens', {
method: 'POST',
body: {
name: tokenName.value,
},
})
emits('create')
tokenName.value = ''
toast.success('Token created')
} catch (error) {
toast.error('Failed to create token')
}
loading.value = false
}
</script>

<template>
<div class="hidden items-center justify-end gap-2 sm:flex">
<UPopover :popper="{ arrow: true }">
<UButton variant="solid" color="primary">
Create a token
</UButton>
<template #panel>
<form @submit.prevent="createToken(tokenName)">
<UCard>
<div class="flex flex-col gap-2">
<p class="flex gap-2 text-sm font-semibold leading-6">
Create a token
</p>
<div class="flex gap-2">
<UInput v-model="tokenName" label="Token name" placeholder="Token name" />
<UButton :loading label="Create" type="submit" />
</div>
</div>
</UCard>
</form>
</template>
</UPopover>
</div>
</template>

<style scoped>
</style>
34 changes: 34 additions & 0 deletions apps/app/app/components/token/Toggle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup lang="ts">
const { token } = defineProps<{
token: string
}>()
const visible = ref(false)
const copy = () => {
navigator.clipboard.writeText(token)
toast.success('Token copied to clipboard')
}
</script>

<template>
<div class="flex select-none items-center gap-2">
<UTooltip text="Copy token" class="cursor-pointer text-sm font-semibold leading-6 text-gray-500 dark:text-gray-400">
<span v-if="visible" @click="copy">
{{ token.slice(0, 4) }}...{{ token.slice(-4) }}
</span>
<div v-else @click="copy">
**********
</div>
</UTooltip>
<UIcon
:name="visible ? 'lucide:eye-off' : 'lucide:eye'"
class="cursor-pointer text-gray-500 dark:text-gray-400"
@click="visible = !visible"
/>
</div>
</template>

<style scoped>
</style>
45 changes: 0 additions & 45 deletions apps/app/app/composables/useSession.ts

This file was deleted.

9 changes: 5 additions & 4 deletions apps/app/app/middleware/admin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default defineNuxtRouteMiddleware(async () => {
const { refresh, isAdmin } = useSession()
await refresh()
if (!isAdmin.value) {
import { Role } from '@shelve/types'

export default defineNuxtRouteMiddleware((): Promise<void> => {
const { user } = useUserSession()
if (!user.value.role === Role.ADMIN) {
toast.error('You need to be an admin to access this page.')
return '/app/projects'
}
Expand Down
9 changes: 6 additions & 3 deletions apps/app/app/middleware/guest-only.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export default defineNuxtRouteMiddleware(async () => {
const user = await useSession().refresh()
if (user) return '/app/projects'
export default defineNuxtRouteMiddleware(() => {
const { loggedIn } = useUserSession()

if (loggedIn.value) {
return navigateTo('/app/projects')
}
})
9 changes: 5 additions & 4 deletions apps/app/app/middleware/protected.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default defineNuxtRouteMiddleware(async () => {
const user = await useSession().refresh()
if (!user) {
export default defineNuxtRouteMiddleware(() => {
const { loggedIn } = useUserSession()

if (!loggedIn.value) {
toast.error('You need to be logged in to access this page.')
return '/login'
return navigateTo('/login')
}
})
2 changes: 1 addition & 1 deletion apps/app/app/pages/app/profile.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
const { user } = useSession()
const { user } = useUserSession()
const usePassword = useCookie('usePassword')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Ref } from 'vue'
const { projectId } = useRoute().params
const user = useCurrentUser()
const { user } = useUserSession()
const project = inject('project') as Ref<Project>
const loading = inject('loading') as Ref<boolean>
Expand Down
Loading

0 comments on commit 0a8f5bd

Please sign in to comment.