mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
Sort files directories first and by name
This commit is contained in:
@@ -14,6 +14,7 @@ export type File = {
|
|||||||
path: string,
|
path: string,
|
||||||
directory: boolean,
|
directory: boolean,
|
||||||
description?: string,
|
description?: string,
|
||||||
|
revision: string,
|
||||||
length: number,
|
length: number,
|
||||||
lastModified?: string,
|
lastModified?: string,
|
||||||
subRepository?: SubRepository, // TODO
|
subRepository?: SubRepository, // TODO
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ class FileTree extends React.Component<Props> {
|
|||||||
baseUrlWithRevision += "/" + tree.revision;
|
baseUrlWithRevision += "/" + tree.revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const compareFiles = function(f1: File, f2: File): number {
|
||||||
|
if (f1.directory) {
|
||||||
|
if (f2.directory) {
|
||||||
|
return f1.name.localeCompare(f2.name);
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (f2.directory) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return f1.name.localeCompare(f2.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const files = [];
|
const files = [];
|
||||||
if (path) {
|
if (path) {
|
||||||
files.push({
|
files.push({
|
||||||
@@ -53,7 +69,8 @@ class FileTree extends React.Component<Props> {
|
|||||||
directory: true
|
directory: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
files.push(...tree._embedded.children);
|
|
||||||
|
files.push(...tree._embedded.children.sort(compareFiles));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className="table table-hover table-sm is-fullwidth">
|
<table className="table table-hover table-sm is-fullwidth">
|
||||||
@@ -79,4 +96,5 @@ class FileTree extends React.Component<Props> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectSheet(styles)(translate("repos")(FileTree));
|
export default injectSheet(styles)(translate("repos")(FileTree));
|
||||||
|
|||||||
Reference in New Issue
Block a user