Skip to content

Commit

Permalink
Merge branch 'gui-issue-#493_Setting-of-the-tool-icon-size' of https:…
Browse files Browse the repository at this point in the history
…//github.com/AleksandrGorodetskii/cloud-pipeline into gui-issue-#493_Setting-of-the-tool-icon-size

GUI ISSUE epam#493 fixed.
If getPreferenceValue from setting is possible, we get 'maximumFileSize' from this.props.preferences.getPreferenceValue('misc.max.tool.icon.size.kb') instead from DEFAULT_VALUE in <Tool> component. And compare this value with image.size.
  • Loading branch information
AleksandrGorodetskii committed Jul 16, 2019
2 parents c69923e + 1ea279b commit 117265c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/src/components/tools/Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ export default class Tool extends localization.LocalizedReactComponent {
}

const doUpload = (file) => {
const maximumFileSize = this.props.preferences.getPreferenceValue('misc.max.tool.icon.size.kb');
const MAX_FILE_SIZE_KB = 50;

This comment has been minimized.

Copy link
@rodichenko

rodichenko Jul 16, 2019

Please define this constant outside of the component (at the beginning of the file, for example)

const maximumFileSize = this.props.preferences.getPreferenceValue('misc.max.tool.icon.size.kb')

This comment has been minimized.

Copy link
@rodichenko

rodichenko Jul 16, 2019

This construction can be simplified to

this.props.preferences.getPreferenceValue('misc.max.tool.icon.size.kb') || MAX_FILE_SIZE_KB
? this.props.preferences.getPreferenceValue('misc.max.tool.icon.size.kb') : MAX_FILE_SIZE_KB;
if (file.type.toLowerCase().indexOf('png') === -1) {
message.error('Only PNG image files are supported', 5);
return false;
Expand All @@ -373,7 +375,9 @@ export default class Tool extends localization.LocalizedReactComponent {
} else {
try {
const json = JSON.parse(request.response);
if (json.status === 'ERROR') {
if (json.status === 'ERROR' && json.message.includes('Icon uploaded is too large:')) {

This comment has been minimized.

Copy link
@rodichenko

rodichenko Jul 16, 2019

Do not do any message-dependent logic - just show this message to the user

message.error(`Maximum file size is ${maximumFileSize}kb`, 5);
} else {
message.error(json.message, 5);
}
} catch (__) {}
Expand Down

0 comments on commit 117265c

Please sign in to comment.