Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.3' into 1
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	client/dist/js/bundle.js
  • Loading branch information
dnsl48 committed Jan 27, 2019
2 parents f05afac + d5e9c84 commit 9c489c5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ env:
- COMPOSER_ROOT_VERSION=1.4.x-dev
- DISPLAY=":99"
- XVFBARGS=":99 -ac -screen 0 1024x768x16"
- TRAVIS_NODE_VERSION="10"
- SS_BASE_URL="http://localhost:8080/"
- SS_ENVIRONMENT_TYPE="dev"

Expand All @@ -37,6 +36,10 @@ matrix:
env: NPM_TEST=1
- php: 5.6
env: PHPCS_TEST=1
- php: 5.6
env:
- DB=PGSQL
- PHPUNIT_TEST=1

before_script:
# Extra $PATH
Expand All @@ -50,6 +53,7 @@ before_script:

# Install composer
- composer validate
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.x-dev --prefer-dist; fi
- composer require silverstripe/recipe-testing:^1 silverstripe/recipe-cms 4.4.x-dev --no-update --prefer-dist
- composer update

Expand All @@ -61,7 +65,7 @@ before_script:
- if [[ $BEHAT_TEST ]]; then (vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi

# Install NPM dependencies
- if [[ $NPM_TEST ]]; then nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION && npm install -g yarn && yarn install --network-concurrency 1 && (cd vendor/silverstripe/admin && yarn install --network-concurrency 1) && yarn run build; fi
- if [[ $NPM_TEST ]]; then nvm install && nvm use && npm install -g yarn && yarn install --network-concurrency 1 && (cd vendor/silverstripe/admin && yarn install --network-concurrency 1) && yarn run build; fi

script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/php; fi
Expand Down
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions client/src/components/AssetDropzone/AssetDropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ class AssetDropzone extends Component {
}

componentDidMount() {
const defaultOptions = this.getDefaultOptions();

this.dropzone = new DropzoneLib(
ReactDOM.findDOMNode(this),
Object.assign({},
defaultOptions,
this.getDefaultOptions(),
this.props.options
));

Expand All @@ -59,8 +57,8 @@ class AssetDropzone extends Component {
this.dropzone.enable();

this.dropzone.options = Object.assign({},
this.dropzone.options,
this.getDefaultOptions(),
this.dropzone.options,
this.props.options
);
}
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/UploadField/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ class UploadField extends Component {
if (maxFiles === null || typeof maxFiles === 'undefined') {
return null;
}
const filesCount = this.props.files.filter(file => !file.message || file.message.type !== 'error').length;

const filesCount = this.props.files.filter(file =>
file.id > 0
&& (!file.message || file.message.type !== 'error')
).length;

const allowed = Math.max(maxFiles - filesCount, 0);

return allowed;
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/UploadField/tests/UploadField-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('UploadField', () => {
);
maxFiles = file.getMaxFiles();

expect(maxFiles).toBe(2);
expect(maxFiles).toBe(3);
});
});

Expand Down Expand Up @@ -253,7 +253,7 @@ describe('UploadField', () => {

it('should hide the dropzone when maxFiles reached', () => {
props.data.multi = true;
props.data.maxFiles = 3;
props.data.maxFiles = 2;
file = ReactTestUtils.renderIntoDocument(
<UploadField {...props} />
);
Expand Down
12 changes: 10 additions & 2 deletions code/Forms/UploadField.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function upload(HTTPRequest $request)
return (new HTTPResponse(json_encode($result), 400))
->addHeader('Content-Type', 'application/json');
}

// We need an ID for getObjectFromData
if (!$file->isInDB()) {
$file->write();
Expand Down Expand Up @@ -321,7 +321,15 @@ public function validate($validator)
if ($maxFiles < 1 || $count <= $maxFiles) {
return true;
}
$validator->validationError($this->getName(), _t('', 'Bobby'));

$validator->validationError($this->getName(), _t(
__CLASS__ . '.ErrorMaxFilesReached',
'You can only upload {count} file.|You can only upload {count} files.',
[
'count' => $maxFiles,
]
));

return false;
}

Expand Down
1 change: 1 addition & 0 deletions code/GraphQL/FolderTypeCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\GraphQL\Pagination\Connection;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DB;

/**
* @skipUpgrade
Expand Down

0 comments on commit 9c489c5

Please sign in to comment.