-
Notifications
You must be signed in to change notification settings - Fork 589
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
model evaluation panel permission ux tweaks #5253
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import { MuiButton } from "@fiftyone/components"; | ||
import { Add } from "@mui/icons-material"; | ||
import { Box } from "@mui/material"; | ||
import React from "react"; | ||
|
||
export default function Evaluate(props: EvaluateProps) { | ||
const { onEvaluate } = props; | ||
const { onEvaluate, permissions } = props; | ||
const canEvaluate = permissions.can_evaluate; | ||
return ( | ||
<MuiButton onClick={onEvaluate} startIcon={<Add />} variant="contained"> | ||
Evaluate Model | ||
</MuiButton> | ||
<Box | ||
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. curious: is it better to use 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. Ohh, is that a new component? Yah, it might be better. Sorry, I saw the comment after merging. I'll follow-up |
||
title={canEvaluate ? "" : "You do not have permission to evaluate model"} | ||
sx={{ cursor: canEvaluate ? "pointer" : "not-allowed" }} | ||
> | ||
<MuiButton | ||
onClick={onEvaluate} | ||
startIcon={<Add />} | ||
variant="contained" | ||
disabled={!canEvaluate} | ||
> | ||
Evaluate Model | ||
</MuiButton> | ||
</Box> | ||
); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ import React from "react"; | |
import { useTriggerEvent } from "./utils"; | ||
|
||
export default function Status(props: StatusProps) { | ||
const { status, canEdit, setStatusEvent } = props; | ||
const { status, canEdit, readOnly, setStatusEvent } = props; | ||
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. 🛠️ Refactor suggestion Consider simplifying permission logic. The component uses both - const { status, canEdit, readOnly, setStatusEvent } = props;
+ const { status, canEdit: maybeCanEdit, setStatusEvent } = props;
+ const canEdit = maybeCanEdit && !props.readOnly;
- if (!readOnly) {
+ if (canEdit) { Also applies to: 10-10 |
||
const triggerEvent = useTriggerEvent(); | ||
|
||
if (canEdit) { | ||
if (!readOnly) { | ||
return ( | ||
<Select | ||
sx={{ | ||
|
@@ -22,6 +22,12 @@ export default function Status(props: StatusProps) { | |
onChange={(e) => { | ||
triggerEvent(setStatusEvent, { status: e.target.value }); | ||
}} | ||
title={ | ||
canEdit | ||
? "" | ||
: "You do not have permission to update evaluation status" | ||
} | ||
disabled={!canEdit} | ||
> | ||
{STATUSES.map((status) => { | ||
const color = COLOR_BY_STATUS[status]; | ||
|
@@ -63,7 +69,8 @@ export default function Status(props: StatusProps) { | |
type StatusProps = { | ||
status?: string; | ||
canEdit?: boolean; | ||
setStatusEvent?: string; | ||
readOnly?: boolean; | ||
setStatusEvent: string; | ||
}; | ||
|
||
const STATUS_LABELS = { | ||
|
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.
How where is this permission set?
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.
Permissions are initialized on loading the panel in file
fiftyone/operators/builtins/panels/model_evaluation/__init__.py