-
Notifications
You must be signed in to change notification settings - Fork 1
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
[MINT-3242] Linking Action Menu Add Milestone & Add Sub-Category to Respective Modals && pass down prepopulated categories #1566
base: feature/MINT-3175_mto
Are you sure you want to change the base?
Conversation
…theMatrix row dropdown
… reset after form is submitted
{/* If column is the Actions column, render <ActionMenu /> with custom buttons that updates data state for reordering */} | ||
{column.accessor === 'actions' ? ( | ||
<ActionMenu | ||
rowType={rowType} | ||
MoveUp={ | ||
<Button | ||
type="button" | ||
disabled={ | ||
currentIndex === 0 || | ||
currentIndex === (rowLength || 0) - 1 | ||
} | ||
onClick={e => { | ||
e.stopPropagation(); | ||
setRearrangedData( | ||
moveRow( | ||
setIndexes, | ||
moveRowDirection(-1), | ||
rowType, | ||
sortedData, | ||
updateOrder, | ||
setError | ||
) | ||
); | ||
}} | ||
onKeyPress={e => { | ||
e.stopPropagation(); | ||
}} | ||
className="share-export-modal__menu-item padding-y-1 padding-x-2 action-menu-item" | ||
unstyled | ||
> | ||
{t( | ||
`modelToOperationsMisc:table.menu.${rowType === 'category' ? 'moveCategoryUp' : 'moveSubCategoryUp'}` | ||
)} | ||
</Button> | ||
} | ||
MoveDown={ | ||
<Button | ||
type="button" | ||
disabled={ | ||
currentIndex === (rowLength || 0) - 1 || | ||
currentIndex === (rowLength || 0) - 2 | ||
} | ||
onClick={e => { | ||
e.stopPropagation(); | ||
setRearrangedData( | ||
moveRow( | ||
setIndexes, | ||
moveRowDirection(1), | ||
rowType, | ||
sortedData, | ||
updateOrder, | ||
setError | ||
) | ||
); | ||
}} | ||
onKeyPress={e => { | ||
e.stopPropagation(); | ||
}} | ||
className="share-export-modal__menu-item padding-y-1 padding-x-2 action-menu-item" | ||
unstyled | ||
> | ||
{t( | ||
`modelToOperationsMisc:table.menu.${rowType === 'category' ? 'moveCategoryDown' : 'moveSubCategoryDown'}` | ||
)} | ||
</Button> | ||
} | ||
/> | ||
) : ( | ||
<> | ||
{RenderCell ? ( | ||
<RenderCell row={row} rowType={rowType} expanded={expanded} /> | ||
) : ( | ||
row[column.accessor as keyof MilestoneType] | ||
)} | ||
</> | ||
)} | ||
</td> | ||
); | ||
})} | ||
</> | ||
); | ||
const RenderCells = ({ | ||
row, | ||
rowType, | ||
expanded, | ||
currentIndex, | ||
rowLength, | ||
categoryID, | ||
subCategoryID, | ||
categoryIndex | ||
}: { | ||
row: RowType; | ||
rowType: MTORowType; | ||
expanded: boolean; | ||
currentIndex: number; | ||
rowLength: number; | ||
categoryID?: string; | ||
subCategoryID?: string; | ||
categoryIndex?: number; | ||
}) => { |
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.
Converted renderCells function to a functional component to aid in no longer needing to remember the function parameter order when calling the function and not needing to write out undefined
for optional parameters.
i.e.
{renderCells(row, rowType, false, 0, 0, undefined, undefined, undefined)}
vs
<RenderCells
row={row}
rowType={rowType}
expanded={false}
currentIndex={0}
rowLength={0}
// categoryID, subCategoryID, categoryIndex omitted
/>
It was also easier for me to keep things in my head when developing 😂
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.
Happy to approve once we talk through some of this and maybe add some comments for clarity.
|
||
if (fireAfterOpening) { | ||
fireAfterOpening(); | ||
} |
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'm a little unsure of the fireAfterOpening
is created, would just calling the function needed on close work? Normally we run the resets when modals close, rather than after opening. Maybe we can sync to talk through ti
MINT-3242
Description
fireAfterOpening
prop to Modal component to allow custom function to fire upon modal openingMTOModalContext
to allow for easier state management and prevent prop drilling forMTOTable
andMTOTableActions
AddCustomCategoryForm
andAddCustomMilestoneForm
to take in prepopulated categoryID and optional subcategoryIDHow to test this change
a.
Add model milestone
on parent category to pop up milestone modal with primary category pre-populatedb.
Add sub-category
on parent category to pop up custom category modal and with things pre-populatedc.
Add model milestone
on subcategory to pop up milestone modal with primary category AND SUBCATEGORY pre-populatedPR Author Checklist
PR Reviewer Guidelines