Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function AddConfigurationModal({
onClick={handleClickedOutside}
>
<div className="bg-background border-border relative h-100 w-1/3 min-w-200 rounded-lg border p-6 shadow-lg">
<h2 className="mb-4 text-lg font-semibold">Add Configuration</h2>
<h2 className="mb-4 text-lg font-semibold">Add File</h2>
<p className="mb-4">Add a new configuration file.</p>

<div className="mb-4 flex items-center gap-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function ConfigurationOverview() {

const xmlFiles = collectXmlFiles(configurationDirectory)
return xmlFiles.map((file) => {
const relativePath = toRelativePath(file.path, 'src/main/configurations/') ?? file.name
const relativePath = toRelativePath(file.path, `${configurationDirectory.path}/`) ?? file.name
return { ...file, relativePath, path: file.path }
})
}, [tree, currentConfigurationProject])
Expand Down
23 changes: 0 additions & 23 deletions src/main/frontend/app/utils/path-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { ConfigurationProject } from '~/types/project.types'

/**
* Extracts the portion of a path after the first occurrence of a marker segment.
* Returns null if the marker is not found.
Expand All @@ -9,24 +7,3 @@ export function toRelativePath(absolutePath: string, marker: string): string | n
const idx = normalized.indexOf(marker)
return idx === -1 ? null : normalized.slice(idx + marker.length)
Comment thread
Matthbo marked this conversation as resolved.
Outdated
}

/**
* Converts a file path to a project-relative path for display.
* Handles both local and cloud environments
*/
export function toProjectRelativePath(absolutePath: string, project: ConfigurationProject): string {
const path = absolutePath.replaceAll('\\', '/')
const root = project.rootPath.replaceAll('\\', '/').replace(/^\/+/, '').replace(/\/+$/, '')
const normalizedPath = path.replace(/^\/+/, '')

if (normalizedPath === root) {
return `${project.name}/`
}

const relative = toRelativePath(normalizedPath, `${root}/`)
if (relative !== null) {
return `${project.name}/${relative}`
}

return path
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public ResponseEntity<ConfigurationProjectDTO> cloneProject(@RequestBody Configu
}

@PostMapping("/open")
public ResponseEntity<ConfigurationProjectDTO> openProject(@RequestBody ConfigurationProjectCreateDTO configurationProjectCreateDTO) throws IOException, ApiException {
public ResponseEntity<ConfigurationProjectDTO> openProject(@RequestBody ConfigurationProjectCreateDTO configurationProjectCreateDTO)
throws IOException, ApiException {
ConfigurationProject configurationProject = configurationProjectService.openProjectFromDisk(configurationProjectCreateDTO.rootPath());
recentProjectsService.addRecentProject(configurationProject.getName(), configurationProject.getRootPath());
return ResponseEntity.ok(configurationProjectService.toDto(configurationProject));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public ConfigurationProject openProjectFromDisk(String path) throws IOException,
Path absolutePath = fileSystemStorage.toAbsolutePath(path);
if (!Files.exists(absolutePath) || !Files.isDirectory(absolutePath)) {
throw new ApiException("Project not found at: " + path, HttpStatus.NOT_FOUND);
} else if (!absolutePath.endsWith(CONFIGURATIONS_DIR + "/" + absolutePath.getFileName())) {
Comment thread
Matthbo marked this conversation as resolved.
Outdated
throw new ApiException("Provided path doesn't seem to be a singular configuration", HttpStatus.BAD_REQUEST);
Comment thread
Matthbo marked this conversation as resolved.
Outdated
}
return loadProjectAndCache(path);
}
Expand Down Expand Up @@ -239,8 +241,7 @@ public ConfigurationProjectDTO toDto(ConfigurationProject configurationProject)
Path absolutePath = fileSystemStorage.toAbsolutePath(configurationProject.getRootPath());
boolean isGitRepo = Files.isDirectory(absolutePath.resolve(".git"));

boolean hasStoredToken =
configurationProject.getGitToken() != null && !configurationProject.getGitToken().isBlank();
boolean hasStoredToken = configurationProject.getGitToken() != null && !configurationProject.getGitToken().isBlank();

return new ConfigurationProjectDTO(
configurationProject.getName(),
Expand Down
Loading