Skip to content

Commit

Permalink
Added warn and tooltip when non-editable
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Sep 26, 2019
1 parent e865460 commit eecb6d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
5 changes: 5 additions & 0 deletions client/app/pages/alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class AlertPage extends React.Component {
// force view mode if can't edit
if (!canEdit) {
this.setState({ mode: MODES.VIEW });
notification.warn(
'You cannot edit this alert',
'You do not have sufficient permissions to edit this alert, and have been redirected to the view-only page.',
{ duration: 0 },
);
}

this.setState({ alert, canEdit, pendingRearm: alert.rearm });
Expand Down
38 changes: 19 additions & 19 deletions client/app/pages/alert/AlertView.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

import { TimeAgo } from '@/components/TimeAgo';
import { Alert as AlertType } from '@/components/proptypes';
Expand All @@ -9,6 +10,7 @@ import Button from 'antd/lib/button';
import Icon from 'antd/lib/icon';
import Dropdown from 'antd/lib/dropdown';
import Menu from 'antd/lib/menu';
import Tooltip from 'antd/lib/tooltip';

import Title from './components/Title';
import Criteria from './components/Criteria';
Expand Down Expand Up @@ -53,25 +55,23 @@ export default class AlertView extends React.Component {
return (
<>
<Title name={name} alert={alert}>
{canEdit && (
<>
<Button type="default" onClick={onEdit}><i className="fa fa-edit m-r-5" />Edit</Button>
<Dropdown
className="m-l-5"
trigger={['click']}
placement="bottomRight"
overlay={(
<Menu>
<Menu.Item>
<a onClick={this.props.delete}>Delete Alert</a>
</Menu.Item>
</Menu>
)}
>
<Button><Icon type="ellipsis" rotate={90} /></Button>
</Dropdown>
</>
)}
<Tooltip title={canEdit ? '' : 'You do not have sufficient permissions to edit this alert'}>
<Button type="default" onClick={canEdit ? onEdit : null} className={cx({ disabled: !canEdit })}><i className="fa fa-edit m-r-5" />Edit</Button>
<Dropdown
className={cx('m-l-5', { disabled: !canEdit })}
trigger={[canEdit ? 'click' : undefined]}
placement="bottomRight"
overlay={(
<Menu>
<Menu.Item>
<a onClick={this.props.delete}>Delete Alert</a>
</Menu.Item>
</Menu>
)}
>
<Button><Icon type="ellipsis" rotate={90} /></Button>
</Dropdown>
</Tooltip>
</Title>
<div className="row bg-white tiled p-20">
<div className="d-flex col-md-8">
Expand Down

0 comments on commit eecb6d3

Please sign in to comment.