|
|
@@ -1,62 +1,71 @@
|
|
|
import { useEffect } from 'react'
|
|
|
import ShareProjectModal from '../js/features/share-project-modal/components/share-project-modal'
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
|
|
-import { withContextRoot } from './utils/with-context-root'
|
|
|
+import { useScope } from './hooks/use-scope'
|
|
|
+import { ScopeDecorator } from './decorators/scope'
|
|
|
+import { contacts } from './fixtures/contacts'
|
|
|
+import { project } from './fixtures/project'
|
|
|
|
|
|
export const LinkSharingOff = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'private',
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'private',
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const LinkSharingOn = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'tokenBased',
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'tokenBased',
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const LinkSharingLoading = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'tokenBased',
|
|
|
- tokens: undefined,
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'tokenBased',
|
|
|
+ tokens: undefined,
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const NonAdminLinkSharingOff = args => {
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'private',
|
|
|
- }
|
|
|
-
|
|
|
- return withContextRoot(<ShareProjectModal {...args} isAdmin={false} />, {
|
|
|
- project,
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'private',
|
|
|
+ },
|
|
|
})
|
|
|
+
|
|
|
+ return <ShareProjectModal {...args} isAdmin={false} />
|
|
|
}
|
|
|
|
|
|
export const NonAdminLinkSharingOn = args => {
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'tokenBased',
|
|
|
- }
|
|
|
-
|
|
|
- return withContextRoot(<ShareProjectModal {...args} isAdmin={false} />, {
|
|
|
- project,
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'tokenBased',
|
|
|
+ },
|
|
|
})
|
|
|
+
|
|
|
+ return <ShareProjectModal {...args} isAdmin={false} />
|
|
|
}
|
|
|
|
|
|
export const RestrictedTokenMember = args => {
|
|
|
@@ -64,103 +73,64 @@ export const RestrictedTokenMember = args => {
|
|
|
// original value on unmount
|
|
|
// Currently this is necessary because the context value is set from window,
|
|
|
// however in the future we should change this to set via props
|
|
|
- const originalIsRestrictedTokenMember = window.isRestrictedTokenMember
|
|
|
- window.isRestrictedTokenMember = true
|
|
|
useEffect(() => {
|
|
|
+ const originalIsRestrictedTokenMember = window.isRestrictedTokenMember
|
|
|
+ window.isRestrictedTokenMember = true
|
|
|
return () => {
|
|
|
window.isRestrictedTokenMember = originalIsRestrictedTokenMember
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'tokenBased',
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'tokenBased',
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const LegacyLinkSharingReadAndWrite = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'readAndWrite',
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'readAndWrite',
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const LegacyLinkSharingReadOnly = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- publicAccesLevel: 'readOnly',
|
|
|
- }
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ publicAccesLevel: 'readOnly',
|
|
|
+ },
|
|
|
+ })
|
|
|
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export const LimitedCollaborators = args => {
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
|
|
- const project = {
|
|
|
- ...args.project,
|
|
|
- features: {
|
|
|
- ...args.project.features,
|
|
|
- collaborators: 3,
|
|
|
+ useScope({
|
|
|
+ project: {
|
|
|
+ ...args.project,
|
|
|
+ features: {
|
|
|
+ ...args.project.features,
|
|
|
+ collaborators: 3,
|
|
|
+ },
|
|
|
},
|
|
|
- }
|
|
|
-
|
|
|
- return withContextRoot(<ShareProjectModal {...args} />, { project })
|
|
|
-}
|
|
|
+ })
|
|
|
|
|
|
-const project = {
|
|
|
- _id: 'a-project',
|
|
|
- name: 'A Project',
|
|
|
- features: {
|
|
|
- collaborators: -1, // unlimited
|
|
|
- },
|
|
|
- publicAccesLevel: 'private',
|
|
|
- tokens: {
|
|
|
- readOnly: 'ro-token',
|
|
|
- readAndWrite: 'rw-token',
|
|
|
- },
|
|
|
- owner: {
|
|
|
- _id: 'fakeOwnerId',
|
|
|
- email: 'stories@overleaf.com',
|
|
|
- },
|
|
|
- members: [
|
|
|
- {
|
|
|
- _id: 'viewer-member',
|
|
|
- type: 'user',
|
|
|
- privileges: 'readOnly',
|
|
|
- name: 'Viewer User',
|
|
|
- email: 'viewer@example.com',
|
|
|
- },
|
|
|
- {
|
|
|
- _id: 'author-member',
|
|
|
- type: 'user',
|
|
|
- privileges: 'readAndWrite',
|
|
|
- name: 'Author User',
|
|
|
- email: 'author@example.com',
|
|
|
- },
|
|
|
- ],
|
|
|
- invites: [
|
|
|
- {
|
|
|
- _id: 'test-invite-1',
|
|
|
- privileges: 'readOnly',
|
|
|
- name: 'Invited Viewer',
|
|
|
- email: 'invited-viewer@example.com',
|
|
|
- },
|
|
|
- {
|
|
|
- _id: 'test-invite-2',
|
|
|
- privileges: 'readAndWrite',
|
|
|
- name: 'Invited Author',
|
|
|
- email: 'invited-author@example.com',
|
|
|
- },
|
|
|
- ],
|
|
|
+ return <ShareProjectModal {...args} />
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
@@ -176,50 +146,9 @@ export default {
|
|
|
argTypes: {
|
|
|
handleHide: { action: 'hide' },
|
|
|
},
|
|
|
+ decorators: [ScopeDecorator],
|
|
|
}
|
|
|
|
|
|
-const contacts = [
|
|
|
- // user with edited name
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- email: 'test-user@example.com',
|
|
|
- first_name: 'Test',
|
|
|
- last_name: 'User',
|
|
|
- name: 'Test User',
|
|
|
- },
|
|
|
- // user with default name (email prefix)
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- email: 'test@example.com',
|
|
|
- first_name: 'test',
|
|
|
- },
|
|
|
- // no last name
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- first_name: 'Eratosthenes',
|
|
|
- email: 'eratosthenes@example.com',
|
|
|
- },
|
|
|
- // more users
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- first_name: 'Claudius',
|
|
|
- last_name: 'Ptolemy',
|
|
|
- email: 'ptolemy@example.com',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- first_name: 'Abd al-Rahman',
|
|
|
- last_name: 'Al-Sufi',
|
|
|
- email: 'al-sufi@example.com',
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'user',
|
|
|
- first_name: 'Nicolaus',
|
|
|
- last_name: 'Copernicus',
|
|
|
- email: 'copernicus@example.com',
|
|
|
- },
|
|
|
-]
|
|
|
-
|
|
|
function setupFetchMock(fetchMock) {
|
|
|
const delay = 1000
|
|
|
|