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

Displaying identifiers for project drop downs #1352

Merged
merged 21 commits into from
Aug 23, 2022

Conversation

ksierks
Copy link
Contributor

@ksierks ksierks commented Aug 9, 2022

Description of changes

What did you change in this pull request? Provide a description of files changed, user interactions changed, etc. Include how to test your changes.

Related issue

#1347

Checklist

Things for the developer to confirm they've done before the PR should be accepted:

  • CHANGELOG.md (and UPGRADING.md if necessary) updated with information for new change.
  • [ ] Tests added (or description of how to test) for any new features.
  • [ ] User documentation updated for UI or technical changes.

@ksierks ksierks added the UI User Interface Issue label Aug 9, 2022
@ksierks ksierks requested a review from joshsadam August 9, 2022 20:41
@joshsadam
Copy link
Contributor

The layout is broken when you select a project:
image

@joshsadam
Copy link
Contributor

Cannot search by project id:
search

@joshsadam
Copy link
Contributor

You should make this into a reusable component so that it can be used in other places. I cannot think of any other ones that need to be replaced right now, but please see if there are any others.

<Select.Option key={project.identifier} value={project.identifier}>
<>
<Text>{project.name}</Text>
<Tag style={{ float: "right" }}>{project.identifier}</Tag>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use float, this is what is causeing the break in your UI when the project is selected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 5cf58ef.

className="t-share-project"
filterOption={false}
onSearch={handleSearch}
onChange={onChange}
defaultValue={targetProject ? targetProject.identifier : null}
/>
>
{options}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you get rid of options attribute on the select and add it here? This is less performant according to their documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 5cf58ef.


const handleSearch = (value) => {
const lowerValue = value.toLowerCase();
const available = projects.filter((project) =>
const filteredProjects = projects.filter((project) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

You should include searching the project id as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 5cf58ef.

<Select.Option key={project.identifier} value={project.identifier}>
<>
<Text>{project.name}</Text>
<Tag style={{ float: "right" }}>{project.identifier}</Tag>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you prepend the id with: id: do the user know what that value is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 5cf58ef.

@joshsadam
Copy link
Contributor

joshsadam commented Aug 10, 2022

3 more things:

  1. Check what happens with long names. You will need to truncate the project name with an ellipsis, and show full with a tooltip or something on hover [This is a really long name that... (id: 2005)].
  2. Try updating this to use TypeScript
  3. TESTING

@ksierks ksierks requested a review from joshsadam August 11, 2022 15:45
Copy link
Contributor

@joshsadam joshsadam left a comment

Choose a reason for hiding this comment

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

A couple more quick changes, sorry I will take a longer look at it in the morning. I also have not tried running it yet.

/**
* React component for displaying a project drop-down menu.
* @param {list} projects - list of projects that is to be displayed
* @param {function} onChange - function that is called when select option has changed
Copy link
Contributor

Choose a reason for hiding this comment

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

When using TypeScript you do not need to add the type also to the JSDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 76ae170.

@@ -692,6 +692,9 @@ project.nav.details=Recent Activity
project.nav.settings=Settings
project.nav.samples.import-metadata=Import Sample Metadata

# Project select
ProjectSelect.label.id=id: {0}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you try using uppercase on the ID, I think it might look better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see ca4b83f.

*/
export function ProjectSelect({
projects,
onChange = undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt you want the onChange to ever be undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 8023bed.

* @returns {JSX.Element}
* @constructor
*/
export function ProjectSelect({
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder we could generalize this to be a select for anything that has an id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so... I just need a good name. Please see d19ce2b.

@@ -11,7 +11,7 @@
import static ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage.waitForTime;

public class ShareSamplesPage {
@FindBy(css = ".t-share-project .ant-select-selection-search-input")
@FindBy(css = ".t-project-select .ant-select-selection-search-input")
private WebElement shareProjectSelect;

@FindBy(className = "ant-select-dropdown")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add testing for searching for a project by it's identifier please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 3aa96c6.

onChange = undefined,
defaultValue = null,
}: ProjectSelectProps): JSX.Element {
const [options, setOptions] = React.useState(() => formatOptions(projects));
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to state what type the options are. I think the best way that I have come across is:

const [options, setOptions] = React.useState<SelectOptions[]>(()=>formatOptions(projects));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 7bfbc4e.

@joshsadam
Copy link
Contributor

This is coming along well, thanks for the updates.  Can you make sure that the project id is displayed after the project is selected, right now just the project name is displayed.

Copy link
Contributor

@joshsadam joshsadam left a comment

Choose a reason for hiding this comment

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

Just a couple more things. also please improve the testing.

*/
export function ProjectSelect({
projects,
onChange = () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just not set a default value for the onChange since it really cannot function without one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 8023bed.

export type Project = { identifier: number; name: string };

export interface ProjectSelectProps extends SelectProps {
projects: Project[];
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to describe all you parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reached out about this comment. Instructed to disregard.

export type Project = { identifier: number; name: string };

export interface ProjectSelectProps extends SelectProps {
projects: Project[];
Copy link
Contributor

Choose a reason for hiding this comment

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

I though you had decided to go with ProjectMinimal here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 76ba866.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After generalising the component, I think picking id and name form IridaBase makes the most sense now. Please see 9942971.

@@ -27,6 +27,8 @@ public void testShareSamplesAsManager() {
samplesPage.shareSamples();

assertFalse(shareSamplesPage.isNextButtonEnabled(), "");
shareSamplesPage.searchForProject("2");
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not really count as searching for a project by it's identifier since the project name also contains a 2. What I would like to see is a completely different name from the identifier and confirm that the id is present in the tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see 0d340a1.

@ksierks ksierks requested a review from joshsadam August 16, 2022 19:20
Copy link
Contributor

@joshsadam joshsadam left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for all the changes.

@joshsadam joshsadam merged commit 318e94a into development Aug 23, 2022
@ksierks ksierks deleted the display-id-for-project-drop-downs branch October 7, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI User Interface Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants