mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Revert "Send fastly token to gui"
This commit is contained in:
parent
0b68a9269e
commit
e896c60f9a
5 changed files with 55 additions and 78 deletions
|
@ -11,18 +11,9 @@ class Storage extends ScratchStorage {
|
||||||
super();
|
super();
|
||||||
this.addWebSource(
|
this.addWebSource(
|
||||||
[this.AssetType.Project],
|
[this.AssetType.Project],
|
||||||
this.getProjectGetConfig.bind(this)
|
projectAsset => `${PROJECT_HOST}/${projectAsset.assetId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
setProjectToken (projectToken) {
|
|
||||||
this.projectToken = projectToken;
|
|
||||||
}
|
|
||||||
getProjectGetConfig (projectAsset) {
|
|
||||||
const path = `${PROJECT_HOST}/${projectAsset.assetId}`;
|
|
||||||
const qs = this.projectToken ? `?token=${this.projectToken}` : '';
|
|
||||||
return path + qs;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const storage = new Storage();
|
const storage = new Storage();
|
||||||
|
|
|
@ -40,23 +40,19 @@ class EmbedView extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.projectInfo && this.props.projectInfo.project_token){
|
return (
|
||||||
return (
|
<React.Fragment>
|
||||||
<React.Fragment>
|
<Meta projectInfo={this.props.projectInfo} />
|
||||||
<Meta projectInfo={this.props.projectInfo} />
|
<IntlGUI
|
||||||
<IntlGUI
|
assetHost={this.props.assetHost}
|
||||||
assetHost={this.props.assetHost}
|
basePath="/"
|
||||||
basePath="/"
|
className="gui"
|
||||||
className="gui"
|
projectHost={this.props.projectHost}
|
||||||
projectHost={this.props.projectHost}
|
projectId={this.state.projectId}
|
||||||
projectId={this.state.projectId}
|
projectTitle={this.props.projectInfo.title}
|
||||||
projectTitle={this.props.projectInfo.title}
|
/>
|
||||||
projectToken={this.props.projectInfo.project_token}
|
</React.Fragment>
|
||||||
/>
|
);
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,6 @@ const PreviewPresentation = ({
|
||||||
isFullScreen={isFullScreen}
|
isFullScreen={isFullScreen}
|
||||||
previewInfoVisible="false"
|
previewInfoVisible="false"
|
||||||
projectHost={projectHost}
|
projectHost={projectHost}
|
||||||
projectToken={projectInfo.project_token}
|
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
onGreenFlag={onGreenFlag}
|
onGreenFlag={onGreenFlag}
|
||||||
onProjectLoaded={onProjectLoaded}
|
onProjectLoaded={onProjectLoaded}
|
||||||
|
|
|
@ -142,16 +142,13 @@ class Preview extends React.Component {
|
||||||
this.props.sessionStatus === sessionActions.Status.FETCHED) ||
|
this.props.sessionStatus === sessionActions.Status.FETCHED) ||
|
||||||
(this.state.projectId !== prevState.projectId))) {
|
(this.state.projectId !== prevState.projectId))) {
|
||||||
this.fetchCommunityData();
|
this.fetchCommunityData();
|
||||||
|
this.getProjectData(this.state.projectId, true /* Show cloud/username alerts */);
|
||||||
if (this.state.justShared) {
|
if (this.state.justShared) {
|
||||||
this.setState({ // eslint-disable-line react/no-did-update-set-state
|
this.setState({ // eslint-disable-line react/no-did-update-set-state
|
||||||
justShared: false
|
justShared: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
|
|
||||||
storage.setProjectToken(this.props.projectInfo.project_token);
|
|
||||||
this.loadProjectData(this.state.projectId, true /* Show cloud/username alerts */);
|
|
||||||
}
|
|
||||||
if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) {
|
if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) {
|
||||||
this.props.resetProject();
|
this.props.resetProject();
|
||||||
if (this.state.justRemixed || this.state.justShared) {
|
if (this.state.justRemixed || this.state.justShared) {
|
||||||
|
@ -199,8 +196,7 @@ class Preview extends React.Component {
|
||||||
|
|
||||||
// Switching out of editor mode, refresh data that comes from project json
|
// Switching out of editor mode, refresh data that comes from project json
|
||||||
if (this.props.playerMode && !prevProps.playerMode) {
|
if (this.props.playerMode && !prevProps.playerMode) {
|
||||||
storage.setProjectToken(this.props.projectInfo.project_token);
|
this.getProjectData(
|
||||||
this.loadProjectData(
|
|
||||||
this.state.projectId,
|
this.state.projectId,
|
||||||
false // Do not show cloud/username alerts again
|
false // Do not show cloud/username alerts again
|
||||||
);
|
);
|
||||||
|
@ -327,7 +323,7 @@ class Preview extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadProjectData (projectId, showAlerts) {
|
getProjectData (projectId, showAlerts) {
|
||||||
if (projectId <= 0) return 0;
|
if (projectId <= 0) return 0;
|
||||||
storage
|
storage
|
||||||
.load(storage.AssetType.Project, projectId, storage.DataFormat.JSON)
|
.load(storage.AssetType.Project, projectId, storage.DataFormat.JSON)
|
||||||
|
@ -833,46 +829,43 @@ class Preview extends React.Component {
|
||||||
/>
|
/>
|
||||||
</Page> :
|
</Page> :
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{this.props.projectInfo && this.props.projectInfo.project_token && (
|
<IntlGUI
|
||||||
<IntlGUI
|
assetHost={this.props.assetHost}
|
||||||
assetHost={this.props.assetHost}
|
authorId={this.props.authorId}
|
||||||
authorId={this.props.authorId}
|
authorThumbnailUrl={this.props.authorThumbnailUrl}
|
||||||
authorThumbnailUrl={this.props.authorThumbnailUrl}
|
authorUsername={this.props.authorUsername}
|
||||||
authorUsername={this.props.authorUsername}
|
backpackHost={this.props.backpackHost}
|
||||||
backpackHost={this.props.backpackHost}
|
backpackVisible={this.props.canUseBackpack}
|
||||||
backpackVisible={this.props.canUseBackpack}
|
basePath="/"
|
||||||
basePath="/"
|
canCreateCopy={this.props.canCreateCopy}
|
||||||
canCreateCopy={this.props.canCreateCopy}
|
canCreateNew={this.props.canCreateNew}
|
||||||
canCreateNew={this.props.canCreateNew}
|
canEditTitle={this.props.canEditTitleInEditor}
|
||||||
canEditTitle={this.props.canEditTitleInEditor}
|
canRemix={this.props.canRemix}
|
||||||
canRemix={this.props.canRemix}
|
canSave={this.props.canSave}
|
||||||
canSave={this.props.canSave}
|
canShare={this.props.canShare}
|
||||||
canShare={this.props.canShare}
|
className="gui"
|
||||||
className="gui"
|
cloudHost={this.props.cloudHost}
|
||||||
cloudHost={this.props.cloudHost}
|
enableCommunity={this.props.enableCommunity}
|
||||||
enableCommunity={this.props.enableCommunity}
|
hasCloudPermission={this.props.isScratcher}
|
||||||
hasCloudPermission={this.props.isScratcher}
|
isShared={this.props.isShared}
|
||||||
isShared={this.props.isShared}
|
projectHost={this.props.projectHost}
|
||||||
projectHost={this.props.projectHost}
|
projectId={this.state.projectId}
|
||||||
projectToken={this.props.projectToken}
|
projectTitle={this.props.projectInfo.title}
|
||||||
projectId={this.state.projectId}
|
renderLogin={this.renderLogin}
|
||||||
projectTitle={this.props.projectInfo.title}
|
onClickLogo={this.handleClickLogo}
|
||||||
renderLogin={this.renderLogin}
|
onGreenFlag={this.handleGreenFlag}
|
||||||
onClickLogo={this.handleClickLogo}
|
onLogOut={this.props.handleLogOut}
|
||||||
onGreenFlag={this.handleGreenFlag}
|
onOpenRegistration={this.props.handleOpenRegistration}
|
||||||
onLogOut={this.props.handleLogOut}
|
onProjectLoaded={this.handleProjectLoaded}
|
||||||
onOpenRegistration={this.props.handleOpenRegistration}
|
onRemixing={this.handleIsRemixing}
|
||||||
onProjectLoaded={this.handleProjectLoaded}
|
onSetLanguage={this.handleSetLanguage}
|
||||||
onRemixing={this.handleIsRemixing}
|
onShare={this.handleShare}
|
||||||
onSetLanguage={this.handleSetLanguage}
|
onToggleLoginOpen={this.props.handleToggleLoginOpen}
|
||||||
onShare={this.handleShare}
|
onUpdateProjectData={this.handleUpdateProjectData}
|
||||||
onToggleLoginOpen={this.props.handleToggleLoginOpen}
|
onUpdateProjectId={this.handleUpdateProjectId}
|
||||||
onUpdateProjectData={this.handleUpdateProjectData}
|
onUpdateProjectThumbnail={this.props.handleUpdateProjectThumbnail}
|
||||||
onUpdateProjectId={this.handleUpdateProjectId}
|
onUpdateProjectTitle={this.handleUpdateProjectTitle}
|
||||||
onUpdateProjectThumbnail={this.props.handleUpdateProjectThumbnail}
|
/>
|
||||||
onUpdateProjectTitle={this.handleUpdateProjectTitle}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{this.props.registrationOpen && (
|
{this.props.registrationOpen && (
|
||||||
this.props.useScratch3Registration ? (
|
this.props.useScratch3Registration ? (
|
||||||
<Scratch3Registration
|
<Scratch3Registration
|
||||||
|
@ -951,7 +944,6 @@ Preview.propTypes = {
|
||||||
parent: projectShape,
|
parent: projectShape,
|
||||||
playerMode: PropTypes.bool,
|
playerMode: PropTypes.bool,
|
||||||
projectHost: PropTypes.string.isRequired,
|
projectHost: PropTypes.string.isRequired,
|
||||||
projectToken: PropTypes.string.isRequired,
|
|
||||||
projectInfo: projectShape,
|
projectInfo: projectShape,
|
||||||
projectNotAvailable: PropTypes.bool,
|
projectNotAvailable: PropTypes.bool,
|
||||||
projectStudios: PropTypes.arrayOf(PropTypes.object),
|
projectStudios: PropTypes.arrayOf(PropTypes.object),
|
||||||
|
|
|
@ -31,6 +31,5 @@ export const projectShape = shape({
|
||||||
remix: shape({
|
remix: shape({
|
||||||
parent: number,
|
parent: number,
|
||||||
root: number
|
root: number
|
||||||
}),
|
})
|
||||||
project_token: string
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue