2021-03-12 05:23:46 -05:00
|
|
|
import ShareProjectModal from '../js/features/share-project-modal/components/share-project-modal'
|
2021-05-11 10:25:22 -04:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2022-05-16 05:38:20 -04:00
|
|
|
import { useScope } from './hooks/use-scope'
|
|
|
|
import { ScopeDecorator } from './decorators/scope'
|
|
|
|
import { contacts } from './fixtures/contacts'
|
|
|
|
import { project } from './fixtures/project'
|
2024-10-10 03:26:18 -04:00
|
|
|
import { bsVersionDecorator } from '../../.storybook/utils/with-bootstrap-switcher'
|
2021-03-12 05:23:46 -05:00
|
|
|
|
|
|
|
export const LinkSharingOff = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'private',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LinkSharingOn = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'tokenBased',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LinkSharingLoading = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'tokenBased',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-07-08 01:03:14 -04:00
|
|
|
export const NonProjectOwnerLinkSharingOff = args => {
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'private',
|
|
|
|
},
|
2021-06-16 05:32:38 -04:00
|
|
|
})
|
2022-05-16 05:38:20 -04:00
|
|
|
|
2022-07-08 08:26:24 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-07-08 01:03:14 -04:00
|
|
|
export const NonProjectOwnerLinkSharingOn = args => {
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'tokenBased',
|
|
|
|
},
|
2021-06-16 05:32:38 -04:00
|
|
|
})
|
2022-05-16 05:38:20 -04:00
|
|
|
|
2022-07-08 08:26:24 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const RestrictedTokenMember = args => {
|
2024-06-18 06:01:37 -04:00
|
|
|
// Override isRestrictedTokenMember to be true
|
2021-06-03 09:44:23 -04:00
|
|
|
// Currently this is necessary because the context value is set from window,
|
|
|
|
// however in the future we should change this to set via props
|
2024-06-18 06:01:37 -04:00
|
|
|
window.metaAttributesCache.set('ol-isRestrictedTokenMember', true)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'tokenBased',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LegacyLinkSharingReadAndWrite = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'readAndWrite',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LegacyLinkSharingReadOnly = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
publicAccesLevel: 'readOnly',
|
|
|
|
},
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LimitedCollaborators = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(setupFetchMock)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
...args.project,
|
|
|
|
features: {
|
|
|
|
...args.project.features,
|
|
|
|
collaborators: 3,
|
|
|
|
},
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2022-05-16 05:38:20 -04:00
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <ShareProjectModal {...args} />
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2022-03-28 06:23:21 -04:00
|
|
|
title: 'Editor / Modals / Share Project',
|
2021-03-12 05:23:46 -05:00
|
|
|
component: ShareProjectModal,
|
|
|
|
args: {
|
|
|
|
show: true,
|
|
|
|
animation: false,
|
|
|
|
user: {},
|
2022-09-22 14:24:33 -04:00
|
|
|
project: {
|
|
|
|
...project,
|
|
|
|
owner: {
|
|
|
|
...project.owner,
|
2024-06-18 06:01:37 -04:00
|
|
|
_id: 'story-user',
|
2022-09-22 14:24:33 -04:00
|
|
|
},
|
|
|
|
},
|
2021-03-12 05:23:46 -05:00
|
|
|
},
|
|
|
|
argTypes: {
|
2021-04-27 03:52:58 -04:00
|
|
|
handleHide: { action: 'hide' },
|
2024-10-10 03:26:18 -04:00
|
|
|
...bsVersionDecorator.argTypes,
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2022-05-16 05:38:20 -04:00
|
|
|
decorators: [ScopeDecorator],
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
2021-06-03 09:44:23 -04:00
|
|
|
|
|
|
|
function setupFetchMock(fetchMock) {
|
|
|
|
const delay = 1000
|
|
|
|
|
|
|
|
fetchMock
|
|
|
|
// list contacts
|
|
|
|
.get('express:/user/contacts', { contacts }, { delay })
|
2023-07-03 07:11:39 -04:00
|
|
|
// access tokens
|
|
|
|
.get(
|
|
|
|
'express:/project/:projectId/tokens',
|
|
|
|
{ tokens: project.tokens },
|
|
|
|
{ delay }
|
|
|
|
)
|
2021-06-03 09:44:23 -04:00
|
|
|
// change privacy setting
|
|
|
|
.post('express:/project/:projectId/settings/admin', 200, { delay })
|
|
|
|
// update project member (e.g. set privilege level)
|
|
|
|
.put('express:/project/:projectId/users/:userId', 200, { delay })
|
|
|
|
// remove project member
|
|
|
|
.delete('express:/project/:projectId/users/:userId', 200, { delay })
|
|
|
|
// transfer ownership
|
|
|
|
.post('express:/project/:projectId/transfer-ownership', 200, {
|
|
|
|
delay,
|
|
|
|
})
|
|
|
|
// send invite
|
|
|
|
.post('express:/project/:projectId/invite', 200, { delay })
|
|
|
|
// delete invite
|
|
|
|
.delete('express:/project/:projectId/invite/:inviteId', 204, {
|
|
|
|
delay,
|
|
|
|
})
|
|
|
|
// resend invite
|
|
|
|
.post('express:/project/:projectId/invite/:inviteId/resend', 200, {
|
|
|
|
delay,
|
|
|
|
})
|
|
|
|
// send analytics event
|
|
|
|
.post('express:/event/:key', 200)
|
|
|
|
}
|