-
Notifications
You must be signed in to change notification settings - Fork 115
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
NEW Implement React history viewer if available (SS 4.2 onwards) #207
NEW Implement React history viewer if available (SS 4.2 onwards) #207
Conversation
Do you see the same thing in the current history viewer for blocks, i.e. elemental 2.0 on SS 4.0 or 4.1? If there are duplicate versions in list it's likely to be coming from the ORM, since this component is essentially a wrapper around the versions that come for a record in GraphQL, which is also just listing versions from the silverstripe/versioned module - I'd suspect there's a logical reason why it displays like this, although I agree that it might be confusing for users |
When I test this there is a bit of a delay in the changes showing up in the History Viewer.
I then move to the I refresh the page. This opens the I open the Also, am I right in the assumption that the three items listed are: 1) Block creation, 2) Block saving, and 3) Block publishing?! |
Yep I think the state of the results not updating needs to be addressed in the history viewer itself, in that we should hook into the save and publish actions to update the history viewer's state or cause it to refetch its records - let's wait until it gets merged in some state then raise an issue for that |
Just to recap on our discussion today. With the current functionality we can change the wording "Modified" back to "Saved" so that it is following the pattern of which action was pressed rather than the state at the time (hopefully thats easier). It would be good to hear if anyone has preferences for using the States here (Draft/Published/Modified) instead of the completed action (Saved/Published). If possible we'd avoid combining them as "Saved as modified" doesn't make sense. |
If at some stage we want to show draft, modified and published as separate labels then we might need to consider adding some API to GraphQL that allows for that now - currently we have Published: boolean only and use that to determine the label. We could also add some React logic to return Draft before the record has first been published, but it might be better for this logic to be contained to the versioned API over a React implementation of it |
- Modified
+ Saved Changed in silverstripe/silverstripe-versioned-admin#2 |
// the query must be set to the "versions" prop on the component that this HOC is | ||
// applied to (see ElementHistoryViewer.js) for binding implementation. | ||
const query = gql` | ||
query readOneBlock ($block_id: ID!, $limit: Int!, $offset: Int!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query could also have a more distinct name.
loading: networkLoading || !versions, | ||
versions, | ||
graphQLErrors: errors, | ||
actions: Object.assign({}, actions, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object spreads, please. :)
const withElementsHistoryViewer = (HistoryViewer) => compose( | ||
readOneBlockQuery | ||
)(HistoryViewer); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but I don't think this function is necessary. readOneBlockQuery
exports an HOC function, expecting a Component as an argument. This should suffice:
updater.component(
'HistoryViewer.Form_ItemEditForm',
readOneBlockQuery,
'ElementHistoryViewer'
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Biggest thing is what appears to be a superfluous HOC definition.
Todo:
|
ac2bf67
to
7c1a649
Compare
@raissanorth mind having a quick once over this pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't had a chance to run this locally yet, but the code itself looks good to me.
Requires SS 4.2 or higher, so will need to be added to a new minor release.
Parent story: silverstripe/silverstripe-versioned#37