Skip to content

Commit

Permalink
fix(webui): only show folder content when clicking opening folders th…
Browse files Browse the repository at this point in the history
…rough graph (#61)

* fix(webui): only show folder content when clicking opening folders through graph

* chore: resolve linting issues
  • Loading branch information
byCedric authored Jul 4, 2024
1 parent 20b8552 commit 20ab2cf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
Binary file modified webui/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion webui/src/app/--/bundles/[bundle]/modules/graph+api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function GET(request: Request, params: Record<'bundle', string>) {
const allModules = Array.from(bundle.modules.values());
const filteredModules = filterModules(allModules, {
filters: moduleFiltersFromParams(query),
searchPath: query.get('path') || undefined,
exactPath: query.get('path') || undefined,
});

const response: ModuleGraphResponse = {
Expand Down
7 changes: 6 additions & 1 deletion webui/src/utils/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,22 @@ export function filterModules(
modules: AtlasModule[],
options: {
filters: ModuleFilters;
/** Search for all modules by path, this matches exact and other matching paths */
searchPath?: string;
/** Search for all modules by exact path, this only matches exact paths */
exactPath?: string;
}
) {
const { filters, searchPath } = options;
const { filters, exactPath, searchPath } = options;

if (searchPath || filters.scope === 'project') {
modules = modules.filter(
(module) =>
(!searchPath || module.relativePath.startsWith(searchPath)) &&
(filters.scope !== 'project' || !module.package)
);
} else if (exactPath) {
modules = modules.filter((module) => module.relativePath.startsWith(`${exactPath}/`));
}

if (filters.include || filters.exclude) {
Expand Down

0 comments on commit 20ab2cf

Please sign in to comment.