-
Notifications
You must be signed in to change notification settings - Fork 122
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
[MLP-594] History #467
[MLP-594] History #467
Conversation
|
||
const save = (data, callback) => cdn.putFileContent(JSON.stringify(data), filePath(), true, callback); | ||
|
||
const refresh = (componentsList, callback) => { |
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.
The refresh signature (called on registry start and component published) has the components list (all the components and all versions) as input. The reason is that both times this is needed to happen, it happens after the list is fetched or modified, so it is good to start from there for navigating the tree.
componentsCache.load((err, componentsList) => { | ||
if(err){ return callback(err); } | ||
componentsDetails.refresh(componentsList, (err) => callback(err, componentsList)); | ||
}); |
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 is what happens on registry start. In this scenario, the componentsDetails.refresh
main goal is to verify integrity or to build the file from scratch (only the first time).
componentsCache.refresh((err, componentsList) => { | ||
if(err){ return callback(err); } | ||
componentsDetails.refresh(componentsList, callback); | ||
}); |
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.
On component published, both files are in need to be updated and in need to succeed otherwise the publish will fail and the CLI will error
src/registry/domain/repository.js
Outdated
}); | ||
}); | ||
}, | ||
saveComponentsInfo: (componentsInfo, callback) => { | ||
cdn.putFileContent(JSON.stringify(componentsInfo), `${conf.s3.componentsDir}/components.json`, true, callback); |
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 method had 0 usages so it was safe to be removed
src/registry/router.js
Outdated
@@ -7,7 +7,7 @@ const ComponentRoute = require('./routes/component'); | |||
const ComponentsRoute = require('./routes/components'); | |||
const ComponentInfoRoute = require('./routes/component-info'); | |||
const ComponentPreviewRoute = require('./routes/component-preview'); | |||
const ListComponentsRoute = require('./routes/list-components'); | |||
const IndexRoute = require('./routes/index'); |
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.
The UI's "home page" used to be called "list components" route but now it's becoming much more than that. So list components => index
@@ -0,0 +1,28 @@ | |||
'use strict'; |
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.
A little utility that given the details file maps to a convenient sorted array.
a(href="#components-history" class="tab-link") History | ||
|
||
include components-list | ||
include components-history |
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.
There are 2 jade partials, and via client-side javascript we toggle the selected one
@@ -3,7 +3,7 @@ | |||
const expect = require('chai').expect; | |||
const sinon = require('sinon'); | |||
|
|||
describe('registry : events-handler', () => { | |||
describe('registry : domain : events-handler', () => { |
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.
unrelated, consistency renaming
|
||
const getFromDirectories = (options, callback) => { | ||
|
||
const details = _.extend({}, _.cloneDeep(options.details)); |
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.
Any reason why extending + deep cloning? (cloneDeep
already return a new object if i'm not wrong)
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.
options.details
can be empty in case it's the first time the new version is running with the current registry. So, options.details
can be undefined
and I need details to fallback to {}
in that scenario. (I just tried to _.cloneDeep(undefined) and I got undefined back)
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.
Good stuff @matteofigus
This allows us to have an history of all the published components. In the UI, there is a new tab that allows to navigate the history, with all the components sorted by date.
A couple of details about how it works:
components-details.json
. In the future it may host much more than the publishedDate if necessary. That is a convenience view of the S3 components files tree.For the review, I don't recommend going through all the commits - look at the diff and inline comments.
Home Page with 2 tabs:
History page: