Options
All
  • Public
  • Public/Protected
  • All
Menu

@unifed/frontend

This package contains the frontend code for the application. It is written with React, using GraphQL for communication with the backend.

The main two directories in this package are components and pages.

There are also tests (which can be run using yarn test) to ensure that nothing has regressed.

Components

This directory contains the different components that we have created for the application. They are used to break pages into smaller parts and improve code reusability.

In particular, these components are reused within various other components or pages.

Pages

This directory contains the different pages that users can access when they are on the application. Each page corresponds to a URL defined in the App component. They make use of both components from the components directory and other local components stored with the page, which are only useful for that particular page.

App

This is located in the components directory and is the main entry point for the frontend of the application (it is included by index.ts, which bootstraps the application). It takes care of URL routing and manages the state of the application, such as whether the user is logged in and whether it is in dark mode.

Documentation

Further developer documentation for this package is available here.

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

ButtonLinkProps

ButtonLinkProps: Omit<ButtonProps, "component"> & LinkProps

Properties for the ButtonLink component.

internal

LinkProps

LinkProps: Omit<MaterialLinkProps, "component"> & RouterLinkProps & Pick<Required<RouterLinkProps>, "children">

Properties for the Link component.

internal

PasswordFieldProps

PasswordFieldProps: Omit<TextFieldProps, "type" | "InputProps"> & { InputProps?: Omit<InputProps, "endAdornment"> }

Properties for the PasswordField component.

internal

VideoProps

VideoProps: { muted?: boolean; stream?: MediaStream }

Type declaration

  • Optional muted?: boolean
  • Optional stream?: MediaStream

VideoWrapperProps

VideoWrapperProps: { muted: boolean; onLeaveCall?: () => void; onMuteChange: () => void; self?: boolean; stream?: MediaStream; username: string }

Type declaration

  • muted: boolean
  • Optional onLeaveCall?: () => void
      • (): void
      • Returns void

  • onMuteChange: () => void
      • (): void
      • Returns void

  • Optional self?: boolean
  • Optional stream?: MediaStream
  • username: string

Variables

Const BrowserMockProvider

BrowserMockProvider: FC<BrowserMockProviderProps> = ...

A wrapper used in a number of tests.

Outline:

  • Provides MockedProvider for testing graphQL calls.

  • Provides MemoryRouter and Route for cases where URL params are used.

param
internal

Const UserContext

UserContext: Context<Context> = ...

Imported by components and pages to access the current state of the user, such as their login status and name.

internal

Const accountsClient

accountsClient: AccountsClient = ...

Base authentication client.

internal

Const apolloClient

apolloClient: ApolloClient<NormalizedCacheObject> = ...

Client to deal with apollo queries.

internal

Const approvePostsMutation

approvePostsMutation: DocumentNode = ...

GraphQL mutation to approve a list of posts.

internal

Const baseTheme

baseTheme: ThemeOptions = ...

Properties that are common to both the lightTheme and darkTheme.

internal

Const changeNameQuery

changeNameQuery: DocumentNode = ...

GraphQL query to change the name of a user.

internal

Const createCommunityQuery

createCommunityQuery: DocumentNode = ...

GraphQL query to create a Community.

internal

Const createPostQuery

createPostQuery: DocumentNode = ...

GraphQL query to create a post.

internal

Const darkTheme

darkTheme: ThemeOptions = ...

The properties for the dark theme of the application.

internal

Const defaultUserContext

defaultUserContext: Context = ...

Sets fields and initial values for the UserContext.

internal

Const deletePostQuery

deletePostQuery: DocumentNode = ...

GraphQL query to delete the post with the given id on the given host.

internal

Const deletePostsMutation

deletePostsMutation: DocumentNode = ...

GraphQL mutation to delete a list of posts.

internal

Const editPostQuery

editPostQuery: DocumentNode = ...

GraphQL query to edit a post.

internal

Const getAdminsQuery

getAdminsQuery: DocumentNode = ...

GraphQL query to retrieve the IDs and hosts of the admins of the community the post is a part of.

internal

Const getCommentsQuery

getCommentsQuery: DocumentNode = ...

GraphQL query to get the comments on a post.

internal

Const getCommunitiesQuery

getCommunitiesQuery: DocumentNode = ...

GraphQL query to get the id and title of communities on a given host.

internal

Const getPostQuery

getPostQuery: DocumentNode = ...

GraphQL query to get a post with a given ID on a given host.

internal

Const getPostsQuery

getPostsQuery: DocumentNode = ...

GraphQL query to get the posts to a given community.

internal

Const getSubscribedQuery

getSubscribedQuery: DocumentNode = ...

GraphQL query to get the posts from communities that a user is subscribed to.

internal

Const getUnapprovedPostsQuery

getUnapprovedPostsQuery: DocumentNode = ...

GraphQL query to get the unapproved posts from communities that the user moderates.

internal

Const getUserQuery

getUserQuery: DocumentNode = ...

GraphQL query to get the logged in user's information.

internal

Const getUsersPostsQuery

getUsersPostsQuery: DocumentNode = ...

GraphQL query to get the posts made by a certain user.

internal

Const lightTheme

lightTheme: ThemeOptions = ...

The properties for the light theme of the application.

internal

Const passwordClient

passwordClient: AccountsClientPassword = ...

Authentication client for the password strategy.

internal

Const reportPostQuery

reportPostQuery: DocumentNode = ...

Const subscribeQuery

subscribeQuery: DocumentNode = ...

GraphQL query to subscribe to a community.

internal

Const unsubscribeQuery

unsubscribeQuery: DocumentNode = ...

GraphQL query to unsubscribe from a community.

internal

Functions

