-
Notifications
You must be signed in to change notification settings - Fork 1k
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
e32fa87
commit bf56062
Showing
9 changed files
with
456 additions
and
338 deletions.
There are no files selected for viewing
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
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
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
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
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,86 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { logout, selectUsername } from "../../store/auth.ts"; | ||
import { | ||
openDialog as openQuotaDialog, | ||
quotaSelector, | ||
} from "../../store/quota.ts"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "../ui/dropdown-menu.tsx"; | ||
import { Button } from "../ui/button.tsx"; | ||
import { | ||
BadgeCent, | ||
Boxes, | ||
CalendarPlus, | ||
Cloud, | ||
ListStart, | ||
Plug, | ||
} from "lucide-react"; | ||
import { openDialog as openSub } from "../../store/subscription.ts"; | ||
import { openDialog as openPackageDialog } from "../../store/package.ts"; | ||
import { openDialog as openSharingDialog } from "../../store/sharing.ts"; | ||
import { openDialog as openApiDialog } from "../../store/api.ts"; | ||
|
||
type MenuBarProps = { | ||
children: React.ReactNode; | ||
className?: string; | ||
}; | ||
|
||
function MenuBar({ children, className }: MenuBarProps) { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
const username = useSelector(selectUsername); | ||
const quota = useSelector(quotaSelector); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger> | ||
<DropdownMenuContent className={className} align={`end`}> | ||
<DropdownMenuLabel className={`username`}>{username}</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem onClick={() => dispatch(openQuotaDialog())}> | ||
<Cloud className={`h-4 w-4 mr-1`} /> | ||
{quota} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => dispatch(openQuotaDialog())}> | ||
<BadgeCent className={`h-4 w-4 mr-1`} /> | ||
{t("quota")} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => dispatch(openSub())}> | ||
<CalendarPlus className={`h-4 w-4 mr-1`} /> | ||
{t("sub.title")} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => dispatch(openPackageDialog())}> | ||
<Boxes className={`h-4 w-4 mr-1`} /> | ||
{t("pkg.title")} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => dispatch(openSharingDialog())}> | ||
<ListStart className={`h-4 w-4 mr-1`} /> | ||
{t("share.manage")} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => dispatch(openApiDialog())}> | ||
<Plug className={`h-4 w-4 mr-1`} /> | ||
{t("api.title")} | ||
</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem asChild> | ||
<Button | ||
size={`sm`} | ||
className={`action-button`} | ||
onClick={() => dispatch(logout())} | ||
> | ||
{t("logout")} | ||
</Button> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} | ||
|
||
export default MenuBar; |
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
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
Oops, something went wrong.