Skip to content

Commit

Permalink
Merge pull request #689 from pmcelhaney/gui
Browse files Browse the repository at this point in the history
spruce up the dashboard
  • Loading branch information
pmcelhaney committed Dec 23, 2023
2 parents 3aa5e09 + 9042128 commit c6d0ebb
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-brooms-own.md
@@ -0,0 +1,5 @@
---
"counterfact": minor
---

Until now the dashboard hasn't gotten much attention. Added a logo and took some baby steps toward the planned design. https://excalidraw.com/#json=THGkyuKCGr_69fFqUrghd,ecIPAvDtoAOajwZ9G4m3sg
5 changes: 5 additions & 0 deletions .changeset/twelve-ducks-reflect.md
@@ -0,0 +1,5 @@
---
"counterfact": patch
---

fix links to open in VSCode
162 changes: 144 additions & 18 deletions src/client/index.html.hbs

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions src/server/module-tree.ts
@@ -1,5 +1,10 @@
import type { Module } from "./registry.js";

interface Route {
methods: { [key: string]: string };
path: string;
}

interface File {
isWildcard: boolean;
module: Module;
Expand Down Expand Up @@ -206,16 +211,23 @@ export class ModuleTree {
);
}

public get routes(): string[] {
const routes: string[] = [];
public get routes(): Route[] {
const routes: Route[] = [];

function traverse(directory: Directory, path: string) {
Object.values(directory.directories).forEach((subdirectory) => {
traverse(subdirectory, `${path}/${subdirectory.rawName}`);
});

Object.values(directory.files).forEach((file) => {
routes.push(`${path}/${file.rawName}`);
const methods: [string, string][] = Object.entries(file.module).map(
([method, implementation]) => [method, String(implementation)],
);

routes.push({
methods: Object.fromEntries(methods),
path: `${path}/${file.rawName}`,
});
});
}

Expand All @@ -228,7 +240,7 @@ export class ModuleTree {

// eslint-disable-next-line etc/no-assign-mutated-array
return routes.sort((first, second) =>
stripBrackets(first).localeCompare(stripBrackets(second)),
stripBrackets(first.path).localeCompare(stripBrackets(second.path)),
);
}
}
7 changes: 6 additions & 1 deletion test/server/module-tree.test.ts
Expand Up @@ -106,6 +106,11 @@ it("has all of the routes", () => {
add(moduleTree, "/a/b", "b");
add(moduleTree, "/a/{b}", "b");
add(moduleTree, "/c", "c");
expect(moduleTree.routes).toEqual(["/a", "/a/b", "/a/{b}", "/c"]);
expect(moduleTree.routes.map((route) => route.path)).toEqual([
"/a",
"/a/b",
"/a/{b}",
"/c",
]);
});
export default ModuleTree;
2 changes: 1 addition & 1 deletion test/server/registry.test.ts
Expand Up @@ -143,7 +143,7 @@ describe("a registry", () => {
registry.add("/c/{b}", {});
registry.add("/c/c", {});

expect(registry.routes).toStrictEqual([
expect(registry.routes.map((route) => route.path)).toStrictEqual([
"/a",
"/a/in/order",
"/b",
Expand Down

0 comments on commit c6d0ebb

Please sign in to comment.