Skip to content

Commit

Permalink
Removes User Profile Landing
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 24, 2024
1 parent 1d302df commit a16d66b
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 130 deletions.
44 changes: 0 additions & 44 deletions frontend/components/user/Toolbar.vue

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/pages/admin/merge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const reset = () => {
<LinkButton
class="p-button-secondary p-button-text"
icon="pi pi-external-link"
:to="fromUserId ? localePath(`/user/${fromUserId}/edit`) : undefined"
:to="fromUserId ? localePath(`/user/${fromUserId}`) : undefined"
new-tab
/>
</div>
Expand All @@ -82,7 +82,7 @@ const reset = () => {
<LinkButton
class="p-button-secondary p-button-text"
icon="pi pi-external-link"
:to="toUserId ? localePath(`/user/${toUserId}/edit`) : undefined"
:to="toUserId ? localePath(`/user/${toUserId}`) : undefined"
new-tab
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/admin/users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const reset = () => {
always
/>
<LinkButton
:to="localePath(`/user/${slotProps.data.id}/edit`)"
:to="localePath(`/user/${slotProps.data.id}`)"
icon="pi pi-arrow-right"
icon-pos="right"
class="p-button-xs p-button-outlined"
Expand Down
1 change: 0 additions & 1 deletion frontend/pages/user/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const [
<template>
<StandardContent v-if="user">
<TitleBar :title="`User: ${user.name || user.id}`" />
<UserToolbar :user-id="id" />
<NuxtPage />
<StandardDebug
:value="user"
Expand Down
76 changes: 0 additions & 76 deletions frontend/pages/user/[id]/edit.vue

This file was deleted.

86 changes: 80 additions & 6 deletions frontend/pages/user/[id]/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,86 @@
<script setup lang="ts">
</script>
import { userEditor } from '@/lib/editor'
<template>
<div>
TODO(#58) implement some kind of user landing page.
const pactaClient = usePACTA()
const { fromParams } = useURLParams()
const { loading: { withLoading }, permissionDenied: { setPermissionDenied } } = useModal()
const router = useRouter()
const localePath = useLocalePath()
const i18n = useI18n()
const { getMaybeMe } = useSession()
const id = presentOrCheckURL(fromParams('id'))
const prefix = `user/[${id}]`
For admins/the user themselves, this is where their portfolio library would go.
const { isAdmin, maybeMe } = await getMaybeMe()
const { data } = await useSimpleAsyncData(`${prefix}.getUser`, () => pactaClient.findUserById(id))
const {
editorValues,
editorFields,
changes,
saveTooltip,
canSave,
} = userEditor(presentOrCheckURL(data.value, 'no user in response'), i18n)
For other users looking at this it's probably a 404, or just very rudimentary data about a user
const deleteUser = () => withLoading(
() => pactaClient.deleteUser(id).then(() => router.push(localePath('/'))),
`${prefix}.deleteUser`,
)
const saveChanges = () => withLoading(
() => pactaClient.updateUser(id, changes.value)
.then(() => router.push(localePath(`/user/${id}`))),
`${prefix}.saveChanges`,
)
const isMe = computed<boolean>(() => {
const mm = maybeMe.value
return !!mm && id === mm.id
})
if (!isMe.value && !isAdmin.value) {
setPermissionDenied(new Error(`permission denied for user ${id}`))
}
</script>

<template>
<div class="flex flex-column gap-3">
<UserEditor
v-if="editorValues"
v-model:editorValues="editorValues"
:editor-fields="editorFields"
/>
<div class="flex gap-3">
<PVButton
icon="pi pi-trash"
class="p-button-danger"
label="Delete"
@click="deleteUser"
/>
<LinkButton
label="Discard Changes"
icon="pi pi-arrow-left"
class="p-button-secondary p-button-outlined"
:to="localePath(`/user/${id}`)"
/>
<div v-tooltip.bottom="saveTooltip">
<PVButton
:disabled="!canSave"
label="Save Changes"
icon="pi pi-arrow-right"
icon-pos="right"
@click="saveChanges"
/>
</div>
</div>
<StandardDebug
:value="editorFields"
label="Editor Fields"
/>
<StandardDebug
:value="editorValues"
label="Editor Values"
/>
<StandardDebug
:value="changes"
label="Changes"
/>
</div>
</template>

0 comments on commit a16d66b

Please sign in to comment.