Skip to content

Commit

Permalink
bug fix so that managed channels could be enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Oct 17, 2024
1 parent 3edb13d commit 88cbfcf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
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 @@ -578,7 +578,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
2 changes: 1 addition & 1 deletion public/pages/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Main extends Component {

handleDataSourceChange = ([dataSource]) => {
const dataSourceId = dataSource?.id;
const dataSourceLabel = dataSource?.label
const dataSourceLabel = dataSource?.label;
if (this.props.dataSourceEnabled && dataSourceId === undefined) {
getNotifications().toasts.addDanger('Unable to set data source.');
} else if (this.state.selectedDataSourceId != dataSourceId) {
Expand Down
2 changes: 1 addition & 1 deletion public/pages/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function parseQueryStringAndGetDataSource(queryString) {
const pair = param.split('=');
params[pair[0]] = pair[1];
}
return params.hasOwnProperty('dataSourceId') ? params['dataSourceId'] || '' : undefined;
return params.hasOwnProperty('dataSourceId') ? params['dataSourceId'] : undefined;
}

export function constructUrlFromDataSource(url) {
Expand Down

0 comments on commit 88cbfcf

Please sign in to comment.