-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fbaf7a
commit e14ef67
Showing
8 changed files
with
107 additions
and
58 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/studiocms_dashboard/src/components/DashboardPageHeader.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
import { getLangFromUrl, useTranslations } from 'studiocms:i18n'; | ||
import DiscordLogo from '@studiocms/assets/svgs/discord.svg?raw'; | ||
import { Button } from '@studiocms/ui/components'; | ||
import Icon from '@studiocms/ui/utils/Icon.astro'; | ||
import UserName from './islands/dashboard/UserName.astro'; | ||
const lang = getLangFromUrl(Astro.url); | ||
const t = useTranslations(lang, '@studiocms/dashboard:index'); | ||
--- | ||
|
||
<header class="page-header"> | ||
<div class="page-title-container"> | ||
<h1 class="page-title">{t("welcome-title")}, <UserName server:defer><Fragment slot='fallback' set:text='User' /></UserName></h1> | ||
</div> | ||
<div class="page-actions-container"> | ||
<Button color='primary' variant='flat' as="a" href={'https://chat.studiocms.dev'} target='_blank' rel='noreferrer,noopener'> | ||
<Fragment set:html={DiscordLogo} slot='start-content' /> | ||
{t("title-button:discord")} | ||
</Button> | ||
<Button color='success' variant='flat'> | ||
<Icon name='chat-bubble-oval-left-ellipsis' width={24} height={24} /> | ||
{t("title-button:feedback")} | ||
</Button> | ||
</div> | ||
</header> | ||
<style> | ||
.page-header { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-bottom: 1rem; | ||
width: 100%; | ||
} | ||
|
||
.page-title-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: .5rem; | ||
width: fit-content; | ||
} | ||
|
||
.page-title { | ||
display: block; | ||
width: fit-content; | ||
margin: 0; | ||
} | ||
|
||
.page-actions-container { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
gap: 1rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/studiocms_dashboard/src/components/islands/LoginChecker.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
import { getUserData, verifyUserPermissionLevel } from 'studiocms:auth/lib/user'; | ||
import { StudioCMSRoutes } from 'studiocms:helpers/routemap'; | ||
interface Props { | ||
requiredPermission: 'owner' | 'admin' | 'editor' | 'visitor' | 'unknown'; | ||
} | ||
const { requiredPermission } = Astro.props; | ||
const user = await getUserData(Astro); | ||
const isAuthorized = await verifyUserPermissionLevel(user, requiredPermission); | ||
--- | ||
|
||
<div | ||
style="display: hidden;" | ||
data-isLoggedIn={user.isLoggedIn} | ||
data-authorized={isAuthorized} | ||
data-redirectprofile={StudioCMSRoutes.mainLinks.userProfile} | ||
data-redirectlogin={StudioCMSRoutes.authLinks.loginURL} | ||
/> | ||
|
||
<script> | ||
const authorized = document.querySelector('[data-authorized]') as HTMLDivElement; | ||
|
||
if (authorized && authorized.dataset.isLoggedIn === 'false') { | ||
window.location.href = authorized.dataset.redirectlogin!; | ||
} | ||
|
||
if (authorized && authorized.dataset.authorized === 'false') { | ||
window.location.href = authorized.dataset.redirectprofile!; | ||
} | ||
</script> | ||
|
43 changes: 0 additions & 43 deletions
43
packages/studiocms_dashboard/src/components/islands/dashboard/PageHeader.astro
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
packages/studiocms_dashboard/src/components/islands/dashboard/UserName.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import { getUserData } from 'studiocms:auth/lib/user'; | ||
const user = await getUserData(Astro); | ||
--- | ||
<Fragment set:text={user.user?.name} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
packages/studiocms_dashboard/src/components/islands/sidebar/UserAccount.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
--- | ||
import { getUserData } from 'studiocms:auth/lib/user'; | ||
import { getLabelForPermissionLevel } from 'studiocms:auth/utils/getLabelForPermissionLevel'; | ||
import { StudioCMSRoutes } from 'studiocms:helpers/routemap'; | ||
import { User } from '@studiocms/ui/components'; | ||
const data = await getUserData(Astro); | ||
if (!data.user) { | ||
return Astro.redirect(StudioCMSRoutes.authLinks.loginURL); | ||
} | ||
--- | ||
<User name={data.user.name} description={getLabelForPermissionLevel(data.permissionLevel)} /> | ||
<User name={data.user?.name || "Visitor"} description={getLabelForPermissionLevel(data.permissionLevel)} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters