Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/persistant annotations #85

Closed
wants to merge 18 commits into from

Conversation

BrianWhitneyAI
Copy link
Contributor

Description of Changes

This PR proposes prioritizing recently used Groups, Filters, and Sorts in the ordering of their respective selection dropdowns ( resolves #57 ). This PR is a continuation of #76 feature/recent-hierarchy-annotations , but is based on the new generalize-ui #79 branch.

Testing

Monitored state through various selections and deselections of Groups, Filters, and Sorts including those with repeated no-file-found options.

I did experience some issues with reloading the application where it would disconnect on the first reload but succeed on the second reload. I believe this is an inherent issue to the base branch or my development environment as is still present without these changes.

This PR also passes tests locally with the exception of

  9) @renderer FileDownloadServiceElectron
       promptForDownloadDirectory
         complains about non-writeable directory when given:
     Error: Trying to stub property 'invoke' of undefined

I believe that this is unique to my local environment since I had to use WSL to run the full test suite. In reviewing this PR it would be super helpful to run tests locally with your dev env just to make sure everything is Ok.

Possible Changes/Adjustments

  1. Limiting the length of recent annotations to a smaller number, I foresee a situation where a user has a lot of interaction and the recent list becomes very long (and unalphabetized) and this feature becomes a hindrance
  2. A adjustment to ‘On Start” state to not include undefined elements.

Copy link
Contributor

@aswallace aswallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran tests locally and they worked fine for me! Left a few comments

  1. Limiting the length of recent annotations to a smaller number, I foresee a situation where a user has a lot of interaction and the recent list becomes very long (and unalphabetized) and this feature becomes a hindrance

I'm not quite sure what you mean by this one. I did quite a bit of interaction locally and the recent list stayed limited, especially since the non-selected recents are hidden when other filters are selected (e.g., if 3 filters are selected then only 2 recents show because of the slicing)

const unavailableAnnotations = useSelector(
selection.selectors.getUnavailableAnnotationsForHierarchy
);
const areAvailableAnnotationLoading = useSelector(
selection.selectors.getAvailableAnnotationsForHierarchyLoading
);
const recentAnnotatitonNames = useSelector(selection.selectors.getRecentAnnotations);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Annotation here and on lines 41 and 70

@@ -76,3 +77,22 @@ export const getUnavailableAnnotationsForHierarchy = createSelector(
allAnnotations.filter((annotation) => !availableAnnotations.includes(annotation.name))
)
);

// COMPOSED SELECTORS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is a duplicate comment since it's already in the composed selectors section

...initialState,
selection: nextSelectionState,
});
describe("Selection reducer", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: can remove lines 43-45 since this should be just be a separate it in the same describe, not a new describe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternately, can keep the previous test format and reduce duplicate code by doing something like

Suggested change
describe("Selection reducer", () => {
describe("Selection reducer", () => {
[
{
actionConstant: selection.actions.SET_ANNOTATION_HIERARCHY,
expectedAction: selection.actions.setAnnotationHierarchy([])
},
{
actionConstant: interaction.actions.SET_FILE_EXPLORER_SERVICE_BASE_URL,
expectedAction: interaction.actions.setFileExplorerServiceBaseUrl("base")
}
].forEach(({actionConstant, expectedAction}) =>
it(`clears selected file state when ${actionConstant} is fired`, () => {
// arrange
const prevSelection = new FileSelection().select({
fileSet: new FileSet(),
index: new NumericRange(1, 3),
sortOrder: 0,
});
const initialSelectionState = {
...selection.initialState,
fileSelection: prevSelection,
};
// act
const nextSelectionState = selection.reducer(
initialSelectionState,
expectedAction
)
const nextSelection = selection.selectors.getFileSelection({
...initialState,
selection: nextSelectionState,
});
// assert
expect(prevSelection.count()).to.equal(3); // consistency check
expect(nextSelection.count()).to.equal(0);
}));

@@ -37,6 +39,7 @@ export default function ListRow(props: Props) {
className={classNames(styles.itemContainer, {
[styles.selected]: item.selected,
[styles.disabled]: item.disabled,
[styles.isBuffer]: item.isBuffer,
})}
menuIconProps={{
iconName: props.subMenuRenderer ? "ChevronRight" : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small visual bug where the ChevronRight icon tries to render on the buffer line for the Filter submenu since it still has a subMenuRenderer prop
Screenshot 2024-05-13 at 4 23 32 PM

const unavailableAnnotations = useSelector(
selection.selectors.getUnavailableAnnotationsForHierarchy
);
const areAvailableAnnotationLoading = useSelector(
selection.selectors.getAvailableAnnotationsForHierarchyLoading
);
const recentAnnotatitonNames = useSelector(selection.selectors.getRecentAnnotations);
const recentAnnotations = recentAnnotatitonNames.flatMap((name) =>
annotations.filter((annotation) => annotation.name === name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if there was a reason we're making recentAnnotations (the one defined in state/store, not the const defined here) an array of strings instead of Annotation[] since the only time the getter is accessed so far is here where it immediately gets used to filter back to type Annotation[]

Edit: I see that it's likely because we're also needing to do comparisons to other types in selections/reducer, so I take back my question 😅 . I'll leave it here for posterity though

import { metadata, selection } from "../../state";
import Annotation, { AnnotationName } from "../../entity/Annotation";
import { selection } from "../../state";
import { uniqBy } from "lodash";

interface Props {
disabledTopLevelAnnotations?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 14: outside the scope of this PR, but I'm unsure if the disableUnavailableAnnotations prop still does anything?

@@ -160,7 +160,8 @@ export default function ListPicker(props: ListPickerProps) {
</div>
<div className={styles.footer}>
<h6>
Displaying {filteredItems.length} of {items.length} Options
{/* (item.lenght -1) to account for buffer in item list. */}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: length

Copy link
Contributor

@SeanLeRoy SeanLeRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think resolving Anya's comments and getting File Name moved would make this good to go to me

@BrianWhitneyAI
Copy link
Contributor Author

closing in favor of #110

@BrianWhitneyAI BrianWhitneyAI deleted the feature/persistant-annotations branch May 21, 2024 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-use columns selected last time
4 participants