@revoloo/cypress6
Version:
Cypress.io end to end testing tool
57 lines (44 loc) • 1.42 kB
JavaScript
import { action, computed, observable } from 'mobx'
import localData from '../lib/local-data'
class UpdateStore {
// states
LOADING_RELEASE_NOTES = 'LOADING_RELEASE_NOTES'
SHOW_RELEASE_NOTES = 'SHOW_RELEASE_NOTES'
SHOW_INSTRUCTIONS = 'SHOW_INSTRUCTIONS'
version
newVersion
dismissedUpdateVersion = localData.get('dismissed-update-version')
state
.ref releaseNotes
constructor () {
if (window.Cypress) {
window.UpdateStore = this // for testing
}
}
get updateAvailable () {
return this.version !== this.newVersion
}
get nonDismissedUpdateAvailable () {
return this.updateAvailable && this.newVersion !== this.dismissedUpdateVersion
}
get hasMatchingReleaseNotes () {
return this.releaseNotes && this.releaseNotes.version === this.newVersion
}
setVersion (version) {
if (version != null) this.version = this.newVersion = version
}
setNewVersion (newVersion) {
this.newVersion = newVersion
}
setDismissedUpdateVersion () {
this.dismissedUpdateVersion = this.newVersion
localData.set('dismissed-update-version', this.newVersion)
}
setReleaseNotes (releaseNotes) {
this.releaseNotes = releaseNotes
}
setState (state) {
this.state = state
}
}
export default new UpdateStore()