Skip to content

Commit

Permalink
Correct all explorer bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Aug 30, 2023
1 parent 033d325 commit 712581f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 11 deletions.
25 changes: 23 additions & 2 deletions src/core/usecases/fileExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,33 @@ const privateThunks = {
} satisfies Thunks;

export const thunks = {
"getProjectHomePath":
"getProjectHomeOrPreviousPath":
() =>
(...args) => {
const [, getState] = args;

return `/${projectConfigs.selectors.selectedProject(getState()).bucket}`;
const homeDirectoryPath = `/${projectConfigs.selectors.selectedProject(getState()).bucket}`;

const currentDirectoryPath = getState().fileExplorer.directoryPath;

return_current_path: {

if( currentDirectoryPath === undefined ){
//NOTE: First navigation
break return_current_path;
}

if( !currentDirectoryPath.startsWith(homeDirectoryPath) ){
// The project has changed while we where on another page
break return_current_path;
}

return currentDirectoryPath;

}

return homeDirectoryPath;

},
/**
* NOTE: It IS possible to navigate to a directory currently being renamed or created.
Expand Down
2 changes: 1 addition & 1 deletion src/core/usecases/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ export const thunks = {
"VAULT_TOKEN": (await secretsManager.getToken()).token,
"VAULT_MOUNT": vault.kvEngine,
"VAULT_TOP_DIR": dispatch(
secretExplorer.thunks.getProjectHomePath()
secretExplorer.protectedThunks.getHomeDirectoryPath()
)
};
})(),
Expand Down
42 changes: 36 additions & 6 deletions src/core/usecases/secretExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,47 @@ export const protectedThunks = {
const { loggedSecretClient, loggedExtendedFsApi } = getContext(extraArg);

return { loggedSecretClient, loggedExtendedFsApi };
}
},
"getHomeDirectoryPath":
() =>
(...args) => {
const [, getState] = args;

return `/${projectConfigs.selectors.selectedProject(getState()).vaultTopDir}`;

},
} satisfies Thunks;


export const thunks = {
"getProjectHomePath":
"getProjectHomeOrPreviousPath":
() =>
(...args) => {
const [, getState] = args;
(...args) => {
const [dispatch, getState] = args;

return `/${projectConfigs.selectors.selectedProject(getState()).vaultTopDir}`;
},
const homeDirectoryPath = dispatch(protectedThunks.getHomeDirectoryPath());

const currentDirectoryPath = getState().secretExplorer.directoryPath;

return_current_path: {

if( currentDirectoryPath === undefined ){
//NOTE: First navigation
break return_current_path;
}

if( !currentDirectoryPath.startsWith(homeDirectoryPath) ){
// The project has changed while we where on another page
break return_current_path;
}

return currentDirectoryPath;

}

return homeDirectoryPath;

},
"navigate":
(params: { directoryPath: string }) =>
async (...args) => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/myFiles/MyFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function MyFiles(props: Props) {
useEffect(() => {

if( route.params.path === undefined ){
routes[route.name]({ "path": fileExplorer.getProjectHomePath() }).replace();
routes[route.name]({ "path": fileExplorer.getProjectHomeOrPreviousPath() }).replace();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/mySecrets/MySecrets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function MySecrets(props: Props) {
useEffect(() => {

if( route.params.path === undefined ){
routes[route.name]({ "path": secretExplorer.getProjectHomePath() }).replace();
routes[route.name]({ "path": secretExplorer.getProjectHomeOrPreviousPath() }).replace();
return;
}

Expand Down

0 comments on commit 712581f

Please sign in to comment.