Fix/mini accounts edit (#384)
* fix: mini accounts skin manager Fix opening the skin manager by moving it to the new logic Put all this login into an component so this shouldn't happen again * fix: formatting
This commit is contained in:
parent
dc865c970f
commit
387630537d
6 changed files with 60 additions and 63 deletions
|
|
@ -254,15 +254,9 @@ export type VersionType =
|
|||
*/
|
||||
"old_beta"
|
||||
|
||||
const ARGS_MAP = { 'core':'{"getWorlds":["id"],"setDefaultUser":["uuid"],"getUsers":[],"uploadSkinBytes":["access_token","skin_data","image_format","skin_variant"],"removeCluster":["id"],"launchCluster":["id","uuid"],"searchPackages":["provider","query"],"removeUser":["uuid"],"changeSkin":["access_token","skin_url","skin_variant"],"updateClusterProfile":["name","profile"],"writeSettings":["setting"],"getLoadersForVersion":["mc_version"],"getUsersFromAuthor":["provider","author"],"fetchLoggedInProfile":["access_token"],"getRunningProcessesByClusterId":["cluster_id"],"createSettingsProfile":["name"],"getDefaultUser":["fallback"],"getClusters":[],"getGameVersions":[],"readSettings":[],"getMultiplePackages":["provider","slugs"],"isClusterRunning":["cluster_id"],"getScreenshots":["id"],"getPackageVersions":["provider","slug","mc_version","loader","offset","limit"],"openMsaLogin":[],"downloadPackage":["provider","package_id","version_id","cluster_id","skip_compatibility"],"getLogByName":["id","name"],"getPackageBody":["provider","body"],"installModpack":["modpack","cluster_id"],"fetchMinecraftProfile":["uuid"],"getProfileOrDefault":["name"],"updateClusterById":["id","request"],"createCluster":["options"],"getRunningProcesses":[],"killProcess":["pid"],"getUser":["uuid"],"getPackage":["provider","slug"],"getGlobalProfile":[],"removeCape":["access_token"],"convertUsernameUUID":["username_uuid"],"getClusterById":["id"],"getLogs":["id"],"open":["input"],"changeCape":["access_token","cape_uuid"]}', 'folders':'{"fromCluster":["folder_name"],"openCluster":["folder_name"]}', 'events':'{"message":["event"],"process":["event"],"ingress":["event"]}', 'oneclient':'{"openDevTools":[],"getBundlesFor":["cluster_id"],"getClustersGroupedByMajor":[]}' }
|
||||
const ARGS_MAP = { 'events':'{"ingress":["event"],"process":["event"],"message":["event"]}', 'folders':'{"fromCluster":["folder_name"],"openCluster":["folder_name"]}', 'oneclient':'{"getBundlesFor":["cluster_id"],"getClustersGroupedByMajor":[],"openDevTools":[]}', 'core':'{"launchCluster":["id","uuid"],"getRunningProcesses":[],"getUsersFromAuthor":["provider","author"],"convertUsernameUUID":["username_uuid"],"getUsers":[],"getLogs":["id"],"fetchLoggedInProfile":["access_token"],"getGameVersions":[],"updateClusterProfile":["name","profile"],"getClusterById":["id"],"isClusterRunning":["cluster_id"],"readSettings":[],"getPackage":["provider","slug"],"removeUser":["uuid"],"removeCape":["access_token"],"open":["input"],"killProcess":["pid"],"setDefaultUser":["uuid"],"updateClusterById":["id","request"],"getGlobalProfile":[],"createSettingsProfile":["name"],"searchPackages":["provider","query"],"getLoadersForVersion":["mc_version"],"changeCape":["access_token","cape_uuid"],"getPackageVersions":["provider","slug","mc_version","loader","offset","limit"],"getPackageBody":["provider","body"],"getClusters":[],"downloadPackage":["provider","package_id","version_id","cluster_id","skip_compatibility"],"removeCluster":["id"],"createCluster":["options"],"getUser":["uuid"],"getWorlds":["id"],"getScreenshots":["id"],"getProfileOrDefault":["name"],"getMultiplePackages":["provider","slugs"],"fetchMinecraftProfile":["uuid"],"changeSkin":["access_token","skin_url","skin_variant"],"uploadSkinBytes":["access_token","skin_data","image_format","skin_variant"],"writeSettings":["setting"],"installModpack":["modpack","cluster_id"],"getRunningProcessesByClusterId":["cluster_id"],"getLogByName":["id","name"],"getDefaultUser":["fallback"],"openMsaLogin":[]}' }
|
||||
export type Router = { 'folders': { fromCluster: (folderName: string) => Promise<string>,
|
||||
openCluster: (folderName: string) => Promise<null> },
|
||||
'oneclient': { openDevTools: () => Promise<void>,
|
||||
getClustersGroupedByMajor: () => Promise<Partial<{ [key in number]: ClusterModel[] }>>,
|
||||
getBundlesFor: (clusterId: number) => Promise<ModpackArchive[]> },
|
||||
'events': { ingress: (event: IngressPayload) => Promise<void>,
|
||||
message: (event: MessagePayload) => Promise<void>,
|
||||
process: (event: ProcessPayload) => Promise<void> },
|
||||
'core': { getClusters: () => Promise<ClusterModel[]>,
|
||||
getClusterById: (id: number) => Promise<ClusterModel | null>,
|
||||
removeCluster: (id: number) => Promise<null>,
|
||||
|
|
@ -306,7 +300,13 @@ changeSkin: (accessToken: string, skinUrl: string, skinVariant: SkinVariant) =>
|
|||
changeCape: (accessToken: string, capeUuid: string) => Promise<MojangFullPlayerProfile>,
|
||||
removeCape: (accessToken: string) => Promise<MojangFullPlayerProfile>,
|
||||
convertUsernameUUID: (usernameUuid: string) => Promise<MowojangProfile>,
|
||||
open: (input: string) => Promise<null> } };
|
||||
open: (input: string) => Promise<null> },
|
||||
'events': { ingress: (event: IngressPayload) => Promise<void>,
|
||||
message: (event: MessagePayload) => Promise<void>,
|
||||
process: (event: ProcessPayload) => Promise<void> },
|
||||
'oneclient': { openDevTools: () => Promise<void>,
|
||||
getClustersGroupedByMajor: () => Promise<Partial<{ [key in number]: ClusterModel[] }>>,
|
||||
getBundlesFor: (clusterId: number) => Promise<ModpackArchive[]> } };
|
||||
|
||||
|
||||
export type { InferCommandOutput }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
import type { MinecraftCredentials } from '@/bindings.gen';
|
||||
import { Button } from '@onelauncher/common/components';
|
||||
import { Trash01Icon } from '@untitled-theme/icons-react';
|
||||
import { DialogTrigger } from 'react-aria-components';
|
||||
import { Overlay, RemoveAccountModal } from './overlay';
|
||||
|
||||
export function DeleteAccountButton({ profile, onPress }: { profile: MinecraftCredentials; onPress: () => void }) {
|
||||
return (
|
||||
<DialogTrigger>
|
||||
<Button className="group w-8 h-8" color="ghost" size="icon">
|
||||
<Trash01Icon className="group-hover:stroke-danger" />
|
||||
</Button>
|
||||
|
||||
<Overlay>
|
||||
<RemoveAccountModal onPress={onPress} profile={profile} />
|
||||
</Overlay>
|
||||
</DialogTrigger>
|
||||
);
|
||||
}
|
||||
21
apps/oneclient/frontend/src/components/ManageSkinButton.tsx
Normal file
21
apps/oneclient/frontend/src/components/ManageSkinButton.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import type { MinecraftCredentials } from '@/bindings.gen';
|
||||
import { Button } from '@onelauncher/common/components';
|
||||
import { useNavigate } from '@tanstack/react-router';
|
||||
import { Pencil01Icon } from '@untitled-theme/icons-react';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export function ManageSkinButton({ profile }: { profile: MinecraftCredentials }) {
|
||||
const navigate = useNavigate();
|
||||
const manageSkin = useCallback(() => navigate({ to: `/app/account/skins`, search: { profile } }), [profile, navigate]);
|
||||
|
||||
return (
|
||||
<Button
|
||||
className="group w-8 h-8"
|
||||
color="ghost"
|
||||
onPress={manageSkin}
|
||||
size="icon"
|
||||
>
|
||||
<Pencil01Icon className="group-hover:stroke-brand-hover" />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
export * from './AccountAvatar';
|
||||
export * from './BrowserPackageItem';
|
||||
export * from './DeleteAccountButton';
|
||||
export * from './GameBackground';
|
||||
export * from './Loader';
|
||||
export * from './LogViewer';
|
||||
export * from './ManageSkinButton';
|
||||
export * from './Navbar';
|
||||
export * from './SheetPage';
|
||||
export * from './SkinViewer';
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@ import { bindings } from '@/main';
|
|||
import { useCommand } from '@onelauncher/common';
|
||||
import { Button } from '@onelauncher/common/components';
|
||||
import { Link } from '@tanstack/react-router';
|
||||
import { Pencil01Icon, PlusIcon, Settings01Icon, Trash01Icon } from '@untitled-theme/icons-react';
|
||||
import { PlusIcon, Settings01Icon } from '@untitled-theme/icons-react';
|
||||
import { DialogTrigger } from 'react-aria-components';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import { AccountAvatar } from '../AccountAvatar';
|
||||
import { DeleteAccountButton } from '../DeleteAccountButton';
|
||||
import { ManageSkinButton } from '../ManageSkinButton';
|
||||
import { AddAccountModal } from './AddAccountModal';
|
||||
import { Overlay } from './Overlay';
|
||||
import { Popup } from './Popup';
|
||||
import { RemoveAccountModal } from './RemoveAccountModal';
|
||||
|
||||
export function AccountPopup() {
|
||||
const users = useCommand(['getUsers'], bindings.core.getUsers);
|
||||
|
|
@ -117,26 +118,8 @@ function AccountEntry({
|
|||
</div>
|
||||
|
||||
<div className="flex flex-row items-center">
|
||||
<Link to="/app/accountSkin">
|
||||
<Button
|
||||
className="group w-8 h-8"
|
||||
color="ghost"
|
||||
onClick={onClick}
|
||||
size="icon"
|
||||
>
|
||||
<Pencil01Icon className="group-hover:stroke-brand-hover" />
|
||||
</Button>
|
||||
</Link>
|
||||
|
||||
<DialogTrigger>
|
||||
<Button className="group w-8 h-8" color="ghost" size="icon">
|
||||
<Trash01Icon className="group-hover:stroke-danger" />
|
||||
</Button>
|
||||
|
||||
<Overlay>
|
||||
<RemoveAccountModal onPress={onDelete} profile={user} />
|
||||
</Overlay>
|
||||
</DialogTrigger>
|
||||
<ManageSkinButton profile={user} />
|
||||
<DeleteAccountButton onPress={onDelete} profile={user} />
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
import type { MinecraftCredentials } from '@/bindings.gen';
|
||||
import type { ButtonProps } from '@onelauncher/common/components';
|
||||
import { AccountAvatar, SheetPage, SkinViewer } from '@/components';
|
||||
import { AddAccountModal, RemoveAccountModal } from '@/components/overlay';
|
||||
import { AccountAvatar, DeleteAccountButton, ManageSkinButton, SheetPage, SkinViewer } from '@/components';
|
||||
import { AddAccountModal } from '@/components/overlay';
|
||||
import { Overlay } from '@/components/overlay/Overlay';
|
||||
import { usePlayerProfile } from '@/hooks/usePlayerProfile';
|
||||
import { bindings } from '@/main';
|
||||
import { useCommandMut, useCommandSuspense } from '@onelauncher/common';
|
||||
import { Button } from '@onelauncher/common/components';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { createFileRoute, Link } from '@tanstack/react-router';
|
||||
import { Pencil01Icon, Trash01Icon } from '@untitled-theme/icons-react';
|
||||
import { useCallback } from 'react';
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { Button as AriaButton, DialogTrigger } from 'react-aria-components';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
|
|
@ -130,16 +128,6 @@ function AccountRow({
|
|||
}) {
|
||||
const { isError } = usePlayerProfile(profile.id);
|
||||
|
||||
const navigate = Route.useNavigate();
|
||||
const manageSkin = useCallback(() => {
|
||||
navigate({
|
||||
to: `/app/account/skins`,
|
||||
search: {
|
||||
profile,
|
||||
},
|
||||
});
|
||||
}, [profile, navigate]);
|
||||
|
||||
return (
|
||||
<AriaButton
|
||||
className={twMerge(
|
||||
|
|
@ -164,24 +152,8 @@ function AccountRow({
|
|||
</div>
|
||||
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
<Button
|
||||
className="group w-8 h-8"
|
||||
color="ghost"
|
||||
onPress={manageSkin}
|
||||
size="icon"
|
||||
>
|
||||
<Pencil01Icon className="group-hover:stroke-brand-hover" />
|
||||
</Button>
|
||||
|
||||
<DialogTrigger>
|
||||
<Button className="group w-8 h-8" color="ghost" size="icon">
|
||||
<Trash01Icon className="group-hover:stroke-danger" />
|
||||
</Button>
|
||||
|
||||
<Overlay>
|
||||
<RemoveAccountModal onPress={onDelete} profile={profile} />
|
||||
</Overlay>
|
||||
</DialogTrigger>
|
||||
<ManageSkinButton profile={profile} />
|
||||
<DeleteAccountButton onPress={onDelete} profile={profile} />
|
||||
</div>
|
||||
</div>
|
||||
</AriaButton>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue