-
Notifications
You must be signed in to change notification settings - Fork 262
/
Copy pathPublishDialog.js
127 lines (117 loc) · 4.26 KB
/
PublishDialog.js
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React, { Component } from "react";
import PropTypes from "prop-types";
import configs from "../configs";
import PreviewDialog from "../ui/dialogs/PreviewDialog";
import StringInput from "../ui/inputs/StringInput";
import BooleanInput from "../ui/inputs/BooleanInput";
import FormField from "../ui/inputs/FormField";
export default class PublishDialog extends Component {
static propTypes = {
onCancel: PropTypes.func,
screenshotUrl: PropTypes.string,
contentAttributions: PropTypes.array,
onPublish: PropTypes.func,
published: PropTypes.bool,
sceneUrl: PropTypes.string,
initialSceneParams: PropTypes.object
};
constructor(props) {
super(props);
this.state = {
name: "",
creatorAttribution: "",
allowRemixing: false,
allowPromotion: false,
...props.initialSceneParams
};
}
onChangeName = name => this.setState({ name });
onChangeCreatorAttribution = creatorAttribution => this.setState({ creatorAttribution });
onChangeAllowRemixing = allowRemixing => this.setState({ allowRemixing });
onChangeAllowPromotion = allowPromotion => this.setState({ allowPromotion });
onConfirm = () => {
const publishState = { ...this.state, contentAttributions: this.props.contentAttributions };
publishState.name = publishState.name.trim();
publishState.creatorAttribution = publishState.creatorAttribution.trim();
this.props.onPublish(publishState);
};
render() {
const { onCancel, screenshotUrl, contentAttributions } = this.props;
const { creatorAttribution, name, allowRemixing, allowPromotion } = this.state;
return (
<PreviewDialog
imageSrc={screenshotUrl}
title={configs.isMoz() ? "Publish to Hubs" : "Publish Scene"}
onConfirm={this.onConfirm}
onCancel={onCancel}
confirmLabel="Save and Publish"
>
<FormField>
<label htmlFor="sceneName">Scene Name</label>
<StringInput
id="sceneName"
required
pattern={"[A-Za-z0-9-':\"!@#$%^&*(),.?~ ]{4,64}"}
title="Name must be between 4 and 64 characters and cannot contain underscores"
value={name}
onChange={this.onChangeName}
/>
</FormField>
<FormField>
<label htmlFor="creatorAttribution">Your Attribution (optional):</label>
<StringInput id="creatorAttribution" value={creatorAttribution} onChange={this.onChangeCreatorAttribution} />
</FormField>
<FormField inline>
<label htmlFor="allowRemixing">
Allow{" "}
<a
href="https://github.com/Hubs-Foundation/Spoke/blob/master/REMIXING.md"
target="_blank"
rel="noopener noreferrer"
>
Remixing
</a>
with
<br />
Creative Commons
<a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener noreferrer">
CC-BY 3.0
</a>
</label>
<BooleanInput id="allowRemixing" value={allowRemixing} onChange={this.onChangeAllowRemixing} />
</FormField>
<FormField inline>
<label htmlFor="allowPromotion">
Allow {configs.isMoz() ? "Hubs Foundation to " : ""}
<a
href="https://github.com/Hubs-Foundation/Spoke/blob/master/PROMOTION.md"
target="_blank"
rel="noopener noreferrer"
>
{configs.isMoz() ? "promote" : "promotion"}
</a>{" "}
{configs.isMoz() ? "" : "of "}my scene
</label>
<BooleanInput id="allowPromotion" value={allowPromotion} onChange={this.onChangeAllowPromotion} />
</FormField>
{contentAttributions && (
<FormField>
<label>Model Attribution:</label>
<ul>
{contentAttributions.map(
(a, i) =>
a.author &&
a.title && (
<li key={i}>
<b>{`${a.title}`}</b>
{(a.author && ` (by ${a.author})`) || ` (by Unknown)`}
</li>
)
)}
</ul>
</FormField>
)}
</PreviewDialog>
);
}
}