-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/room ownership #833
Closed
Closed
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb343a2
Revert "Remove roles"
brianpeiris 53de046
Revert "Remove postWithAuth"
brianpeiris 1c50ede
Revert "Remove sign in UI from home page"
brianpeiris 3f10142
Revert "Remove sign in UI from home page"
brianpeiris 0355073
Fix link click callback
brianpeiris b2ca98a
Fix signin/out on home page
brianpeiris 5ea75a8
Send auth token in hub channel join payload
brianpeiris ae8784f
isOwner instead of roles
brianpeiris 01a2637
Merge branch 'master' of github.com:mozilla/hubs into feature/room-ow…
brianpeiris 502cffb
Fix signedIn boolean
brianpeiris 8cdfd06
Remove todo
brianpeiris fd43000
Remove postWithAuth
brianpeiris 60bd1c0
Rename token to auth_token
brianpeiris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,15 @@ import mozLogo from "../assets/images/moz-logo-black.png"; | |
import classNames from "classnames"; | ||
import { ENVIRONMENT_URLS } from "../assets/environments/environments"; | ||
import { connectToReticulum } from "../utils/phoenix-utils"; | ||
import maskEmail from "../utils/mask-email"; | ||
|
||
import styles from "../assets/stylesheets/index.scss"; | ||
|
||
import HubCreatePanel from "./hub-create-panel.js"; | ||
import AuthDialog from "./auth-dialog.js"; | ||
import ReportDialog from "./report-dialog.js"; | ||
import JoinUsDialog from "./join-us-dialog.js"; | ||
import ReportDialog from "./report-dialog.js"; | ||
import SignInDialog from "./sign-in-dialog.js"; | ||
import UpdatesDialog from "./updates-dialog.js"; | ||
import DialogContainer from "./dialog-container.js"; | ||
import { WithHoverSound } from "./wrap-with-audio"; | ||
|
@@ -29,6 +31,8 @@ class HomeRoot extends Component { | |
static propTypes = { | ||
intl: PropTypes.object, | ||
sceneId: PropTypes.string, | ||
store: PropTypes.object, | ||
authChannel: PropTypes.object, | ||
authVerify: PropTypes.bool, | ||
authTopic: PropTypes.string, | ||
authToken: PropTypes.string, | ||
|
@@ -41,12 +45,18 @@ class HomeRoot extends Component { | |
state = { | ||
environments: [], | ||
dialog: null, | ||
signedIn: null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, maybe make this |
||
mailingListEmail: "", | ||
mailingListPrivacy: false | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state.signedIn = props.authChannel.authenticated; | ||
this.state.email = props.authChannel.email; | ||
} | ||
|
||
componentDidMount() { | ||
this.closeDialog = this.closeDialog.bind(this); | ||
if (this.props.authVerify) { | ||
this.showAuthDialog(true); | ||
this.verifyAuth().then(this.showAuthDialog); | ||
|
@@ -77,8 +87,14 @@ class HomeRoot extends Component { | |
channel.push("auth_verified", { token: this.props.authToken }); | ||
} | ||
|
||
showDialog = (DialogClass, props = {}) => { | ||
this.setState({ | ||
dialog: <DialogClass {...{ onClose: this.closeDialog, ...props }} /> | ||
}); | ||
}; | ||
|
||
showAuthDialog = verifying => { | ||
this.setState({ dialog: <AuthDialog closable="false" verifying={verifying} authOrigin={this.props.authOrigin} /> }); | ||
this.showDialog(AuthDialog, { closable: false, verifying, authOrigin: this.props.authOrigin }); | ||
}; | ||
|
||
loadHomeVideo = () => { | ||
|
@@ -87,33 +103,40 @@ class HomeRoot extends Component { | |
playVideoWithStopOnBlur(videoEl); | ||
}; | ||
|
||
closeDialog() { | ||
closeDialog = () => { | ||
this.setState({ dialog: null }); | ||
} | ||
}; | ||
|
||
showJoinUsDialog() { | ||
this.setState({ dialog: <JoinUsDialog onClose={this.closeDialog} /> }); | ||
} | ||
showJoinUsDialog = () => this.showDialog(JoinUsDialog); | ||
|
||
showReportDialog() { | ||
this.setState({ dialog: <ReportDialog onClose={this.closeDialog} /> }); | ||
} | ||
showReportDialog = () => this.showDialog(ReportDialog); | ||
|
||
showUpdatesDialog() { | ||
this.setState({ | ||
dialog: <UpdatesDialog onClose={this.closeDialog} onSubmittedEmail={() => this.showEmailSubmittedDialog()} /> | ||
showUpdatesDialog = () => | ||
this.showDialog(UpdatesDialog, { | ||
onSubmittedEmail: () => { | ||
this.showDialog( | ||
<DialogContainer>Great! Please check your e-mail to confirm your subscription.</DialogContainer> | ||
); | ||
} | ||
}); | ||
} | ||
|
||
showEmailSubmittedDialog() { | ||
this.setState({ | ||
dialog: ( | ||
<DialogContainer onClose={this.closeDialog}> | ||
Great! Please check your e-mail to confirm your subscription. | ||
</DialogContainer> | ||
) | ||
showSignInDialog = () => { | ||
this.showDialog(SignInDialog, { | ||
message: messages["sign-in.prompt"], | ||
onSignIn: async email => { | ||
const { authComplete } = await this.props.authChannel.startAuthentication(email); | ||
this.showDialog(SignInDialog, { authStarted: true }); | ||
await authComplete; | ||
this.setState({ signedIn: true, email }); | ||
this.closeDialog(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
signOut = () => { | ||
this.props.authChannel.signOut(); | ||
this.setState({ signedIn: false }); | ||
}; | ||
|
||
loadEnvironmentFromScene = async () => { | ||
let sceneUrlBase = "/api/v1/scenes"; | ||
|
@@ -155,7 +178,7 @@ class HomeRoot extends Component { | |
Promise.all(environmentLoads).then(() => this.setState({ environments })); | ||
}; | ||
|
||
onDialogLinkClicked = trigger => { | ||
onLinkClicked = trigger => { | ||
return e => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
@@ -204,6 +227,22 @@ class HomeRoot extends Component { | |
</WithHoverSound> | ||
</div> | ||
</div> | ||
<div className={styles.signIn}> | ||
{this.state.signedIn ? ( | ||
<div> | ||
<span> | ||
<FormattedMessage id="sign-in.as" /> {maskEmail(this.state.email)} | ||
</span>{" "} | ||
<a onClick={this.onLinkClicked(this.signOut)}> | ||
<FormattedMessage id="sign-in.out" /> | ||
</a> | ||
</div> | ||
) : ( | ||
<a onClick={this.onLinkClicked(this.showSignInDialog)}> | ||
<FormattedMessage id="sign-in.in" /> | ||
</a> | ||
)} | ||
</div> | ||
</div> | ||
<div className={styles.heroContent}> | ||
<div className={styles.attribution}> | ||
|
@@ -264,7 +303,7 @@ class HomeRoot extends Component { | |
className={styles.link} | ||
rel="noopener noreferrer" | ||
href="#" | ||
onClick={this.onDialogLinkClicked(this.showJoinUsDialog.bind(this))} | ||
onClick={this.onLinkClicked(this.showJoinUsDialog)} | ||
> | ||
<FormattedMessage id="home.join_us" /> | ||
</a> | ||
|
@@ -274,7 +313,7 @@ class HomeRoot extends Component { | |
className={styles.link} | ||
rel="noopener noreferrer" | ||
href="#" | ||
onClick={this.onDialogLinkClicked(this.showUpdatesDialog.bind(this))} | ||
onClick={this.onLinkClicked(this.showUpdatesDialog)} | ||
> | ||
<FormattedMessage id="home.get_updates" /> | ||
</a> | ||
|
@@ -284,7 +323,7 @@ class HomeRoot extends Component { | |
className={styles.link} | ||
rel="noopener noreferrer" | ||
href="#" | ||
onClick={this.onDialogLinkClicked(this.showReportDialog.bind(this))} | ||
onClick={this.onLinkClicked(this.showReportDialog)} | ||
> | ||
<FormattedMessage id="home.report_issue" /> | ||
</a> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ import en from "react-intl/locale-data/en"; | |
import styles from "../assets/stylesheets/scene-ui.scss"; | ||
import hubLogo from "../assets/images/hub-preview-white.png"; | ||
import spokeLogo from "../assets/images/spoke_logo_black.png"; | ||
import { getReticulumFetchUrl } from "../utils/phoenix-utils"; | ||
import { generateHubName } from "../utils/name-generation"; | ||
import { createAndRedirectToNewHub } from "../utils/phoenix-utils"; | ||
import { WithHoverSound } from "./wrap-with-audio"; | ||
import CreateRoomDialog from "./create-room-dialog.js"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
|
@@ -52,23 +51,8 @@ class SceneUI extends Component { | |
this.props.scene.removeEventListener("loaded", this.onSceneLoaded); | ||
} | ||
|
||
createRoom = async () => { | ||
const payload = { hub: { name: this.state.customRoomName || generateHubName(), scene_id: this.props.sceneId } }; | ||
const createUrl = getReticulumFetchUrl("/api/v1/hubs"); | ||
|
||
const res = await fetch(createUrl, { | ||
body: JSON.stringify(payload), | ||
headers: { "content-type": "application/json" }, | ||
method: "POST" | ||
}); | ||
|
||
const hub = await res.json(); | ||
|
||
if (!process.env.RETICULUM_SERVER || document.location.host === process.env.RETICULUM_SERVER) { | ||
document.location = hub.url; | ||
} else { | ||
document.location = `/hub.html?hub_id=${hub.hub_id}`; | ||
} | ||
createRoom = () => { | ||
createAndRedirectToNewHub(this.state.customRoomName, this.props.sceneId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops |
||
}; | ||
|
||
render() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notes from other PR, but these should prob be
auth_token
vsperm_token