-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[ML] Overview: ensure proper permissions check for empty prompt 'Create job' buttons #49067
[ML] Overview: ensure proper permissions check for empty prompt 'Create job' buttons #49067
Conversation
Pinging @elastic/ml-ui (:ml) |
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.
Disabling the Create buttons in the EuiEmptyPrompt
s looks good, but we should probably also hide the link to Creating a new job
in the text on the left of the page if they don't have canCreateJob
or ml nodes available.
💚 Build Succeeded |
Thanks for taking a look @peteharverson 🙌 |
💚 Build Succeeded |
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.
LGTM
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.
Add two suggestions, one about a possible simplification where to do checks.
<FormattedMessage | ||
id="xpack.ml.overview.gettingStartedSectionCreateJob" | ||
defaultMessage="creating a new job" | ||
/> | ||
) : ( | ||
<EuiLink href={createJobLink} target="blank"> | ||
<FormattedMessage | ||
id="xpack.ml.overview.gettingStartedSectionCreateJob" | ||
defaultMessage="creating a new job" | ||
/> |
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.
Nit: Suggest to move both FormattedMessage
to a const
so we don't have the same i18n id twice.
import { checkPermission } from '../privilege/check_privilege'; | ||
import { mlNodesAvailable } from '../ml_nodes_check/check_ml_nodes'; | ||
import { NavigationMenu } from '../components/navigation_menu'; | ||
import { OverviewSideBar } from './components/sidebar'; | ||
import { OverviewContent } from './components/content'; | ||
|
||
export const OverviewPage: FC = () => { | ||
const disableCreateAnomalyDetectionJob = !checkPermission('canCreateJob') || !mlNodesAvailable(); | ||
const disableCreateAnalyticsButton = | ||
!checkPermission('canCreateDataFrameAnalytics') || | ||
!checkPermission('canStartStopDataFrameAnalytics'); | ||
return ( |
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.
What do you think of moving the imports and check consts directly into the panel components? Then there would be no need to pass them down 2 levels via props.
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.
Keeping them in the parent component makes it easier to share the permissions check since it has to be called from the panels and the sidebar component. I thought it might be preferable to calling it in 3 different places. Happy to make the change if it seems cleaner.
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.
Sorry I missed that the same check is used in Panel + Sidebar, happy to leave as 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.
LGTM
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.
Tested and LGTM
💚 Build Succeeded |
…te job' buttons (elastic#49067) * disabled overview empty prompt create job button if no permissions * permission check from overviewPage main component. add mlNodes check to resolver * remove period from overview empty prompt title
…te job' buttons (elastic#49067) * disabled overview empty prompt create job button if no permissions * permission check from overviewPage main component. add mlNodes check to resolver * remove period from overview empty prompt title
Summary
Fixes #49018
Disables
Create job
button for empty prompts in Overview page if permissions are not met.Uses same permissions check for corresponding job types (anomaly detection
Create job
check for the anomaly detection panel and analyticsCreate job
check for analytics panel).Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
- [ ] This was checked for breaking API changes and was labeled appropriately- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately