-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19bddbb
commit 0faf718
Showing
9 changed files
with
40 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
import { createSelector } from "reselect"; | ||
|
||
import { State } from "../"; | ||
import Annotation, { AnnotationName } from "../../entity/Annotation"; | ||
|
||
// BASIC SELECTORS | ||
export const getAnnotations = (state: State) => state.metadata.annotations; | ||
export const getDataSources = (state: State) => state.metadata.dataSources; | ||
|
||
// COMPOSED SELECTORS | ||
export const getSortedAnnotations = createSelector(getAnnotations, (annotations: Annotation[]) => { | ||
// Sort annotations by file name first then everything else alphabetically | ||
const fileNameAnnotationIndex = annotations.findIndex( | ||
(annotation) => | ||
annotation.name === AnnotationName.FILE_NAME || annotation.name === "File Name" | ||
); | ||
if (fileNameAnnotationIndex === -1) { | ||
return Annotation.sort(annotations); | ||
} | ||
return [ | ||
annotations[fileNameAnnotationIndex], | ||
...Annotation.sort([ | ||
...annotations.slice(0, fileNameAnnotationIndex), | ||
...annotations.slice(fileNameAnnotationIndex + 1), | ||
]), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters