Skip to content

Conversation

Kronos66
Copy link
Collaborator

No description provided.

@vuolter
Copy link

vuolter commented Aug 31, 2021

Hey @Kronos66 I tried this PR and I can actually see the versions dropdown now, but no data are saved in the db table versions when applying changes to the content, so the dropdown remains empty (I see just the entry current).

On a single types (named global in the img below) I got this error, I'm on postgresql:

Screenshot 2021-08-31 at 12 06 14

Signed-off-by: Maksymilian Pamuła <[email protected]>
@Kronos66
Copy link
Collaborator Author

Kronos66 commented Sep 5, 2021

Hey @Kronos66 I tried this PR and I can actually see the versions dropdown now, but no data are saved in the db table versions when applying changes to the content, so the dropdown remains empty (I see just the entry current).

On a single types (named global in the img below) I got this error, I'm on postgresql:

Screenshot 2021-08-31 at 12 06 14

Hi @vuolter, I added support for single types.
Could you check this again?

Copy link

@vuolter vuolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kronos66, I tested your latest changes and by applying just a few small changes I was able to get the plugin finally working fine on my side. Thanks for your amazing support! ❤️

Comment on lines 65 to 67
const { id: singleTypeId } = await model.findOne({});
knexQueryBuilder
.where({ content_type: contentType, entity_id: singleTypeId });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if the query returns actually an entry, I changed this block to:

const entry = await model.findOne({});
if (entry) {
  knexQueryBuilder.where({
    content_type: contentType,
    entity_id: entry.id,
  });
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch I will fix this in next commit :) thank you

return versionsForCurrentId.map((el) => ({
content: el.entity,
return versionsForCurrentContentType.map((el) => ({
content: JSON.parse(el.entity),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like el.entity is already an object, I reverted to:

content: el.entity,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, because we write data to database as json and here we always get string

Copy link

@vuolter vuolter Sep 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kronos66 I tried 0d5e94c and I can confirm it fails with JSON.parse(el.entity):

Screenshot 2021-09-08 at 11 39 57

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question about this problem, what database do you use?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postgresql

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i remember correctly this happens also with built-in sqlite @Kronos66

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @vuolter , sorry for delay
I added the saveParse method to handle objects, now everything should works correctly

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Kronos66, sorry to reply so late.... I tried your latest changes under sqlite and mysql on a fresh installation and everything looks working fine, on both.
I'll try to check on postgresql as well and let you know.

@Christianlance85
Copy link

Christianlance85 commented Oct 21, 2021

I am getting TypeError: Cannot read property 'listEntityVersions' of undefined when I try to spin it up, but if I remove the first route in the routes.json file, I can spin up my environment, however, it is unable to get the versions of the collection types. Has anyone else gotten this or know how to fix it?

{
      "method": "GET",
      "path": "/explorer/versions/:model/:id",
      "handler": "Versions.listEntityVersions",
      "config": {
        "policies": []
      }
    },

@cyp3rius
@Kronos66

@joacimastrom
Copy link

What's the status on this @Kronos66 ? I need versioning in an app, if this works it'd be great :)

@mstrag mstrag removed their request for review July 24, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants