Skip to content

Commit

Permalink
ADDON-35090: Added toast message when enable/disable/delete/update/cl…
Browse files Browse the repository at this point in the history
…one from ui
  • Loading branch information
dkhatri-crest committed Apr 6, 2021
1 parent efee4be commit 9d84551
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import update from 'immutability-helper';
import Message from '@splunk/react-ui/Message';

import ControlWrapper from './ControlWrapper';
import { getUnifiedConfigs } from '../util/util';
import { getUnifiedConfigs, generateToast } from '../util/util';
import Validator, { SaveValidator } from '../util/Validator';
import { MODE_CLONE, MODE_CREATE, MODE_EDIT, MODE_CONFIG } from '../constants/modes';
import { PAGE_INPUT } from '../constants/pages';
Expand Down Expand Up @@ -247,6 +247,11 @@ class BaseFormView extends PureComponent {
if (this.hook && typeof this.hook.onSaveSuccess === 'function') {
this.hook.onSaveSuccess();
}
if (this.props.mode === MODE_EDIT || this.props.mode === MODE_CONFIG) {
generateToast(`Updated ${val.name}`, 'success');
} else {
generateToast(`Created ${val.name}`, 'success');
}
this.props.handleFormSubmit(/* isSubmititng */false,/* closeEntity */ true);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function ConfigurationTable({ serviceName, serviceTitle }) {
serviceName={serviceName}
handleRequestModalOpen={() => handleRequestOpen()}
/>
<ToastMessages />
<ToastMessages position="top-right" />
{generateModalDialog()}
</TableContextProvider>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styled from 'styled-components';
import WaitSpinner from '@splunk/react-ui/WaitSpinner';
import update from 'immutability-helper';
import { _ } from '@splunk/ui-utils/i18n';
import { generateToast } from '../util/util';

import { axiosCallWrapper } from '../util/axiosCallWrapper';
import TableContext from '../context/TableContext';
Expand Down Expand Up @@ -55,6 +56,7 @@ class DeleteModal extends Component {
);
this.setState({ isDeleting: false });
this.handleRequestClose();
generateToast(`Deleted ${this.props.stanzaName}`, 'success');
});
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ function TableWrapper({ page, serviceName, handleRequestModalOpen, handleOpenPag
},
});
});
if (response.data.entry[0].content.disabled === true) {
generateToast(`Disabled ${response.data.entry[0].name}`, "success");
} else {
generateToast(`Enabled ${response.data.entry[0].name}`, "success");
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function InputPage() {
page={PAGE_INPUT}
handleOpenPageStyleDialog={handleOpenPageStyleDialog}
/>
<ToastMessages />
<ToastMessages position="top-right" />
{!entity.isInputPageStyle && entity.open ? generateModalDialog() : null}
</div>
</TableContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const axiosCallWrapper = ({
// Something happened in setting up the request that triggered an Error
message = `Error making ${method} request to ${endpointUrl}`;
}
generateToast(message);
generateToast(message, "error");
callbackOnError(error);
return Promise.reject(error);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,23 @@ export function getUnifiedConfigs() {
}

const createToast = makeCreateToast(Toaster);
export const generateToast = (message, action = undefined) => {
export const generateToast = (message, messageType, action = undefined) => {
let toastType;
switch (messageType) {
case 'success':
toastType = TOAST_TYPES.SUCCESS;
break;
case 'error':
toastType = TOAST_TYPES.ERROR;
break;
case 'warning':
toastType = TOAST_TYPES.ERROR;
break;
default:
toastType = TOAST_TYPES.INFO;
}
createToast({
type: TOAST_TYPES.ERROR,
type: toastType,
message,
autoDismiss: true,
dismissOnActionClick: true,
Expand Down

0 comments on commit 9d84551

Please sign in to comment.