diff --git a/services/web/frontend/js/features/share-project-modal/components/link-sharing.js b/services/web/frontend/js/features/share-project-modal/components/link-sharing.js
index e18c112bc7..5d2be9bcb8 100644
--- a/services/web/frontend/js/features/share-project-modal/components/link-sharing.js
+++ b/services/web/frontend/js/features/share-project-modal/components/link-sharing.js
@@ -13,7 +13,7 @@ import CopyLink from '../../../shared/components/copy-link'
export default function LinkSharing() {
const [inflight, setInflight] = useState(false)
- const { monitorRequest, updateProject } = useShareProjectContext()
+ const { monitorRequest } = useShareProjectContext()
const project = useProjectContext()
@@ -23,15 +23,16 @@ export default function LinkSharing() {
setInflight(true)
monitorRequest(() => setProjectAccessLevel(project, publicAccesLevel))
.then(() => {
- // TODO: ideally this would use the response from the server
- updateProject({ publicAccesLevel })
+ // NOTE: not calling `updateProject` here as it receives data via
+ // project:publicAccessLevel:changed and project:tokens:changed
+ // over the websocket connection
// TODO: eventTracking.sendMB('project-make-token-based') when publicAccesLevel is 'tokenBased'
})
.finally(() => {
setInflight(false)
})
},
- [monitorRequest, project, updateProject]
+ [monitorRequest, project]
)
switch (project.publicAccesLevel) {
diff --git a/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js b/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
index 93c252a277..251160a305 100644
--- a/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
+++ b/services/web/test/frontend/features/share-project-modal/components/share-project-modal.test.js
@@ -736,6 +736,21 @@ describe('', function () {
it('handles switching between access levels', async function () {
fetchMock.post('express:/project/:projectId/settings/admin', 204)
+ let watchCallbacks = {}
+
+ const ideWithProject = project => {
+ return {
+ $scope: {
+ $watch: (path, callback, deep) => {
+ watchCallbacks[path] = callback
+ return () => {}
+ },
+ $applyAsync: () => {},
+ project
+ }
+ }
+ }
+
render(
', function () {
publicAccessLevel: 'tokenBased'
})
+ // NOTE: updating the scoped project data manually,
+ // as the project data is usually updated via the websocket connection
+ watchCallbacks.project({ ...project, publicAccesLevel: 'tokenBased' })
+
await screen.findByText('Link sharing is on')
const disableButton = await screen.findByRole('button', {
name: 'Turn off link sharing'
@@ -770,6 +789,10 @@ describe('', function () {
publicAccessLevel: 'private'
})
+ // NOTE: updating the scoped project data manually,
+ // as the project data is usually updated via the websocket connection
+ watchCallbacks.project({ ...project, publicAccesLevel: 'private' })
+
await screen.findByText(
'Link sharing is off, only invited users can view this project.'
)