-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add/remove view UI #359
Merged
Merged
Add/remove view UI #359
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1b964c1
start mutations, augment endpoint to accept body
nleroy917 728af38
finish mutations for projectViews
nleroy917 89093b6
Merge pull request #335 from pepkit/322_view_mutations
nleroy917 64f9b08
progress on views modal
sanghoonio 0a10d26
merge dev changes
sanghoonio 13ebee7
project help tab
sanghoonio 0d80cb1
Merge branch 'dev' into dev_sam
sanghoonio 5e5ff08
Merge branch 'dev' into dev_sam
sanghoonio 9601dca
view selector style
sanghoonio 23c09dd
Merge branch 'dev' into dev_sam
sanghoonio 9c708c3
view settings ui and other ui cleanup
sanghoonio 4e468a1
revert view api endpoints
sanghoonio 3d3cb45
add and remove views somewhat work
sanghoonio 559cb5e
view gear button now indicates through color change that a view can b…
sanghoonio d143d5c
added newlines to project.py and models.py to pass lint check
sanghoonio 112a7ac
reformatted with black
sanghoonio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ import { OverlayTrigger, Tooltip } from 'react-bootstrap'; | |
import { useProjectPageView } from '../../hooks/stores/useProjectPageView'; | ||
import { ViewSelector } from '../project/view-selector'; | ||
|
||
type PageView = 'samples' | 'subsamples' | 'config'; | ||
type PageView = 'samples' | 'subsamples' | 'config' | 'help'; | ||
|
||
type NavProps = {}; | ||
type NavProps = { | ||
filteredSamples: string[]; | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
type ViewButtonProps = { | ||
view: PageView; | ||
|
@@ -43,13 +45,13 @@ const ViewButton = (props: ViewButtonProps) => { | |
}; | ||
|
||
export const ProjectDataNav = (props: NavProps) => { | ||
const {} = props; | ||
const { filteredSamples } = props; | ||
|
||
const { pageView, setPageView } = useProjectPageView(); | ||
|
||
return ( | ||
<div className="h-100 w-100 d-flex flex-row align-items-center"> | ||
<div className="mx-2"> | ||
{/*<div className="mx-2"> | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<OverlayTrigger | ||
placement="right" | ||
delay={{ show: 100, hide: 600 }} | ||
|
@@ -62,7 +64,7 @@ export const ProjectDataNav = (props: NavProps) => { | |
> | ||
<i className="bi bi-info-circle text-muted"></i> | ||
</OverlayTrigger> | ||
</div> | ||
</div>*/} | ||
<div | ||
className={ | ||
pageView === 'samples' ? 'border-0 px-1 h-100 text-muted bg-white shadow-sm align-middle' : 'px-1 h-100' | ||
|
@@ -104,7 +106,18 @@ export const ProjectDataNav = (props: NavProps) => { | |
color={pageView === 'config' ? ' text-dark' : ' text-muted'} | ||
/> | ||
</div> | ||
<ViewSelector /> | ||
<div className={pageView === 'help' ? 'border-0 px-1 h-100 text-muted bg-white shadow-sm' : 'px-1 h-100'}> | ||
<ViewButton | ||
view="help" | ||
setPageView={setPageView} | ||
icon="bi bi-question-circle-fill me-2" | ||
text="Help" | ||
isDirty={false} | ||
bold={pageView === 'help' ? ' fw-normal' : ' fw-light'} | ||
color={pageView === 'help' ? ' text-dark' : ' text-muted'} | ||
/> | ||
</div> | ||
Comment on lines
+109
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we think we will still keep this? |
||
<ViewSelector filteredSamples={filteredSamples} /> | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,184 @@ | ||
import { FC, useState } from 'react'; | ||
import { Modal, Tab, Tabs } from 'react-bootstrap'; | ||
import ReactSelect from 'react-select'; | ||
import { Controller, FieldErrors, useForm } from 'react-hook-form'; | ||
import { ErrorMessage } from '@hookform/error-message'; | ||
|
||
|
||
import { useViewMutations } from '../../hooks/mutations/useViewMutations'; | ||
import { useProjectPage } from '../../contexts/project-page-context'; | ||
import { CreateProjectViewRequest, addProjectView, deleteProjectView } from '../../api/project'; | ||
import { useProjectViews } from '../../hooks/queries/useProjectViews'; | ||
import { useProjectSelectedView } from '../../hooks/stores/useProjectSelectedViewStore'; | ||
|
||
interface Props { | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
show: boolean; | ||
onHide: () => void; | ||
filteredSamples: string[]; | ||
} | ||
|
||
export const ViewOptionsModal: FC<Props> = ({ show, onHide, filteredSamples}) => { | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { namespace, projectName, tag } = useProjectPage(); | ||
const { view, setView } = useProjectSelectedView(); | ||
|
||
const projectViewsQuery = useProjectViews(namespace, projectName, tag); | ||
|
||
const projectViewsIsLoading = projectViewsQuery.isLoading; | ||
const projectViews = projectViewsQuery.data; | ||
|
||
const viewMutations = useViewMutations(namespace, projectName, tag); | ||
|
||
const [selectedViewDelete, setSelectedViewDelete] = useState(null); | ||
const [deleteState, setDeleteState] = useState(true); | ||
|
||
type FormValues = { | ||
name: string; | ||
description: string; | ||
}; | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { | ||
register, | ||
reset: resetForm, | ||
formState: { isValid, errors }, | ||
} = useForm<FormValues>({ | ||
mode: 'onChange', | ||
defaultValues: { | ||
name: null, | ||
description: null, | ||
}, | ||
}); | ||
|
||
const handleDeleteView = async() => { | ||
viewMutations.removeViewMutation.mutate(selectedViewDelete.value); | ||
setSelectedViewDelete(null) | ||
}; | ||
|
||
const runValidation = () => { | ||
projectViewsQuery.refetch(); | ||
}; | ||
|
||
const onSubmit = (e) => { | ||
e.preventDefault(); | ||
|
||
const createViewRequest: CreateProjectViewRequest = { | ||
viewName: e.target[0].value, | ||
sampleNames: filteredSamples, // You might want to update this based on your requirements | ||
description: e.target[1].value, | ||
noFail: false | ||
}; | ||
|
||
viewMutations.addViewMutation.mutate(createViewRequest); | ||
|
||
e.target.reset() | ||
resetForm({}, { keepValues: false }) | ||
}; | ||
|
||
return ( | ||
<Modal size="lg" centered animation={false} show={show} onHide={onHide} style={{zIndex: 99999}}> | ||
<Modal.Header closeButton> | ||
<h1 className="modal-title fs-5">Manage Views</h1> | ||
</Modal.Header> | ||
<Modal.Body> | ||
{filteredSamples ? ( | ||
<div className=""> | ||
<h6 className="mb-1">Save View</h6> | ||
<p className="mb-3 text-xs">Save the current filtered sample table state as a view by providing a name (required) and description (optional) for the view.</p> | ||
<form onSubmit={onSubmit}> | ||
<div className="input-group mb-2"> | ||
<span className="input-group-text text-xs">Name</span> | ||
<input | ||
{...register('name', { | ||
required: { | ||
value: true, | ||
message: 'View Name must not be empty.', | ||
}, | ||
pattern: { | ||
value: /^[a-zA-Z0-9_-]+$/, | ||
message: "View Name must contain only alphanumeric characters, '-', or '_'.", | ||
}, | ||
})} | ||
placeholder="..." | ||
type="text" | ||
className="form-control text-xs" | ||
id="view-name" | ||
aria-describedby="view-name-help" | ||
/> | ||
</div> | ||
<div className="input-group"> | ||
<span className="input-group-text text-xs">Description</span> | ||
<input | ||
{...register('desc')} | ||
placeholder="..." | ||
type="text" | ||
className="form-control text-xs" | ||
id="view-description" | ||
aria-describedby="view-description-help" | ||
/> | ||
</div> | ||
<ErrorMessage | ||
errors={errors} | ||
name="name" | ||
render={({ message }) => message ? <p className="text-danger text-xs pt-1 mb-0">{message}</p> : null} | ||
/> | ||
<button | ||
disabled={!isValid || !!errors.name?.message} | ||
type='submit' | ||
className="btn btn-success px-2 mt-3 text-xs"> | ||
<i className="bi bi-plus-lg"></i> Save New View | ||
</button> | ||
</form> | ||
<hr /> | ||
</div> | ||
) : null } | ||
<div className=""> | ||
<h6 className="mb-1">Remove View</h6> | ||
<p className="mb-3 text-xs">Remove an existing view by selecting it from the dropdown menu.</p> | ||
<ReactSelect | ||
styles={{ | ||
control: (provided) => ({ | ||
...provided, | ||
borderRadius: '0.333333em', // Left radii set to 0, right radii kept at 4px | ||
}), | ||
}} | ||
className="top-z w-100 ms-auto" | ||
options={ | ||
projectViews?.views.map((view) => ({ | ||
view: view.name, | ||
description: view.description || 'No description', | ||
value: view.name, | ||
label: `${view.name} | ${view.description || 'No description'}`, | ||
})) || [] | ||
} | ||
onChange={(selectedOption) => { | ||
debugger; | ||
sanghoonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ((selectedOption === null) || (projectViews?.views.length === 0)) { | ||
setSelectedViewDelete(null); | ||
setDeleteState(true); | ||
} else { | ||
setSelectedViewDelete(selectedOption); | ||
setDeleteState(false); | ||
} | ||
}} | ||
isDisabled={projectViews?.views.length === 0 || projectViewsIsLoading} | ||
isClearable | ||
placeholder={ | ||
projectViewsIsLoading | ||
? 'Loading views...' | ||
: projectViews?.views.length === 0 | ||
? 'No views available' | ||
: 'Select a view' | ||
} | ||
value={selectedViewDelete === null ? null : { view: selectedViewDelete.view, description: selectedViewDelete.description, value: selectedViewDelete.value, label: selectedViewDelete.label }} | ||
/> | ||
<button | ||
disabled={deleteState} | ||
onClick={handleDeleteView} | ||
className="btn btn-danger px-2 mt-3 text-xs"> | ||
<i className="bi bi-trash"></i> Remove View | ||
</button> | ||
</div> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we think we are going to remove this?