Skip to content
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

feat: tutorials implement invitations #154

Merged
merged 28 commits into from
Jun 23, 2021

Conversation

GrazianoRamiro
Copy link
Contributor

@GrazianoRamiro GrazianoRamiro commented Jun 18, 2021

Intention

  • Integrate invitations flow into the tutorials task-app

  • Take the necessary components from react-appkit and replicate them into react-ux

Description

React Client


  • Translate invite.js file into a Typescript file and adjust corresponding typings.

React UX


  • Replicate the following components from react-appkit into react-ux:

    • RedeemDialog

    • DialogHeading

    • PartySharingDialog

    • BotDialog

    • MemberAvatar

    • Theme

  • Extract the following components into their own file:

    • PendingInvitation
    • PendingOfflineInvitation
    • TableCell
  • Replicate the following hooks from react-appkit into react-ux:

    • useKeywords
    • useMembers
  • Update compilerOptions to point to es2019 to support Array.flat method.

Tutorials Tasks App


  • Implement PartySharingDialog and RedeemDialog in order to support invitations

  • Add REACT_APP_SWARM_SIGNAL environment variable in the tasks-app to be able to customize it.

  • Remove sentry commented stuff

  • Add documentation to be able to use a local signal server to test invitations

  • Leave a comment of open issue related StrictMode and some MaterialUI components: Tutorials - React StrictMode triggers warnings #157

Open tasks

  • Make Braneframe use PartySharingDialog and RedeemDialog from react-ux instead of their own copy of the components

  • Tidy up existing documentation and prepare a proper walkthrough of the tutorials app

  • Implement Storybooks within the tutorials app?

@GrazianoRamiro GrazianoRamiro marked this pull request as ready for review June 22, 2021 20:23
@rzadp
Copy link
Contributor

rzadp commented Jun 23, 2021

Implement Storybooks within the tutorials app?

I'm not sure if we want that. We had some hard time configuring Storybooks, the fact that there is a webpack with a hidden config inside the storybooks is not helping. So maybe it will be better to keep the tutorials app as lean as possible.

persistent: true,
},
swarm: {
signal: REACT_APP_SWARM_SIGNAL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app is going to silently not work if the user forgots to take care of .env file.
Maybe it would be a good idea to throw an error if REACT_APP_SWARM_SIGNAL is not present, or provide a default?
A default would be wss://apollo3.kube.moon.dxos.network/dxos/signal (note: not apollo1 which is not there atm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's why apollo1 was not working for me. Great then. Yup, I agree with you, I'll add that sanity check of the variable to #158 to work on it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User (developer) config should be via a YML file. The SDK should read this file and augment it.
No constants (e.g., apollo1, 2, 3) should be in code.
We should not introduce ENV variables for individual properties (it becomes really complicated). If we need something like that then we COULD have the .env point to a different config file.

@rzadp
Copy link
Contributor

rzadp commented Jun 23, 2021

This is a first step of #158

@rzadp rzadp merged commit b9c7427 into main Jun 23, 2021
@rzadp rzadp deleted the feature/tutorials-implement-invitations branch June 23, 2021 09:18
};

// Hook to redeem an invitation Code and provide the PIN authentication if needed.
export function useInvitationRedeemer ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** */ comment.
Use arrow functions.

import React, { useState, useEffect } from 'react';

import { makeStyles } from '@material-ui/core';
import Button from '@material-ui/core/Button';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move to?

import { 
  A, 
  B, 
  C 
} from '.../core'

const [inviteRequestTime, setInviteRequestTime] = useState<number>();

const [contacts] = useContacts();
const invitableContacts = contacts?.filter((c) => !members.some((m) => m.publicKey.toHex() === c.publicKey.toHex())); // contacts not already in this party
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Contacts not already in this party." (Capitalized, period)

persistent: true,
},
swarm: {
signal: REACT_APP_SWARM_SIGNAL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User (developer) config should be via a YML file. The SDK should read this file and augment it.
No constants (e.g., apollo1, 2, 3) should be in code.
We should not introduce ENV variables for individual properties (it becomes really complicated). If we need something like that then we COULD have the .env point to a different config file.

@@ -35,7 +35,7 @@ import { Client } from '@dxos/client';

const client = new Client({
swarm: {
signal: 'wss://apollo1.kube.moon.dxos.network/dxos/signal'
signal: 'wss://apollo3.kube.moon.dxos.network/dxos/signal'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to figure out how to deal with constants for tutorials.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to change the tutorial and make the user run his own signal server locally?
We could completely get rid of this constant.

cp .env.example .env
```

Next, edit the `.env` file, and set `REACT_APP_SWAM_SIGNAL` variable as:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, all config from the YML file.

1. Run the local signal server

```bash
npx @dxos/signal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create TODO for someone: this should be @dxos/signal-server

@richburdon
Copy link
Member

Please add BASIC storybooks for any components that are added here.

@rzadp
Copy link
Contributor

rzadp commented Jun 23, 2021

About the code style suggestions - If possible, these should be expressed as rules in our eslint config. We use that config everywhere so that the code style is consistent in every repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants