Skip to content
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

[Backport 2.x] MDS Bug fix when configuring a Trigger Action in Create Monitor #1129

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { EuiSmallButton, EuiSmallButtonEmpty, EuiEmptyPrompt, EuiText } from '@e
import { APP_PATH } from '../../../../utils/constants';
import { MONITORS_NAV_ID } from '../../../../../utils/constants';
import { getUseUpdatedUx } from '../../../../services';
import { getURL } from '../../../utils/helpers';

const createMonitorText =
'There are no existing alerts. Create a monitor to add triggers and actions. Once an alarm is triggered, the state will show in this table.';
Expand All @@ -18,10 +19,13 @@ const createTriggerText =
const editTriggerConditionsText =
'There are no existing alerts. Adjust trigger conditions to start alerting. Once an alarm is triggered, the state will show in this table.';

const getCreateMonitorButton = () => (
const getCreateMonitorButton = (landingDataSourceId) => (
<EuiSmallButton
fill
href={`${getUseUpdatedUx() ? MONITORS_NAV_ID : ''}#${APP_PATH.CREATE_MONITOR}`}
href={getURL(
`${getUseUpdatedUx() ? MONITORS_NAV_ID : ''}#${APP_PATH.CREATE_MONITOR}`,
landingDataSourceId
)}
>
Create monitor
</EuiSmallButton>
Expand All @@ -30,7 +34,7 @@ const editMonitorButton = (onCreateTrigger) => (
<EuiSmallButtonEmpty onClick={onCreateTrigger}>Edit monitor</EuiSmallButtonEmpty>
);

const DashboardEmptyPrompt = ({ onCreateTrigger, isModal = false }) => {
const DashboardEmptyPrompt = ({ onCreateTrigger, landingDataSourceId, isModal = false }) => {
const inMonitorDetails = typeof onCreateTrigger === 'function';
const displayText = isModal
? editTriggerConditionsText
Expand All @@ -41,7 +45,7 @@ const DashboardEmptyPrompt = ({ onCreateTrigger, isModal = false }) => {
? undefined
: isModal
? editMonitorButton(onCreateTrigger)
: getCreateMonitorButton();
: getCreateMonitorButton(landingDataSourceId);
return (
<EuiEmptyPrompt
style={{ maxWidth: '45em' }}
Expand All @@ -57,6 +61,7 @@ const DashboardEmptyPrompt = ({ onCreateTrigger, isModal = false }) => {

DashboardEmptyPrompt.propTypes = {
onCreateTrigger: PropTypes.func,
landingDataSourceId: PropTypes.string
};

export default DashboardEmptyPrompt;
7 changes: 6 additions & 1 deletion public/pages/Dashboard/containers/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,12 @@ export default class Dashboard extends Component {
isSelectable={true}
selection={selection}
onChange={this.onTableChange}
noItemsMessage={<DashboardEmptyPrompt onCreateTrigger={onCreateTrigger} />}
noItemsMessage={
<DashboardEmptyPrompt
onCreateTrigger={onCreateTrigger}
landingDataSourceId={this.props.landingDataSourceId}
/>
}
data-test-subj={'alertsDashboard_table'}
/>

Expand Down
Loading