Skip to content

Commit

Permalink
Fix disappearing space members when adding links (#8082)
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Dec 12, 2022
1 parent f808c2d commit 4d52c74
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-space-member-disappearing
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Space member disappearing

We've fixed a bug where adding links to a space would remove newly added members in the UI.

https://github.com/owncloud/web/issues/8081
https://github.com/owncloud/web/pull/8082
9 changes: 7 additions & 2 deletions packages/web-app-files/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { ShareTypes } from 'web-client/src/helpers/share'
import get from 'lodash-es/get'
import { ClipboardActions } from '../helpers/clipboardActions'
import { thumbnailService } from '../services'
import { buildResource, Resource, SpaceResource } from 'web-client/src/helpers'
import {
buildResource,
isProjectSpaceResource,
Resource,
SpaceResource
} from 'web-client/src/helpers'
import { WebDAV } from 'web-client/src/webdav'
import { ClientService } from 'web-pkg/src/services'

Expand Down Expand Up @@ -192,7 +197,7 @@ export default {
},
updateCurrentFileShareTypes({ state, getters, commit }) {
const highlighted = getters.highlightedFile
if (!highlighted) {
if (!highlighted || isProjectSpaceResource(highlighted)) {
return
}
commit('UPDATE_RESOURCE_FIELD', {
Expand Down
23 changes: 23 additions & 0 deletions packages/web-app-files/tests/unit/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import actions from '../../../src/store/actions'
import { spaceRoleManager, ShareTypes, Share } from 'web-client/src/helpers/share'
import { mockDeep } from 'jest-mock-extended'
import { OwnCloudSdk } from 'web-client/src/types'
import { Resource } from 'web-client'
import { SpaceResource } from 'web-client/src/helpers'

jest.mock('../../../src/helpers/resources')
jest.mock('../../../src/gettext')
Expand Down Expand Up @@ -98,4 +100,25 @@ describe('vuex store actions', () => {
expect(stateMock.commit).toHaveBeenCalledTimes(1)
})
})

describe('updateCurrentFileShareTypes', () => {
const stateMock = { currentFileOutgoingShares: [] }
const commitSpy = jest.fn()

it('updates the resource if given', () => {
const getters = { highlightedFile: mockDeep<Resource>() }
actions.updateCurrentFileShareTypes({ state: stateMock, getters, commit: commitSpy })
expect(commitSpy).toHaveBeenCalledTimes(1)
})
it('does not update the resource if not given', () => {
const getters = { highlightedFile: undefined }
actions.updateCurrentFileShareTypes({ state: stateMock, getters, commit: commitSpy })
expect(commitSpy).toHaveBeenCalledTimes(0)
})
it('does not update project space resources', () => {
const getters = { highlightedFile: mockDeep<SpaceResource>({ driveType: 'project' }) }
actions.updateCurrentFileShareTypes({ state: stateMock, getters, commit: commitSpy })
expect(commitSpy).toHaveBeenCalledTimes(0)
})
})
})

0 comments on commit 4d52c74

Please sign in to comment.