fix(dashboard): properly determine page links

This commit is contained in:
Jake/Rads 2022-06-27 20:31:33 +02:00
parent b99af6a52e
commit 061c94dab4
2 changed files with 46 additions and 6 deletions

View File

@ -8,7 +8,7 @@
import twemoji from 'twemoji';
import Privacy from './Privacy.svelte';
import MemberEdit from './MemberEdit.svelte';
import { Link } from 'svelte-navigator';
import { Link, useLocation } from 'svelte-navigator';
import { Member, Group } from '../../api/types';
@ -50,6 +50,21 @@
await tick();
el.focus();
}
let location = useLocation()
let pathName = $location.pathname;
function getGroupPageUrl(randomizer?: boolean) {
let str: string;
if (pathName.startsWith("/dash/")) str = "/dash";
else str = "/profile";
str += `/g/${group.id}`;
if (randomizer) str += "/random";
return str;
}
</script>
<CardBody style="border-left: 4px solid #{settings && settings.appearance.color_background ? isPage ? "" : group.color : group.color }; margin: -1rem -1.25rem">
@ -120,11 +135,11 @@
{/if}
{#if !isPage}
<Link to={isPublic ? `/profile/g/${group.id}` : `/dash/g/${group.id}`}><button class="link-button button-right btn btn-primary" tabindex={-1} aria-label="view group page">View page</button></Link>
<Link to={getGroupPageUrl()}><button class="link-button button-right btn btn-primary" tabindex={-1} aria-label="view group page">View page</button></Link>
{:else if !isPublic}
<Link to="/dash?tab=groups"><button class="link-button button-right btn btn-primary" tabindex={-1} aria-label="view group system">View system</button></Link>
{/if}
<Link to={isPublic ? `/profile/g/${group.id}/random` : `/dash/g/${group.id}/random`}><button class="link-button button-right btn btn-secondary" style={isPublic ? "float: none !important; margin-left: 0;" : ""} tabindex={-1} aria-label="randomize group members">Randomize group</button></Link>
<Link to={getGroupPageUrl(true)}><button class="link-button button-right btn btn-secondary" style={isPublic ? "float: none !important; margin-left: 0;" : ""} tabindex={-1} aria-label="randomize group members">Randomize group</button></Link>
{:else if editMode}
<Edit on:deletion bind:group bind:editMode />

View File

@ -12,7 +12,7 @@
import ProxyTags from './ProxyTags.svelte';
import { Member, Group } from '../../api/types';
import { Link } from 'svelte-navigator';
import { Link, useLocation } from 'svelte-navigator';
export let groups: Group[] = [];
export let member: Member;
@ -67,6 +67,31 @@
await tick();
el.focus();
}
let location = useLocation()
let pathName = $location.pathname;
function getMemberPageUrl() {
let str: string;
if (pathName.startsWith("/dash/")) str = "/dash";
else str = "/profile";
str += `/m/${member.id}`;
return str;
}
function getSystemPageUrl() {
let str: string;
if (pathName.startsWith("/dash/")) str = "/dash";
else {
str = "/profile";
str += `/s/${member.system}`;
}
str += "?tab=members";
return str;
}
</script>
<CardBody style="border-left: 4px solid #{settings && settings.appearance.color_background ? isPage ? "" : member.color : member.color }; margin: -1rem -1.25rem">
@ -156,9 +181,9 @@
{#if isMainDash}<Button style="flex: 0" color="secondary" on:click={() => groupMode = true} aria-label="edit member groups">Groups</Button>{/if}
{/if}
{#if !isPage}
<Link to={isPublic ? `/profile/m/${member.id}` : `/dash/m/${member.id}`}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member page">View page</Button></Link>
<Link to={getMemberPageUrl()}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member page">View page</Button></Link>
{:else}
<Link to={isPublic ? `/profile/s/${member.system}?tab=members` : "/dash?tab=members"}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member's system">View system</Button></Link>
<Link to={getSystemPageUrl()}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member's system">View system</Button></Link>
{/if}
{:else if editMode}
<Edit on:deletion bind:member bind:editMode />