Skip to content
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

Make use of new productversion field if available #7045

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-productversion-log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Log correct oCIS version if available

oCIS has introduced a new `productversion` field to announce it's correct version while maintaining a fake 10.x.x version in the `versionstring` field to keep clients compatible. We're using the new productversion field when it exists and use versionstring as a fallback. Thus the backend product information prints the correct oCIS version now.

https://github.com/owncloud/ocis/pull/3805
https://github.com/owncloud/web/pull/7045
10 changes: 5 additions & 5 deletions packages/web-runtime/src/container/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export const getWebVersion = (): string => {
}

export const getBackendVersion = ({ store }: { store: Store<unknown> }): string => {
const backendVersion = store.getters.user.version
Copy link
Contributor

Choose a reason for hiding this comment

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

ok, where did user.version come from in the past?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the capabilities response is extracted into the user store module as capabilities and version keys. see

SET_CAPABILITIES(state, data) {
(yes, it's weird and ugly 😆 don't know why it is like that).

if (!backendVersion || !backendVersion.string) {
const backendStatus = store.getters.capabilities?.core?.status
if (!backendStatus || !backendStatus.versionstring) {
return undefined
}
const product = backendVersion.product || 'ownCloud'
const version = backendVersion.string
const edition = backendVersion.edition
const product = backendStatus.product || 'ownCloud'
const version = backendStatus.productversion || backendStatus.versionstring
const edition = backendStatus.edition
return `${product} ${version} ${edition}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Just had a random shower thought on whether we should insert (development) here if process.env.NODE_ENV === development

Copy link
Contributor

Choose a reason for hiding this comment

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

To detect whether the bundle-watched dist is being used or the shipped web in oCIS - I've been adding a lot of console.log's recently to debug caching

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oha, nice! good idea :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do that in a followup to unblock the next ocis beta

}
23 changes: 19 additions & 4 deletions packages/web-runtime/tests/unit/container/versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,47 @@ describe('collect version information', () => {
it('returns undefined when the backend version object has no "string" field', () => {
const store = versionStore({
product: 'ownCloud',
string: undefined
versionstring: undefined
})
expect(getBackendVersion({ store })).toBeUndefined()
})
it('falls back to "ownCloud" as a product when none is defined', () => {
const store = versionStore({
string: '10.8.0',
versionstring: '10.8.0',
edition: 'Community'
})
expect(getBackendVersion({ store })).toBe('ownCloud 10.8.0 Community')
})
it('provides the backend version as concatenation of product, version and edition', () => {
const store = versionStore({
product: 'oCIS',
string: '1.16.0',
versionstring: '1.16.0',
edition: 'Reva'
})
expect(getBackendVersion({ store })).toBe('oCIS 1.16.0 Reva')
})
it('prefers the productversion over versionstring field if both are provided', () => {
const store = versionStore({
product: 'oCIS',
versionstring: '10.8.0',
productversion: '2.0.0',
edition: 'Community'
})
expect(getBackendVersion({ store })).toBe('oCIS 2.0.0 Community')
})
})
})

const versionStore = (version: any): Store<any> => {
return new Vuex.Store({
getters: {
user: jest.fn(() => ({ version }))
capabilities: jest.fn(() => ({
core: {
status: {
...version
}
}
}))
}
})
}