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

[BOT] Farabi/bot-2133/show-proper-message-on-loading-invalid-strategy #16527

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
6 changes: 6 additions & 0 deletions packages/bot-skeleton/src/scratch/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { saveWorkspaceToRecent } from '../../utils/local-storage';
import DBotStore from '../dbot-store';
import { LogTypes } from '../../constants/messages';
import { error_message_map } from '../../utils/error-config';
import { botNotification } from '../../../../bot-web-ui/src/components/bot-notification/bot-notification';
import { notification_message } from '../../../../bot-web-ui/src/components/bot-notification/bot-notification-utils';

export const getSelectedTradeType = (workspace = Blockly.derivWorkspace) => {
const trade_type_block = workspace.getAllBlocks(true).find(block => block.type === 'trade_definition_tradetype');
Expand Down Expand Up @@ -121,10 +123,14 @@ export const load = async ({
}) => {
if (!DBotStore?.instance || !workspace) return;
const { setLoading } = DBotStore.instance;
const { load_modal } = DBotStore.instance;
const { setLoadedLocalFile } = load_modal;
setLoading(true);
// Delay execution to allow fully previewing previous strategy if users quickly switch between strategies.
await delayExecution(100);
const showInvalidStrategyError = () => {
setLoadedLocalFile(null);
botNotification(notification_message.invalid_xml);
setLoading(false);
const error_message = localize('XML file contains unsupported elements. Please check or modify file.');
globalObserver.emit('ui.log.error', error_message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const notification_message = {
bot_stop: localize('You’ve just stopped the bot. Any open contracts can be viewed on the Reports page.'),
workspace_change: localize('Changes you make will not affect your running bot.'),
block_delete: localize('You’ve just deleted a block.'),
invalid_xml: localize('Your import failed due to an invalid file. Upload a complete file in XML format.'),
[NOTIFICATION_TYPE.BOT_IMPORT]: localize('You’ve successfully imported a bot.'),
[NOTIFICATION_TYPE.BOT_DELETE]: localize('You’ve successfully deleted a bot.'),
strategy_conversion: localize('Save this strategy as an XML file from Deriv Bot for faster re-imports.'),
Expand Down
Loading