AccountMenu

  • AccountMenu(): ReactElement
  • The dropdown menu that is displayed when the user icon in the Header is clicked.

    Outline:

    • The 'Profile' button takes users to their profile page.

    • The 'Settings' button takes users to their account settings page.

    • The 'Logout' button logs the user out of the application.

    internal

    Returns ReactElement

AccountSettingsPage

  • AccountSettingsPage(): ReactElement

AccountTab

ActionButton

  • ActionButton(props: Props): ReactElement

App

  • App(): ReactElement

ButtonLink

CenteredLoader

  • CenteredLoader(props: CircularProgressProps): ReactElement

Comment

Comments

CommunitiesListCard

  • CommunitiesListCard(): ReactElement

CommunityCallPage

  • CommunityCallPage(): ReactElement
  • Allows users to join a group call with other community members.

    Outline:

    • Users are displayed a 'Join' button.

    • Users are placed into a group call with other members after clicking the 'Join' button.

    • Users can mute themselves and other members in the call - useful for 1-on-1 or restricted group conversations.

    • Access to the user's microphone and camera is required.

    internal

    Returns ReactElement

CommunityDescription

CommunityPostsPage

  • CommunityPostsPage(): ReactElement

CreateCommunityDialog

  • CreateCommunityDialog(): ReactElement
  • Used to create a community.

    Outline:

    • Users can click the 'plus' icon in the header of the application.

    • They can then enter a name, ID and description for the community.

    • On success, they are redirected to the new community page.

    • Otherwise they are shown an error message.

    internal

    Returns ReactElement

CreatePostPage

  • CreatePostPage(): ReactElement

EmailVerificationPage

  • EmailVerificationPage(): ReactElement

ErrorMessage

Footer

  • Footer(): ReactElement
  • The footer for the App.

    Outline:

    • Clicking the 'Help' button takes the user to the user manual.

    • Clicking the 'Privacy Notice' button takes the user to the privacy policy.

    • Clicking the 'Source Code' button takes the user to the GitHub repository.

    internal

    Returns ReactElement

Header

  • The header of the application.

    Outline:

    • Allows the user to
      • return to the home page by clicking the logo;
      • search for communities;
      • toggle the theme for the application;
      • take actions on their profile e.g. logout.
    internal

    Parameters

    Returns ReactElement | null

HomePage

  • HomePage(): ReactElement

JoinCallMessage

  • JoinCallMessage(props: { onJoinClick: () => void }): ReactElement

Link

LoadingCard

  • LoadingCard(): ReactElement

LoginCard

  • LoginCard(): ReactElement

LoginPage

  • LoginPage(): ReactElement

LogoTemplate

MarkdownEditor

MarkdownViewer

ModerationPage

  • ModerationPage(): ReactElement

PageNotFoundPage

  • PageNotFoundPage(): ReactElement

PasswordField

PasswordResetCard

  • PasswordResetCard(): ReactElement

PasswordResetPage

  • PasswordResetPage(): ReactElement

PasswordResetRequestCard

  • PasswordResetRequestCard(): ReactElement

PasswordResetRequestPage

  • PasswordResetRequestPage(): ReactElement

PasswordStrengthMeter

Popup

Post

PostCreator

PostEditor

PostEditorBase

PostHeader

  • Used to display the user icon, title and actions that can be taken on a post or comment.

    Outline:

    • The user's icon is displayed on the left of the header

    • The title of the post is displayed in the middle of the header. Nothing is displayed for the title of comments, as they do not have one.

    • Users who have made the post or administrators of the community the post is a part of can edit or delete the post by selecting the desired option from a dropdown.

    • Users from the same host who are not the author of the post have the option to report the post from the dropdown menu.

    internal

    Parameters

    Returns ReactElement

PostPage

  • PostPage(): ReactElement

PostPreview

PrivacyNoticePage

  • PrivacyNoticePage(): ReactElement

ProfileTab

QueueTab

  • QueueTab(): ReactElement
  • Allows community administrators to approve or remove unapproved content on their communities

    Outline:

    • If approve or remove is successful, the selected posts are removed from the moderation queue.
    internal

    Returns ReactElement

RegistrationCard

  • RegistrationCard(): ReactElement
  • Allows users to register an account on the application.

    Outline:

    • Users can enter their email, a username and password to register.

    • They must check a box saying that they have read and agree to the privacy notice.

    • Upon successfully creating the account, they are redirected to their HomePage, otherwise an error message is displayed.

    internal

    Returns ReactElement

RegistrationPage

  • RegistrationPage(): ReactElement

SearchInput

  • SearchInput(): ReactElement
  • The search bar used to search for communities.

    Outline:

    • Users can type a host name into the search bar to display a dropdown of the communities on that host.

    • They can then click a community from the dropdown to be taken to the page of that community.

    internal

    Returns ReactElement

SubscribeButton

SubscribedPosts

  • SubscribedPosts(): ReactElement

UserIcon

UserInfoCard

UserProfilePage

  • UserProfilePage(): ReactElement

UserProvider

  • UserProvider(props: { children: ReactElement }): ReactElement
  • Wrapper for the application so that all components and pages can access the user information at any point.

    This helps to prevent prop drilling.

    internal

    Parameters

    • props: { children: ReactElement }
      • children: ReactElement

    Returns ReactElement

Video

VideoGrid

VideoWrapper

WelcomeCard

  • WelcomeCard(): ReactElement

Const reportWebVitals

  • reportWebVitals(onPerfEntry?: ReportHandler): void

setAccountsClient

  • setAccountsClient(client: AccountsClient): void
  • AccountsJS has some poorly designed configuration steps, which led to circular dependencies.

    This function is used to lazily set the accountsClient, reference, which is needed to add authentication tokens to each request.

    internal

    Parameters

    • client: AccountsClient

      Accounts client to be set.

    Returns void

Generated using TypeDoc