-
Notifications
You must be signed in to change notification settings - Fork 530
Expand file tree
/
Copy pathheaderShare.js
More file actions
70 lines (61 loc) · 2.64 KB
/
Copy pathheaderShare.js
File metadata and controls
70 lines (61 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import {Provider} from 'react-redux';
import {createReactRoot} from '@cdo/apps/util/createReactRoot';
import {AllPublishableProjectTypes} from '@cdo/generated-scripts/sharedConstants';
import {getStore} from '../redux';
import ShareDialog from './components/ShareDialog';
import {showShareDialog} from './components/shareDialogRedux';
import popupWindow from './popup-window';
export function shareProject(shareUrl) {
dashboard.project.saveIfSourcesChanged().then(() => {
var dialogDom = document.getElementById('project-share-dialog');
if (!dialogDom) {
dialogDom = document.createElement('div');
dialogDom.setAttribute('id', 'project-share-dialog');
document.body.appendChild(dialogDom);
}
const appType = dashboard.project.getStandaloneApp();
const selectedSong = dashboard.project.getSelectedSong();
// The AgeDialog used by Dance Party stores an 'ad_anon_over13' cookie for signed out users,
// so we want to use that when we decide whether the user can share their project via social media.
const pageConstants = getStore().getState().pageConstants;
let canShareSocial;
if (appType === 'dance') {
const is13Plus = sessionStorage.getItem('ad_anon_over13') === 'true';
canShareSocial =
pageConstants.is13Plus || (!pageConstants.isSignedIn && is13Plus);
} else {
canShareSocial = pageConstants.is13Plus || !pageConstants.isSignedIn;
}
// Allow publishing for any project type that students can publish.
// Younger students can now get to the share dialog if their teacher allows
// it. ShareAllowedDialog will disable publishing, even if canPublish is true,
// if the project is in restricted share mode.
const canPublish =
!!appOptions.isSignedIn && AllPublishableProjectTypes.includes(appType);
createReactRoot(
<Provider store={getStore()}>
<ShareDialog
isProjectLevel={!!dashboard.project.isProjectLevel()}
allowSignedOutShare={appType === 'dance'}
shareUrl={shareUrl}
selectedSong={selectedSong}
thumbnailUrl={dashboard.project.getThumbnailUrl()}
isAbusive={dashboard.project.exceedsAbuseThreshold()}
canPrint={appType === 'artist'}
canPublish={canPublish}
channelId={dashboard.project.getCurrentId()}
appType={appType}
onClickPopup={popupWindow}
canShareSocial={canShareSocial}
userSharingDisabled={appOptions.userSharingDisabled}
/>
</Provider>,
dialogDom,
{
legacyReactDomRender: true,
}
);
getStore().dispatch(showShareDialog());
});
}