import classNames from 'classnames';
import { defineMessages, FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import React from 'react';
import Box from '../box/box.jsx';
import Modal from '../../containers/modal.jsx';
import styles from './prompt.css';
import { SCRATCH_MAX_CLOUD_VARIABLES } from '../../lib/tw-cloud-limits.js';
const messages = defineMessages({
forAllSpritesMessage: {
defaultMessage: 'For all sprites',
description: 'Option message when creating a variable for making it available to all sprites',
id: 'gui.gui.variableScopeOptionAllSprites'
},
forThisSpriteMessage: {
defaultMessage: 'For this sprite only',
description: 'Option message when creating a varaible for making it only available to the current sprite',
id: 'gui.gui.variableScopeOptionSpriteOnly'
},
cloudVarOptionMessage: {
defaultMessage: 'Cloud variable (stored on server)',
description: 'Option message when creating a variable for making it a cloud variable, a variable that is stored on the server', /* eslint-disable-line max-len */
id: 'gui.gui.cloudVariableOption'
},
availableToAllSpritesMessage: {
defaultMessage: 'This variable will be available to all sprites.',
description: 'A message that displays in a variable modal when the stage is selected indicating ' +
'that the variable being created will available to all sprites.',
id: 'gui.gui.variablePromptAllSpritesMessage'
},
listAvailableToAllSpritesMessage: {
defaultMessage: 'This list will be available to all sprites.',
description: 'A message that displays in a list modal when the stage is selected indicating ' +
'that the list being created will available to all sprites.',
id: 'gui.gui.listPromptAllSpritesMessage'
}
});
const customButtonStyle = (button) => {
// if class is manually specified, dont try to guess the intended style
if (button.class) {
switch (button.class) {
case "ok":
return styles.okButton;
case "cancel":
return styles.cancelButton;
default:
return styles.cancelButton;
}
}
// assume intended style from role
if (button.role) {
switch (button.role) {
case "ok":
return styles.okButton;
case "close":
return styles.cancelButton;
}
}
return styles.cancelButton;
};
const PromptComponent = props => props.isCustom ? (
{(props.customButtons && props.customButtons.length > 0 ?
{/* slice then reverse to avoid mutating the array. reversing cause scratch modals put OK on the right & usually you define OK button first */}
{props.customButtons.slice().reverse().map(button => (
))}
: null)}
) : (
{props.label}
{props.showVariableOptions ?