Skip to content

Commit

Permalink
fix: implement breaking webgen changes and fix wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
GregTCLTK committed Jan 21, 2024
1 parent db2152f commit e0a9566
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pages/hosting/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const MB = 1000000;

export const state = asState({
loaded: false,
servers: <(Server)[]>[],
servers: <Server[]>[],
meta: <Meta>undefined!
});

Expand Down
2 changes: 1 addition & 1 deletion pages/hosting/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { state } from "./data.ts";
import { canWriteInFolder, currentFiles } from "./views/state.ts";

export async function refreshState() {
state.servers = asState((await API.hosting.servers()).map(x => asState(x)));
state.servers = asState(await API.hosting.servers());
state.meta = asState(await API.hosting.meta());
}

Expand Down
6 changes: 3 additions & 3 deletions pages/hosting/modrinth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function find(versions: string[], type: ServerTypes, offset = 0, limit = 2
path.searchParams.set("offset", offset.toString());

const json = await retry<SearchResponse>(async () => {
const response = await pipeline.fetch(SchedulerPriority.High, path.toString());
const response = await pipeline.fetch(SchedulerPriority.High, path.toString()).promise;
assert(response.ok);
return response.json();
});
Expand All @@ -105,7 +105,7 @@ async function getLatestDownload(versions: string[], type: ServerTypes, projecti
path.searchParams.set("game_versions", JSON.stringify(versions));

const json = await retry(async () => {
const response = await pipeline.fetch(SchedulerPriority.Low, path.toString());
const response = await pipeline.fetch(SchedulerPriority.Low, path.toString()).promise;
assert(response.ok);
return response.json();
});
Expand All @@ -118,7 +118,7 @@ async function getLatestDownload(versions: string[], type: ServerTypes, projecti
async function getSpecificDownload(versionId: string) {
const path = new URL(`${apiUrl}/version/${versionId}`);
const json = await retry(async () => {
const response = await pipeline.fetch(SchedulerPriority.High, path.toString());
const response = await pipeline.fetch(SchedulerPriority.High, path.toString()).promise;
assert(response.ok);
return response.json();
});
Expand Down
1 change: 1 addition & 0 deletions pages/hosting/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const labels = {
suspended: "Suspended",
"contact-support": "Contact Support",
maintenance: "Maintenance",
disabled: "Disabled",
} satisfies Record<Server[ "labels" ][ number ], string>;

export const auditLabels = {
Expand Down
2 changes: 1 addition & 1 deletion pages/hosting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type GridItem = Component | [ settings: {

export type RemotePath = {
name: string;
size?: string;
size?: number;
canWrite?: boolean;
lastModified?: number;
fileMimeType?: string;
Expand Down
2 changes: 1 addition & 1 deletion pages/hosting/views/ServerStaticInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { calculateUptime } from "shared/uptime.ts";
import { format } from "std/fmt/bytes.ts";
import { asRef, BasicLabel, Component, Entry, Grid, ref, refMerge, StateHandler } from "webgen/mod.ts";
import { Server } from "../../../spec/music.ts";
import { calculateUptime } from "../../shared/uptime.ts";
import { MB } from "../data.ts";
import { GridItem } from "../types.ts";
import { ChangeStateButton } from "./changeStateButton.ts";
Expand Down
2 changes: 1 addition & 1 deletion pages/hosting/views/dialogs/deleteServerDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const deleteServerDialog = (serverId: string) => {
Button("Cancel")
.setStyle(ButtonStyle.Inline)
.onClick(() => sheet.close()),
Button("Delete").setColor(Color.Critical).onClick(async () => {
Button("Delete").setColor(Color.Critical).onPromiseClick(async () => {
await API.hosting.serverId(serverId).delete()
.then(stupidErrorAlert);
location.href = "/hosting";
Expand Down
5 changes: 3 additions & 2 deletions pages/hosting/views/pathNavigation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, Button, ButtonStyle, Component, Custom, Grid, loadingWheel } from "webgen/mod.ts";
import { Box, Button, ButtonStyle, Custom, Grid, loadingWheel } from "webgen/mod.ts";
import { listFiles } from "../loading.ts";
import { GridItem } from "../types.ts";
import { loading, path } from "./state.ts";

export function pathNavigation(): Component | [ settings: { width?: number | undefined; heigth?: number | undefined; }, element: Component ] {
export function pathNavigation(): GridItem {
return path.map(list => Grid(
...list.split("/").filter((_, index, list) => (list.length - 1) != index).map((item, currentIndex, list) => Button(item || 'home')
.setStyle(ButtonStyle.Secondary)
Expand Down
2 changes: 1 addition & 1 deletion pages/hosting/views/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const creationView = () => creationState.$loading.map(loading => {
Spacer(),
Button("Submit").onClick(async () => {
const { error, validate } = Validate(
state,
data,
serverCreate
);
const validation = validate();
Expand Down

0 comments on commit e0a9566

Please sign in to comment.