Skip to content

Track asset provenance when using the paint editor #229

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
13 changes: 11 additions & 2 deletions packages/scratch-gui/src/containers/paint-editor-wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,28 @@
this.props.vm.renameCostume(this.props.selectedCostumeIndex, name);
}
handleUpdateImage (isVector, image, rotationCenterX, rotationCenterY) {
const currentCostume = this.props.vm.editingTarget.getCostumes()[this.props.selectedCostumeIndex];
const currentAsset = currentCostume.asset;

const provenance = currentAsset.clean ? currentAsset.assetId : currentAsset.provenance;

if (isVector) {
this.props.vm.updateSvg(
this.props.selectedCostumeIndex,
image,
rotationCenterX,
rotationCenterY);
rotationCenterY,
provenance,

Check failure on line 38 in packages/scratch-gui/src/containers/paint-editor-wrapper.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

Unexpected trailing comma

Check failure on line 38 in packages/scratch-gui/src/containers/paint-editor-wrapper.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

Unexpected trailing comma
);
} else {
this.props.vm.updateBitmap(
this.props.selectedCostumeIndex,
image,
rotationCenterX,
rotationCenterY,
2 /* bitmapResolution */);
2 /* bitmapResolution */,
provenance,

Check failure on line 47 in packages/scratch-gui/src/containers/paint-editor-wrapper.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

Unexpected trailing comma

Check failure on line 47 in packages/scratch-gui/src/containers/paint-editor-wrapper.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

Unexpected trailing comma
);
}
}
render () {
Expand Down
3 changes: 2 additions & 1 deletion packages/scratch-gui/src/lib/project-saver-hoc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@
asset.assetType,
asset.dataFormat,
asset.data,
asset.assetId
asset.assetId,
{ provenance: asset.provenance }

Check failure on line 240 in packages/scratch-gui/src/lib/project-saver-hoc.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

There should be no space after '{'

Check failure on line 240 in packages/scratch-gui/src/lib/project-saver-hoc.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

There should be no space before '}'

Check failure on line 240 in packages/scratch-gui/src/lib/project-saver-hoc.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

There should be no space after '{'

Check failure on line 240 in packages/scratch-gui/src/lib/project-saver-hoc.jsx

View workflow job for this annotation

GitHub Actions / Detect affected packages, build and test

There should be no space before '}'
).then(response => {
// Asset servers respond with {status: ok} for successful POSTs
if (response.status !== 'ok') {
Expand Down
8 changes: 6 additions & 2 deletions packages/scratch-vm/src/virtual-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,9 @@ class VirtualMachine extends EventEmitter {
* @param {!number} rotationCenterY y of point about which the costume rotates, relative to its upper left corner
* @param {!number} bitmapResolution 1 for bitmaps that have 1 pixel per unit of stage,
* 2 for double-resolution bitmaps
* @param {?string} provenance - an assetId of an asset that this one was based on
*/
updateBitmap (costumeIndex, bitmap, rotationCenterX, rotationCenterY, bitmapResolution) {
updateBitmap (costumeIndex, bitmap, rotationCenterX, rotationCenterY, bitmapResolution, provenance) {
const costume = this.editingTarget.getCostumes()[costumeIndex];
if (!(costume && this.runtime && this.runtime.renderer)) return;
if (costume && costume.broken) delete costume.broken;
Expand Down Expand Up @@ -934,6 +935,7 @@ class VirtualMachine extends EventEmitter {
null, // id
true // generate md5
);
costume.asset.setProvenance(provenance);
costume.assetId = costume.asset.assetId;
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
this.emitTargetsUpdate();
Expand All @@ -951,8 +953,9 @@ class VirtualMachine extends EventEmitter {
* @param {string} svg - new SVG for the renderer.
* @param {number} rotationCenterX x of point about which the costume rotates, relative to its upper left corner
* @param {number} rotationCenterY y of point about which the costume rotates, relative to its upper left corner
* @param {?string} provenance - an assetId of an asset that this one was based on
*/
updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) {
updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY, provenance) {
const costume = this.editingTarget.getCostumes()[costumeIndex];
if (costume && costume.broken) delete costume.broken;
if (costume && this.runtime && this.runtime.renderer) {
Expand All @@ -973,6 +976,7 @@ class VirtualMachine extends EventEmitter {
null,
true // generate md5
);
costume.asset.setProvenance(provenance);
costume.assetId = costume.asset.assetId;
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
this.emitTargetsUpdate();
Expand Down
Loading