-
Notifications
You must be signed in to change notification settings - Fork 31
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
Conversation
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) => |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 5cf58ef.
3 more things:
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 76ae170.
src/main/webapp/resources/js/components/project/ProjectSelect.tsx
Outdated
Show resolved
Hide resolved
@@ -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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 7bfbc4e.
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. |
There was a problem hiding this 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 = () => {}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 76ba866.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see 0d340a1.
There was a problem hiding this 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.
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:
[ ] Tests added (or description of how to test) for any new features.[ ] User documentation updated for UI or technical changes.