mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Updated teams button.
This commit is contained in:
parent
8048bc7866
commit
44393472cf
12 changed files with 46 additions and 55 deletions
|
|
@ -8,13 +8,12 @@ import LanguageButton from 'components/input/LanguageButton';
|
|||
import ProfileButton from 'components/input/ProfileButton';
|
||||
import TeamsButton from 'components/input/TeamsButton';
|
||||
import Icons from 'components/icons';
|
||||
import { useLogin, useMessages, useNavigation, useTeamUrl } from 'components/hooks';
|
||||
import { useMessages, useNavigation, useTeamUrl } from 'components/hooks';
|
||||
import styles from './NavBar.module.css';
|
||||
|
||||
export function NavBar() {
|
||||
const { user } = useLogin();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { pathname } = useNavigation();
|
||||
const { pathname, router } = useNavigation();
|
||||
const { teamId, renderTeamUrl } = useTeamUrl();
|
||||
|
||||
const cloudMode = !!process.env.cloudMode;
|
||||
|
|
@ -60,6 +59,12 @@ export function NavBar() {
|
|||
!cloudMode && { label: formatMessage(labels.logout), url: '/logout' },
|
||||
].filter(n => n);
|
||||
|
||||
const handleTeamChange = (teamId: string) => {
|
||||
const url = teamId ? `/teams/${teamId}` : '/';
|
||||
|
||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.navbar}>
|
||||
<div className={styles.logo}>
|
||||
|
|
@ -83,7 +88,7 @@ export function NavBar() {
|
|||
})}
|
||||
</div>
|
||||
<div className={styles.actions}>
|
||||
{user?.teams?.length && <TeamsButton teamId={teamId} />}
|
||||
<TeamsButton teamId={teamId} onChange={handleTeamChange} />
|
||||
<ThemeButton />
|
||||
<LanguageButton />
|
||||
<ProfileButton />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import DataTable from 'components/common/DataTable';
|
||||
import TeamsTable from 'app/(main)/settings/teams/TeamsTable';
|
||||
import { useTeams } from 'components/hooks';
|
||||
import { useLogin, useTeams } from 'components/hooks';
|
||||
|
||||
export function TeamsDataTable({
|
||||
allowEdit,
|
||||
|
|
@ -9,7 +9,8 @@ export function TeamsDataTable({
|
|||
allowEdit?: boolean;
|
||||
showActions?: boolean;
|
||||
}) {
|
||||
const queryResult = useTeams();
|
||||
const { user } = useLogin();
|
||||
const queryResult = useTeams(user.id);
|
||||
|
||||
return (
|
||||
<DataTable queryResult={queryResult}>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Button, Modal, ModalTrigger, ActionForm } from 'react-basics';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useLogin, useMessages, useModified, useTeamUrl } from 'components/hooks';
|
||||
import { useLogin, useMessages, useModified, useTeams, useTeamUrl } from 'components/hooks';
|
||||
import WebsiteDeleteForm from './WebsiteDeleteForm';
|
||||
import WebsiteResetForm from './WebsiteResetForm';
|
||||
import WebsiteTransferForm from './WebsiteTransferForm';
|
||||
|
|
@ -12,11 +12,12 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
|||
const { touch } = useModified();
|
||||
const { teamId, renderTeamUrl } = useTeamUrl();
|
||||
const router = useRouter();
|
||||
const hasTeams = user?.teams?.length > 0;
|
||||
const { result } = useTeams(user.id);
|
||||
const hasTeams = result?.data?.length > 0;
|
||||
const isTeamOwner =
|
||||
(!teamId && hasTeams) ||
|
||||
(hasTeams &&
|
||||
user?.teams
|
||||
result?.data
|
||||
?.find(({ id }) => id === teamId)
|
||||
?.teamUser.find(({ role, userId }) => role === ROLES.teamOwner && userId === user.id));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue