Skip to content

Commit

Permalink
fix: resolve data file field handler
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek305 committed Oct 21, 2024
1 parent 0e33c77 commit f16e7ba
Show file tree
Hide file tree
Showing 8 changed files with 5,405 additions and 5,400 deletions.
90 changes: 48 additions & 42 deletions __test__/data/fileField.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,58 @@
},
"value": [
{
"uid": "blt78cdb7bdceb00332",
"created_at": "2019-05-27T06:25:46.929Z",
"updated_at": "2019-05-27T06:25:46.929Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "49385",
"tags": [],
"filename": "asdasdasd(1).png",
"url": "https://images.contentstack.io/v3/assets/blxxx/blt78cdb7bdceb00332/sadsadsASS/asdasdasd(1).png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "asdasdasd(1).png"
"file": {
"uid": "blt78cdb7bdceb00332",
"created_at": "2019-05-27T06:25:46.929Z",
"updated_at": "2019-05-27T06:25:46.929Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "49385",
"tags": [],
"filename": "asdasdasd(1).png",
"url": "https://images.contentstack.io/v3/assets/blxxx/blt78cdb7bdceb00332/sadsadsASS/asdasdasd(1).png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "asdasdasd(1).png"
}
},
{
"uid": "bltd40e27d1918972a4",
"created_at": "2019-05-27T06:22:42.426Z",
"updated_at": "2019-05-27T06:22:42.426Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "21748",
"tags": [],
"filename": "MVMT_Rallye_Green_Sandstone_3.png",
"url": "https://images.contentstack.io/v3/assets/blxxx/bltd40e27d1918972a4/5ceb8232231227de413bab12/MVMT_Rallye_Green_Sandstone_3.png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "MVMT_Rallye_Green_Sandstone_3.png"
"file": {
"uid": "bltd40e27d1918972a4",
"created_at": "2019-05-27T06:22:42.426Z",
"updated_at": "2019-05-27T06:22:42.426Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "21748",
"tags": [],
"filename": "MVMT_Rallye_Green_Sandstone_3.png",
"url": "https://images.contentstack.io/v3/assets/blxxx/bltd40e27d1918972a4/5ceb8232231227de413bab12/MVMT_Rallye_Green_Sandstone_3.png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "MVMT_Rallye_Green_Sandstone_3.png"
}
},
{
"uid": "blt236db5d7d0d2c2d1",
"created_at": "2019-05-27T06:22:39.763Z",
"updated_at": "2019-05-27T06:22:39.763Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "23804",
"tags": [],
"filename": "MVMT_Rallye_Green_Sandstone_2.png",
"url": "https://images.contentstack.io/v3/assets/blxxx/blt236db5d7d0d2c2d1/5ceb822f065d29344df9fd2d/MVMT_Rallye_Green_Sandstone_2.png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "MVMT_Rallye_Green_Sandstone_2.png"
"file": {
"uid": "blt236db5d7d0d2c2d1",
"created_at": "2019-05-27T06:22:39.763Z",
"updated_at": "2019-05-27T06:22:39.763Z",
"created_by": "asssa",
"updated_by": "asssa",
"content_type": "image/png",
"file_size": "23804",
"tags": [],
"filename": "MVMT_Rallye_Green_Sandstone_2.png",
"url": "https://images.contentstack.io/v3/assets/blxxx/blt236db5d7d0d2c2d1/5ceb822f065d29344df9fd2d/MVMT_Rallye_Green_Sandstone_2.png",
"ACL": [],
"is_dir": false,
"_version": 1,
"title": "MVMT_Rallye_Green_Sandstone_2.png"
}
}
],
"entry": {
Expand Down
5 changes: 2 additions & 3 deletions __test__/field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ describe("Field", () => {
});

it("setFocus", () => {
field.setFocus()
field.setFocus();
expect(connection.sendToParent).toHaveBeenCalledWith("focus");

});
});

Expand Down Expand Up @@ -131,7 +130,7 @@ describe("Field", () => {
singleFileField.getData()
);
expect(
fileFieldData.multiple.value.map((file) => file.uid)
fileFieldData.multiple.value.map(({ file }) => file.uid)
).toEqual(multipleFileField.getData());
});

Expand Down
2 changes: 1 addition & 1 deletion __test__/fieldModifierLocation/field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe("Field", () => {
singleFileField.getData()
);
expect(
fileFieldData.multiple.value.map((file) => file.uid)
fileFieldData.multiple.value.map(({ file }) => file.uid)
).toEqual(multipleFileField.getData());
});

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/app-sdk",
"version": "2.1.0",
"version": "2.1.1",
"types": "dist/src/index.d.ts",
"description": "The Contentstack App SDK allows you to customize your Contentstack applications.",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function separateResolvedData(field: Field, value: GenericObjectType) {
resolvedData = value;
unResolvedData =
field.schema.multiple === true
? value.map((file: any) => file.uid)
? value.map(({ file }: any) => file.uid)
: value.uid;
} else if (field.schema.multiple === true) {
resolvedData = [];
Expand Down
2 changes: 1 addition & 1 deletion src/fieldModifierLocation/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function separateResolvedData(
resolvedData = value;
unResolvedData =
field.schema.multiple === true
? value.map((file: any) => file.uid)
? value.map(({ file }: any) => file.uid)
: value.uid;
} else if (field.schema.multiple === true) {
resolvedData = [];
Expand Down
Loading

0 comments on commit f16e7ba

Please sign in to comment.