Merge pull request #1125 from akhilmhdh/fix/deep-main-page

fix: resolved nav header secret path issues
This commit is contained in:
Maidul Islam
2023-10-27 10:01:57 -04:00
committed by GitHub
2 changed files with 7 additions and 15 deletions

View File

@@ -131,7 +131,7 @@ export default function NavHeader({
{isFolderMode &&
secretPathSegments?.map((folderName, index) => {
const query = { ...router.query };
query.secretPath = secretPathSegments.slice(0, index + 1);
query.secretPath = `/${secretPathSegments.slice(0, index + 1).join("/")}`;
return (
<div

View File

@@ -111,23 +111,15 @@ export const SecretOverviewPage = () => {
try {
// create folder if not existing
if (secretPath !== "/") {
// /hello/world -> ["", "hello","world"]
const path = secretPath.split("/");
// if its empty string on join use and OR gate to convert to /
// /hello
const directory =
path
.slice(0, -1)
.reduce(
(prev, curr, index, arr) => prev + (index + 1 === arr.length ? curr : `/${curr}`),
""
) || "/";
const folderName = path.at(-1); // world
if (folderName && directory) {
// /hello/world -> [hello","world"]
const pathSegment = secretPath.split("/").filter(Boolean);
const parentPath = `/${pathSegment.slice(0, -1).join("/")}`;
const folderName = pathSegment.at(-1);
if (folderName && parentPath) {
await createFolder({
workspaceId,
environment: env,
directory,
directory: parentPath,
folderName
});
}