Skip to content

Commit

Permalink
[BOT] Farabi/bot-2133/show-proper-message-on-loading-invalid-strategy (
Browse files Browse the repository at this point in the history
…binary-com#16527)

* fix: show invalid xml message when ivalid strategy is imported

* chore: updated error message for invalid file

* fix: invalid error for specific strategies
  • Loading branch information
farabi-deriv committed Aug 26, 2024
1 parent 59f5842 commit 11d85fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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

0 comments on commit 11d85fa

Please sign in to comment.