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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.env
@@ -1,3 +1,3 @@
# The version of OCIS to use in pipelines that test against OCIS
OCIS_COMMITID=ea435449d2843a96c6b5d030e139eb6658a17078
OCIS_COMMITID=4aeac5c93f1bf6a74e1962a51efebbdf30164cf2
OCIS_BRANCH=master
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-productversion-log
@@ -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
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
Member 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
Member 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
Member 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
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
}
}
}))
}
})
}