Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyro Integration #2503

Open
wants to merge 517 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
517 commits
Select commit Hold shift + click to select a range
e4b0a4d
oops: remove broken eslint config plugin
ferothefox Sep 8, 2024
b0265ee
run lint
ferothefox Sep 8, 2024
2f1c8c5
lint
ferothefox Sep 8, 2024
a8f2aac
lint
ferothefox Sep 8, 2024
3265dc6
lint
ferothefox Sep 8, 2024
8462b9f
disable import/no-unresolved
ferothefox Sep 8, 2024
ff90bcd
test
ferothefox Sep 9, 2024
1430695
undo test
ferothefox Sep 9, 2024
2601ad3
chore: vaporize null err catch
ferothefox Sep 9, 2024
aeaa5cc
address design concerns
ferothefox Sep 9, 2024
a2231df
split files and content pages
ferothefox Sep 9, 2024
a6dc5ef
migrate to <buttonstyled>
ferothefox Sep 9, 2024
d28098b
fix: correctly handle errors from sendPowerAction
ferothefox Sep 9, 2024
cbdd561
put stuff back due to technical complications
ferothefox Sep 9, 2024
524fa4c
refactor: use setup function
ferothefox Sep 9, 2024
f697e64
fix: longstanding bug that prevented ssr from working on root panel page
ferothefox Sep 9, 2024
8fae9ac
chore: fix loading anim
ferothefox Sep 9, 2024
5553224
refactor: use composition api for all servers components
ferothefox Sep 9, 2024
3696dfb
fix padding
ferothefox Sep 9, 2024
eece773
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 10, 2024
4b55dea
lockfile
ferothefox Sep 10, 2024
3260c7b
refactor(frontend): "this-is-fine.gif" is now served from local assets
prplwtf Sep 11, 2024
495fd87
Merge remote-tracking branch 'modrinth-code/main'
ChecksumDev Sep 11, 2024
ee88395
feat(frontend): proper content files split, sidebar improv, console m…
thewander02 Sep 11, 2024
3f0e0c4
fix(frontend): oops
thewander02 Sep 11, 2024
68bf4cc
feat(frontend): Make console taller
prplwtf Sep 11, 2024
632c68f
feat(frontend): Make console slightly less taller
prplwtf Sep 11, 2024
a87766d
fix(frontend): Hide pack ID if empty
prplwtf Sep 11, 2024
d1a6a38
feat(frontend): change font, backup notif
thewander02 Sep 11, 2024
8cddf26
fix(frontend): kill font file, remove from nuxt config
thewander02 Sep 11, 2024
f9010e8
feat(frontend): backup improvements and fixes
thewander02 Sep 11, 2024
e75129c
fix(frontend): darkmode
thewander02 Sep 11, 2024
13df623
feat(frontend): reactive titles on panel pages
ferothefox Sep 11, 2024
c626d84
fix: missing colors in console state pill
ferothefox Sep 11, 2024
9a2a90d
chore: a11y label for copy ip btn
ferothefox Sep 11, 2024
815b380
chore: shrink terminal font size back down
ferothefox Sep 11, 2024
792376d
chore: link World to files page
ferothefox Sep 11, 2024
33148bd
chore: lint
ferothefox Sep 11, 2024
079fcb9
feat(frontend): clearly show modpack in serverlisting
ferothefox Sep 12, 2024
7493ddb
feat(app): initial servers integration
ferothefox Sep 12, 2024
74d59f1
feat(frontend): savebanner, options tab improvements
thewander02 Sep 12, 2024
c90b2fc
feat(frontend): improved mobile support for options
thewander02 Sep 12, 2024
c9f0ba0
feat(frontend): add suspend server to store; account for more props, …
thewander02 Sep 12, 2024
b5e8dfd
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 13, 2024
9a378c5
chore(app): icon
ferothefox Sep 14, 2024
760ee56
chore(app): add pyroloading component
ferothefox Sep 14, 2024
5099c23
chore(app): clean
ferothefox Sep 14, 2024
1031b10
feat(app): make listServers accept auth arg
ferothefox Sep 14, 2024
8bcd3f6
feat(app): basic server listings
ferothefox Sep 14, 2024
b7aa09a
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 14, 2024
04badbd
use staging
ferothefox Sep 14, 2024
27ffca0
feat(app): server listings
ferothefox Sep 14, 2024
40af89b
chore(app): clean
ferothefox Sep 14, 2024
e357f7c
chore(app): lint
ferothefox Sep 14, 2024
d2c441c
.
ferothefox Sep 14, 2024
f101237
asdfkjafsdg
ferothefox Sep 14, 2024
673c4a9
fix(app): use scoped name convention for route names
ferothefox Sep 14, 2024
72dd2af
fix(app): fucking routes
ferothefox Sep 14, 2024
b2c6e48
feat(app): implement rest of routes
ferothefox Sep 14, 2024
c474ced
chore(app): clean
ferothefox Sep 14, 2024
2e3d73e
chore(app): align with desktop design
ferothefox Sep 14, 2024
8dab561
feat(app): add tauri websocket
ferothefox Sep 14, 2024
8dd19f8
chore(app): bump turbo
ferothefox Sep 14, 2024
d46d75f
feat(app): overview
ferothefox Sep 15, 2024
21c490a
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 15, 2024
81310aa
chore(app): clean
ferothefox Sep 15, 2024
24d1a2f
chore(app): consolidate websocket logic
ferothefox Sep 15, 2024
e0f1ade
fix(app): dont use nuxtlink because it doesnt exist
ferothefox Sep 15, 2024
e617754
feat(app): move websockets to separate store
ferothefox Sep 15, 2024
328e7a0
fix(app): issue where ws connections could be duplicated leading to u…
ferothefox Sep 15, 2024
37eb286
feat: intit loader page, various changes & improvements
thewander02 Sep 15, 2024
9edbb30
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 17, 2024
2db0156
feat(frontend): filesystem init function imp, listing & nav
thewander02 Sep 18, 2024
39edd52
style(frontend): File manager entries and breadcrumbs now show the po…
prplwtf Sep 18, 2024
cbb6279
refactor(app): move modrinth credentials-related code to new credenti…
ferothefox Sep 21, 2024
db202f0
fix(app): dumb error appearance
ferothefox Sep 21, 2024
5e49855
fix(app): sending power actions to servers
ferothefox Sep 21, 2024
664f230
chore(app): improve session types
ferothefox Sep 21, 2024
ebde456
chore(global): improve pyrofetch headers type
ferothefox Sep 21, 2024
0ba8204
feat(frontend): major files work (wip), various fixes n improvements
thewander02 Sep 23, 2024
3f73f5f
fix(frontend): lint
ferothefox Sep 23, 2024
081d67d
fix(frontend): lint files page
ferothefox Sep 23, 2024
8477a2a
fix(frontend): typed move modal
ferothefox Sep 23, 2024
c70eb98
chore(app): sync filesystem store changes
ferothefox Sep 23, 2024
fa47548
chore(app): sync override changes
ferothefox Sep 23, 2024
e31d0b5
fix(app): correctly fetch modpack data instead of using retarded rint…
ferothefox Sep 23, 2024
f2a7c1d
fix(app): THEY CALL ME THE TYPESCRIPT GIVER
ferothefox Sep 23, 2024
ed0df6f
chore(app): clean
ferothefox Sep 23, 2024
83d1846
fix(frontend): files fixes
thewander02 Sep 24, 2024
534203e
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 25, 2024
5d33bbc
fix(frontend): linting errors
ferothefox Sep 25, 2024
698b2fa
fix(frontend): files, main page polish, various bug fix's n improveme…
thewander02 Sep 26, 2024
c6dd15e
feat(frontend): files inf scroll, power btns, various changes n fixes
thewander02 Sep 26, 2024
24ab292
chore(frontend): clean
thewander02 Sep 26, 2024
7725796
Add GDPR export (#2461)
Geometrically Sep 27, 2024
3fe6b38
chore: run lint (#2411)
Erb3 Sep 28, 2024
f475d8e
feat(frontend): major files work (upload, rename file editor) WIP, se…
thewander02 Sep 28, 2024
8d48617
Merge remote-tracking branch 'upstream/main'
ferothefox Sep 30, 2024
80133a8
chore: bump turbo
ferothefox Oct 1, 2024
47691a4
feat(frontend): "SOME BULSHIT" ahhhhhhhh
thewander02 Oct 1, 2024
4cc1369
fix(frontend): project data types in serverlisting
ferothefox Oct 1, 2024
2ce98e7
fix(frontend): server action button linting and appearance
ferothefox Oct 1, 2024
00a8717
chore(frontend): snazzify server status pill
ferothefox Oct 1, 2024
3b8eca1
chore(frontend): grammar fix on save banner
ferothefox Oct 1, 2024
e19c129
fix(frontend): use sensible styling for terminal command input
ferothefox Oct 1, 2024
a58ffbf
fix(frontend): bubble up div in properties
ferothefox Oct 1, 2024
6bac98e
feat(frontend): new overview animation
ferothefox Oct 1, 2024
3e3c32c
feat(frontend): subdomains tm, loader page wip, storage fix
thewander02 Oct 1, 2024
782a50a
fix(frontend): sufix .modrinth.gg
thewander02 Oct 1, 2024
6996c34
feat: autocomplete console commands mvp
ChecksumDev Oct 1, 2024
5a00cd8
feat(frontend): everything and nothing tm
thewander02 Oct 1, 2024
2f4e8fc
refactor: inline autocomplete
ChecksumDev Oct 1, 2024
19737da
feat(frontend): command auto complete
thewander02 Oct 1, 2024
6f132de
feat: command-tree autocompletion
ChecksumDev Oct 1, 2024
88ecc23
feat(frontend): v69 million of auto complete asdad
thewander02 Oct 1, 2024
734594d
feat(frontend): fixes across the board, reinstalling pt1 tm, stuff n …
thewander02 Oct 1, 2024
361f56a
fix(frontend): slightly better tree shaking + suggestions, will polis…
ChecksumDev Oct 1, 2024
3497865
feat(frontend): server icons tm
thewander02 Oct 1, 2024
521d979
Merge remote-tracking branch 'upstream/main'
ferothefox Oct 2, 2024
ea692e7
Merge remote-tracking branch 'upstream/main'
ferothefox Oct 3, 2024
c391ada
feat:(frontend): all of the above
thewander02 Oct 3, 2024
1f6a532
feat(frontend): upgrade new server utility
thewander02 Oct 3, 2024
12a1eab
fix(frontend): auth override
thewander02 Oct 3, 2024
d26e73e
fix(frontend): prod 2 electric boogaloo
thewander02 Oct 3, 2024
40e104a
fix(frontend): test if is env
thewander02 Oct 4, 2024
932477c
feat(frontend): refactors and fixes all around tm
thewander02 Oct 4, 2024
2c4ab8d
feat(frontend): fixes and half broken features
thewander02 Oct 5, 2024
502cee9
align designs
ferothefox Oct 5, 2024
d389116
test
ferothefox Oct 5, 2024
6f64669
test
ferothefox Oct 5, 2024
4bc568a
test
ferothefox Oct 5, 2024
0f33ebb
test
ferothefox Oct 5, 2024
4bc7df0
test
ferothefox Oct 5, 2024
5df2cd1
test
ferothefox Oct 5, 2024
8ec5f59
aaa
ferothefox Oct 5, 2024
89405ab
test
ferothefox Oct 5, 2024
8a74b74
Merge remote-tracking branch 'upstream/main'
ferothefox Oct 5, 2024
e3a443b
asdlkfj
ferothefox Oct 5, 2024
073cd5a
feat yuh
thewander02 Oct 5, 2024
d94e28a
oops
ferothefox Oct 5, 2024
f41cd4d
imagine
thewander02 Oct 5, 2024
fff9097
feat: extra port allocations
ChecksumDev Oct 5, 2024
06fbd41
fucking ellie
ferothefox Oct 5, 2024
9472754
kill me
thewander02 Oct 5, 2024
216af67
edit go brrrrr
thewander02 Oct 5, 2024
1251cd8
icon edit hover
thewander02 Oct 5, 2024
f8e21b6
tooltips & stuff
thewander02 Oct 5, 2024
7c63934
clean, motd, loaders
thewander02 Oct 5, 2024
dad7fa1
chore: subdomain > Custom URL
ferothefox Oct 5, 2024
8faf134
chore: do not open file editor for images, jars, etc
ferothefox Oct 5, 2024
c17baa6
fix: file row overflow styling
ferothefox Oct 5, 2024
b46f3ef
feat: show copyable subdomain in server information
ChecksumDev Oct 6, 2024
2723750
feat(frontend): stuff and thing
thewander02 Oct 7, 2024
f794399
chore: align overview skeleton design
ferothefox Oct 7, 2024
44a8f9c
refactor: polling server install status screen
ferothefox Oct 7, 2024
1e3fd2c
chore: uncrunch all servers button
ferothefox Oct 7, 2024
96cb1d5
feat: servericon component
ferothefox Oct 7, 2024
8cd4c16
chore: attempt to mitigate hydration errors
ferothefox Oct 7, 2024
bd6ab6c
FIX POJO
ferothefox Oct 7, 2024
ef42076
chore: clean
ferothefox Oct 7, 2024
eb33453
chore: link file card to files page
ferothefox Oct 7, 2024
09e7b8c
feat: terminal - browser fullscreening functionality
ferothefox Oct 7, 2024
1c60848
fix: terminal text selection regression
ferothefox Oct 7, 2024
7949607
feat(frontend): polish & fixes tm
thewander02 Oct 8, 2024
e12af49
fix: tm
thewander02 Oct 8, 2024
fc34cde
lint n round
thewander02 Oct 8, 2024
630cb40
Merge remote-tracking branch 'upstream/main'
ferothefox Oct 8, 2024
ad5842d
Merge remote-tracking branch 'upstream/main'
ferothefox Oct 8, 2024
de80046
chore: fixup
ferothefox Oct 8, 2024
8e0537a
chore: fixup
ferothefox Oct 8, 2024
49c1cf4
chore: fixup
ferothefox Oct 8, 2024
552aea3
chore: fixup
ferothefox Oct 8, 2024
95e190b
chore: fixup
ferothefox Oct 8, 2024
47c9540
chore: fixup
ferothefox Oct 8, 2024
353c409
chore: fixup
ferothefox Oct 8, 2024
9bb99de
chore: fixup
ferothefox Oct 8, 2024
47a4565
chore: fixup
ferothefox Oct 8, 2024
833d11f
chore: fixup
ferothefox Oct 8, 2024
6fbf950
chore: fixup
ferothefox Oct 8, 2024
9ded3e9
chore: fixup
ferothefox Oct 8, 2024
d14e1a0
chore: fixup
ferothefox Oct 8, 2024
115cd5e
chore: fixup
ferothefox Oct 9, 2024
ae70f54
chore: fixup
ferothefox Oct 9, 2024
86102d9
chore: trigger virtual list height watcher on fullscreen
ferothefox Oct 9, 2024
a8eb9b1
chore: fixup
ferothefox Oct 9, 2024
e51dff1
refactor: initial move loader page to options
ferothefox Oct 9, 2024
0674652
chore: fixup
ferothefox Oct 9, 2024
d4998b1
chore: fixup
ferothefox Oct 9, 2024
ae1dfc1
refactor: async load content
ferothefox Oct 9, 2024
17322ea
chore: fixup
ferothefox Oct 9, 2024
7e9b84b
chore: finalize pre-remote switch
thewander02 Oct 9, 2024
91f70f2
fix(frontend): remove unused showModLabel
thewander02 Oct 9, 2024
7e67e1e
feat: add placeholder to server name input
not-nullptr Oct 9, 2024
54459e0
fix: correct master key
ferothefox Oct 9, 2024
f69062d
chore: hardcode site url
ferothefox Oct 9, 2024
7fa9ddd
feat: improve modal for new allocation
prplwtf Oct 9, 2024
60c23a1
feat: use server icon instead of modpack icon for pyromodal
prplwtf Oct 9, 2024
15cb65a
lint: create allocation modal
prplwtf Oct 9, 2024
329dd73
feat: disable commandInput when server is not running
prplwtf Oct 9, 2024
c7acabd
fix: spelling mistake in server status toasts
not-nullptr Oct 9, 2024
ffc1402
chore: update marketing img
ferothefox Oct 10, 2024
18b180f
chore: clean
ferothefox Oct 10, 2024
bbf5d8a
feat: cards
ferothefox Oct 10, 2024
9be2c0b
fix: lint
ferothefox Oct 10, 2024
a5a619a
fix: lint
ferothefox Oct 10, 2024
0755dfd
feat(frontend): implementation for network & startup tabs, more desig…
thewander02 Oct 10, 2024
7746db7
fix(frontend): prelude sftp, minor fix
thewander02 Oct 10, 2024
fc07b99
Merge branch 'main' into pyro
ferothefox Oct 10, 2024
01d7580
Remove Pyro integration from app
ferothefox Oct 10, 2024
43951f5
Merge branch 'main' into pyro
ferothefox Oct 10, 2024
33872d6
fix lint
ferothefox Oct 10, 2024
8e02f8f
fix(purchasemodal): nullcheck price
ferothefox Oct 11, 2024
763e4ae
feat(marketing): stripe-hooked pricing cards (TYPESCRIPT SOON)
ferothefox Oct 11, 2024
5c3199f
chore: clean
ferothefox Oct 11, 2024
737f2a2
feat: make websocket independent of overview, move state buttons to t…
not-nullptr Oct 11, 2024
f9e38bf
fix: empty container when no allocations
prplwtf Oct 11, 2024
0bed5fb
feat: wip modal consistencies
prplwtf Oct 11, 2024
fb735a1
feat: improve modal styling and consistencies
prplwtf Oct 11, 2024
9b9353d
lint: fix lint
prplwtf Oct 11, 2024
6a29932
Merge branch 'pyro' of github.com:/modrinth/code into pyro
not-nullptr Oct 11, 2024
101cc1d
fix: pyro modal linting
not-nullptr Oct 11, 2024
5095c30
feat: cache server listing
not-nullptr Oct 11, 2024
4adb3d2
feat(frontend): initial migration off pinia to pyroServer wip
thewander02 Oct 11, 2024
6c51295
fix: crash relating to non arbitrary pojos
not-nullptr Oct 11, 2024
8ccb988
Merge branch 'pyro' of github.com:/modrinth/code into pyro
not-nullptr Oct 11, 2024
63953c0
fix: black bg on console whilst loading
not-nullptr Oct 11, 2024
9b07f9f
fix(autocomplete): slicing issues & scroll issues
not-nullptr Oct 11, 2024
645f15f
fix: autocomplete preview with commands starting with `/`
not-nullptr Oct 11, 2024
5afab67
fix(autocomplete): remove logging
not-nullptr Oct 11, 2024
f39fb84
fix: `\n` in logs
not-nullptr Oct 11, 2024
d0b419b
fix: tab contrast, text color for completions
not-nullptr Oct 11, 2024
1f6fe8b
fix: text duplication bug in autocomplete
not-nullptr Oct 11, 2024
f3d3b1c
fix: hydration issue on server listing
not-nullptr Oct 11, 2024
8122c57
fix: scrolling to bottom in server terminal
not-nullptr Oct 11, 2024
b528978
fix: change ">" to "reinstall"
not-nullptr Oct 11, 2024
05c971c
feat: label for fullscreen button
not-nullptr Oct 11, 2024
912b167
feat: hover state for file card
not-nullptr Oct 11, 2024
2531502
feat: active state on console fullscreen btn
not-nullptr Oct 11, 2024
ffb5b46
feat: pyroServer full migration
thewander02 Oct 12, 2024
eeac5e0
fix: tab button on dark mode
not-nullptr Oct 12, 2024
c6da9b7
feat: best suggestion now uses the hovered item, mouse hover items
not-nullptr Oct 12, 2024
e977864
fix: console msgs not sending
not-nullptr Oct 12, 2024
af2662b
fix: pyro logo colour on footer
not-nullptr Oct 12, 2024
043b71f
update billing page
Geometrically Oct 12, 2024
0309615
feat(frontend): centralize server interfacing to cut down on requests
thewander02 Oct 13, 2024
54470b6
refactor: move server creation entirely to labrinth
ChecksumDev Oct 13, 2024
85251f3
chore: properly type websocket, feat: provisioning w/o reload
not-nullptr Oct 13, 2024
1b16cd7
Merge branch 'pyro' of github.com:/modrinth/code into pyro
not-nullptr Oct 13, 2024
f8e3ed8
feat: `/servers/manage` button in user dropdown
not-nullptr Oct 13, 2024
f6aa3ae
feat: redirect to server management page on purchase
not-nullptr Oct 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ generated

# app testing dir
app-playground-data/*

# soley because i need the PORT to be 3002 due to WSL stuff
.env
apps/frontend/.env
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion apps/app-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"@tauri-apps/plugin-os": "^2.0.0-rc.0",
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
"@tauri-apps/plugin-updater": "^2.0.0-rc.0",
"@tauri-apps/plugin-websocket": "2.0.0-rc.1",
"@tauri-apps/plugin-window-state": "^2.0.0-rc.0",
"@vintl/vintl": "^4.4.1",
"ansi-to-html": "^0.7.2",
"dayjs": "^1.11.10",
"floating-vue": "^5.2.2",
"ofetch": "^1.3.4",
Expand All @@ -31,7 +33,8 @@
"vue": "^3.4.21",
"vue-multiselect": "3.0.0",
"vue-router": "4.3.0",
"vue-virtual-scroller": "v2.0.0-beta.8"
"vue-virtual-scroller": "v2.0.0-beta.8",
"vue3-apexcharts": "^1.6.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
Expand Down
164 changes: 164 additions & 0 deletions apps/app-frontend/src/components/ui/NavTabs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<template>
<nav
class="experimental-styles-within relative flex w-fit overflow-clip rounded-full bg-bg-raised p-1 text-sm font-bold"
>
<RouterLink
v-for="(link, index) in filteredLinks"
v-show="link.shown === undefined ? true : link.shown"
:key="index"
ref="tabLinkElements"
:to="query ? (link.href ? `?${query}=${link.href}` : '?') : link.href"
class="button-animation z-[1] flex flex-row items-center gap-2 px-4 py-2 focus:rounded-full"
:class="{
'text-brand': activeIndex === index && !subpageSelected,
'text-contrast': activeIndex === index && subpageSelected,
}"
>
<component :is="link.icon" v-if="link.icon" class="size-5" />
<span class="text-nowrap">{{ link.label }}</span>
</RouterLink>
<div
:class="`navtabs-transition pointer-events-none absolute h-[calc(100%-0.5rem)] overflow-hidden rounded-full p-1 ${subpageSelected ? 'bg-button-bg' : 'bg-brand-highlight'}`"
:style="{
left: sliderLeftPx,
top: sliderTopPx,
right: sliderRightPx,
bottom: sliderBottomPx,
opacity: sliderLeft === 4 && sliderLeft === sliderRight ? 0 : activeIndex === -1 ? 0 : 1,
}"
aria-hidden="true"
></div>
</nav>
</template>

<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute, RouterLink } from 'vue-router'

const route = useRoute()

interface Tab {
label: string
href: string
shown?: boolean
icon?: unknown
subpages?: string[]
}

const props = defineProps<{
links: Tab[]
query?: string
}>()

const sliderLeft = ref(4)
const sliderTop = ref(4)
const sliderRight = ref(4)
const sliderBottom = ref(4)
const activeIndex = ref(-1)
const oldIndex = ref(-1)
const subpageSelected = ref(false)

const filteredLinks = computed(() =>
props.links.filter((x) => (x.shown === undefined ? true : x.shown)),
)
const sliderLeftPx = computed(() => `${sliderLeft.value}px`)
const sliderTopPx = computed(() => `${sliderTop.value}px`)
const sliderRightPx = computed(() => `${sliderRight.value}px`)
const sliderBottomPx = computed(() => `${sliderBottom.value}px`)

function pickLink() {
let index = -1
subpageSelected.value = false
for (let i = filteredLinks.value.length - 1; i >= 0; i--) {
const link = filteredLinks.value[i]
if (decodeURIComponent(route.path) === link.href) {
index = i
break
} else if (
decodeURIComponent(route.path).includes(link.href) ||
(link.subpages &&
link.subpages.some((subpage) => decodeURIComponent(route.path).includes(subpage)))
) {
index = i
subpageSelected.value = true
break
}
}
activeIndex.value = index

if (activeIndex.value !== -1) {
startAnimation()
} else {
oldIndex.value = -1
sliderLeft.value = 0
sliderRight.value = 0
}
}

const tabLinkElements = ref()

function startAnimation() {
const el = tabLinkElements.value[activeIndex.value].$el

if (!el || !el.offsetParent) return

const newValues = {
left: el.offsetLeft,
top: el.offsetTop,
right: el.offsetParent.offsetWidth - el.offsetLeft - el.offsetWidth,
bottom: el.offsetParent.offsetHeight - el.offsetTop - el.offsetHeight,
}

if (sliderLeft.value === 4 && sliderRight.value === 4) {
sliderLeft.value = newValues.left
sliderRight.value = newValues.right
sliderTop.value = newValues.top
sliderBottom.value = newValues.bottom
} else {
const delay = 200

if (newValues.left < sliderLeft.value) {
sliderLeft.value = newValues.left
setTimeout(() => {
sliderRight.value = newValues.right
}, delay)
} else {
sliderRight.value = newValues.right
setTimeout(() => {
sliderLeft.value = newValues.left
}, delay)
}

if (newValues.top < sliderTop.value) {
sliderTop.value = newValues.top
setTimeout(() => {
sliderBottom.value = newValues.bottom
}, delay)
} else {
sliderBottom.value = newValues.bottom
setTimeout(() => {
sliderTop.value = newValues.top
}, delay)
}
}
}

onMounted(() => {
window.addEventListener('resize', pickLink)
pickLink()
})

onUnmounted(() => {
window.removeEventListener('resize', pickLink)
})

watch(route, () => pickLink())
</script>
<style scoped>
.navtabs-transition {
/* Delay on opacity is to hide any jankiness as the page loads */
transition:
all 150ms cubic-bezier(0.4, 0, 0.2, 1) 0s,
opacity 250ms cubic-bezier(0.5, 0, 0.2, 1) 50ms;
}
</style>
1 change: 1 addition & 0 deletions apps/app-frontend/src/helpers/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
55 changes: 55 additions & 0 deletions apps/app-frontend/src/store/credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { get as getCreds } from '../helpers/mr_auth.js'
import { get_user } from '../helpers/cache.js'
import { handleError } from '../store/state'

export interface User {
id: string
username: string
avatar_url: string
bio: string
created: Date
role: string
badges: number
}

export interface Credentials {
session: string
expires: Date
user_id: string
active: boolean
user: User | null
}

export type SessionToken = Credentials['session']

export const useCredentialsStore = defineStore('credentials', () => {
const credentials = ref<Credentials | null>(null)
const error = ref<Error | null>(null)

async function fetchCredentials() {
try {
const creds = await getCreds()
if (creds && creds.user_id) {
creds.user = await get_user(creds.user_id)
}
credentials.value = creds
} catch (err) {
handleError(err)
error.value = err as Error
}
}

function clearCredentials() {
credentials.value = null
error.value = null
}

return {
credentials,
error,
fetchCredentials,
clearCredentials,
}
})
Loading
Loading