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

ADDON-35090: Added toast message when enable/disable/delete/update/cl… #157

Merged
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 @@ -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