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

Refactor common code to use full paths #4393

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

AdityaHegde
Copy link
Collaborator

To replace the left nav with a free form folder structure we need to make sure our code uses paths everywhere instead of mapping name and type to a path. This PR is the 1st step where we update common methods to use paths.

@AdityaHegde AdityaHegde force-pushed the adityahegde/folder-structure-commons-refactor branch from 90db1d2 to 47baed1 Compare March 21, 2024 05:54
Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good 👍

import NavigationMenuItem from "@rilldata/web-common/layout/navigation/NavigationMenuItem.svelte";
import { runtime } from "../../runtime-client/runtime-store";
import { deleteFileArtifact } from "../entity-management/actions";
import { EntityType } from "../entity-management/types";
import { useChartFileNames } from "./selectors";
import { useChartRoutes } from "./selectors";

export let chartName: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than chartName, this should now be chartPath. Then we can use the path directly in the deleteFileArtifact function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. This PR makes an effort to not touch the components to update such params.

Comment on lines +57 to +58
getFileAPIPathFromNameAndType(currentAssetName, entityType),
getFileAPIPathFromNameAndType(values.newName, entityType),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we migrate, the modal should take a fileName as prop, not an assetName

const route = getRouteFromName(getNextEntityName(names, name), type);

await goto(route);
await goto(getNextEntityName(allPaths, name));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we migrate, navigation to the "next entity name" will be confusing in cases where users do not have a sources/, models/, dashboards/ directory structure. So instead, to avoid too much magic in the code, I think we should navigate to the root / in all cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm true. I thought we could navigate to the next file in the folder. But i havent seen any editor do that.

import {
extractFileExtension,
sanitizeEntityName,
} from "web-common/src/features/sources/extract-file-name";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import looks off – shouldn't it include "@rilldata/web-common/..."?

@@ -7,6 +7,7 @@ import { createRuntimeServiceListFiles } from "@rilldata/web-common/runtime-clie
export function useMainEntityFiles(
instanceId: string,
prefix: "sources" | "models" | "dashboards" | "charts" | "custom-dashboards",
transform = (name: string) => name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than this transform parameter, can we instead just edit the createRuntimeServiceListFiles selector function to return file paths not file names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it is still used in a lot of places without the fill path. Lets do that refactor once we get to different entities.

@AdityaHegde AdityaHegde merged commit b41c830 into main Mar 25, 2024
4 checks passed
@AdityaHegde AdityaHegde deleted the adityahegde/folder-structure-commons-refactor branch March 25, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants