Code Monkey home page Code Monkey logo

community-app's Introduction

Dev Build Status Master Build Status Quality Gate Status Security Rating Vulnerabilities

Topcoder Community App

New version of Topcoder Community website.

Knowledgebase

Misc Development Notes

.exchange-rates.cache

Often you may note that the file named .exchange-rates.cache, located in the root folder of the app, got updated without you touching it. In such case, please, don't hesitate to keep and commit its updated version. It is a cache of real-world currency exchange rates. Keeping it up-to-date, and preserving between restarts of the app (no matter in which mode) saves a lot of calls to https://openexchangerates.com, thus allowing us to stay within the limits of their free plan.

In case of merge conflicts, just commit the version of cache file that has a more recent timestamp among its data fields.

If you need any operations related to currency conversions, pay attention to the /src/shared/services/money.js service.

Deployment and Execution

Disclaimer: Current instructions are biased towards Ubuntu 16.04. Hovewer, similar recipes should work for other OS. Should you encounter and overcome any tricky issues on other OS, you are welcome to add notes/hints into this file.

  1. You should have the following prerequisites:

    • NodeJS 8.2.1 (other recent versions should also work fine);
    • Python 2.7.
  2. Install dependencies with one of the following commands:

    • $ npm install Installs all dependencies. Recommended for local development;
    • $ npm install --production Installs only production dependencies. These include all you need to run linters & unit tests, to build & run production version of the App. Does not include additional development tools.
  3. Run linters and unit tests with following commands:

    • $ npm run lint:js Runs ESLint (AirBnB style);
    • $ npm run lint:scss Runs Stylelint (standard Stylelint style);
    • $ npm run lint Runs both ESLint and Stylelint;
    • $ npm run jest Runs unit tests;
    • $ npm run jest -- -u Runs unit test with update of component snapshots;
    • $ npm test Runs ESLint, Stylelint and unit tests.
  4. Set environment variables:

    • PORT Specifies the port to run the App at. Defaults to 3000;
    • NODE_CONFIG_ENV Specifies Topcoder backend to use. Should be either development or production. Defaults to production.

    Many app segments depend on Contentful CMS for routing information. Thus, even if the page/component you are working with does not require CMS directly, you may see CMS-related error messages. To interact with CMS you must setup the following environment variables:

    • CONTENTFUL_SPACE_ID
    • CONTENTFUL_CDN_API_KEY
    • CONTENTFUL_PREVIEW_API_KEY

    If you have access to Topcoder CMS space (or you use your own CMS space for development), you'll find them under Space settings > API keys. Otherwise, look for these credentials in the challenge forum, or reach a copilot to get them.

  5. To build the App's frontend run one of (the result of build will be output into /build folder in both cases):

    • $ npm run build To rebuild production frontend;
    • $ npm run build:dev This command should only be used to test whether development build of the front end works. You don't have to execute this command to run development version of the App (the server will automatically build frontend in memory anyway). You can't successfully execute this command without installing dev dependencies.
  6. To run the App use:

    • $ npm start To run the App in normal mode. The frontend will be served from /build folder. The Topcoder backend to use will be chosen depending on NODE_CONFIG_ENV value;
    • $ npm run dev To run the App with development tools. In this case the frontend is build in memory by server and uses dev tools like redux-devtools. The Topcoder backend to use will be chosen depending on NODE_CONFIG_ENV value. This demands dev dependencies installed at the first step.

If you run the App locally against development Topcoder backend you should access the App as local.topcoder-dev.com:3000. Prior doing this you should add into your /etc/hosts the line 127.0.0.1 local.topcoder-dev.com. To login into development Topcoder backend use accounts.topcoder-dev.com/members to login. Log out at www.topcoder-dev.com, or just wipe out auth cookies.

If you run the App locally against production Topcoder backend you should run it at the port 80 and access the App as local.topcoder.com. Prior doing this you should add into your /etc/hosts the line 127.0.0.1 local.topcoder.com. The easiest way to allow the App to listen at the port 80 on Ubuntu 16.04 is (no guarantees, how safe is it):

  • $ sudo apt install libcap2-bin;
  • $ which node to figure out your path/to/node;
  • $ sudo setcap cap_net_bind_service=+ep /path/to/node;
  • Now you can run the App. To login into production Topcoder backend use accounts.topcoder.com/members with your regular account, and to logout you can just wipe out cookies, or just log out at www.topcoder.com.

Development dependencies include StyleFMT. You can execute $ npm run lint:scss -- --fix to automatically correct you stylesheets to comply with Stylelint rules (but it can fail for some rules). To automatically correct js files, you can use npm run lint:js -- --fix.

Accessing Wipro Community

Access to Wipro community demands proper authorization. In development environment (both local and remote) the test user dan_developer / dantopcoder123 is authorized to access this community. So login at https://accounts.topcoder-dev.com/member in the same browser before you do anything.

It is intended that Wipro community is accessed as wipro.topcoder-dev.com in dev (both local and remote) and wipro.topcoder.com in prod. Thus, to deploy it locally you should have in your /etc/hosts the alias 127.0.0.1 wipro.topcoder-dev.com, and run the app with the command NODE_CONFIG_ENV=development PORT=80 npm run dev. Take into account the following:

  1. To run the App at port 80 you may need extra configuration (see in the end of the previous section);

  2. Once you have added this alias to your /etc/hosts, it is extremely easy to forget about it and to be totally confused when failing to access the remotely deployed dev version of the App (because wipro.topcoder-dev.com is used in both places). Thus we recommend to comment out this alias in /etc/hosts whenever you don't need it!!! Technically, it makes total sense just to run the local dev version of the App at, say, local.wipro.topcoder-dev.com:3000, and the code does support it... the problem is that, as of now, Topcoder's accounts-app does not allow to authenticated from such subdomain/port, thus you won't be permitted to access.

  3. As of now, this community can be also rapidly accessed at local.topcoder-dev.com/community/wipro/. It should be fine to use it during development, just keep in mind that you should use relative links to navigate inside the community, as our primary goal is to ensure it is properly funcional at wipro.topcoder-dev.com.

Configuration for logentries.com

We use https://logentries.com to track the logs. Log Entries API token should be provided via the LOG_ENTRIES_TOKEN environment variable, which will override the default values set in /config/default.json (sample account for local setup testing), and in /config/production.json (empty token) - with empty token Log Entries will not be used.

Configuration for Scoreboard API

Change the property in URL.COMMUNITY_API in config.

Configuration for Email Verify URL

Change the property in URL.EMAIL_VERIFY_URL in config.

TC pages integrated

Current Status

Note: Server-side rendering is supported. It means, if you go to /src/server/App.jsx and remove the line <_script type="application/javascript" src="/bundle.js"></script>, which loads JS bundle in the page, when you start the App and load any page, you'll still see a properly rendered page (without any interactivity). It means that loading of JS bundle and initialization of ReactJS do not block the proper rendering of the page.

Setup of this App is not finished yet. Here is a brief summary of current configuration and problems found on the way.

This App already contains:

  • A high-level draft of isomorphic App structure;
  • A dummy client App;
  • A set of general Topcoder stylesheets in /src/styles;
  • Autoprefixer;
  • Babel with latest JS support both client- and server-side;
  • ESLint (AirBnB style);
  • Express server;
  • Font loading (Roboto fonts are included into the repo);
  • Hot Module Replacement for JS code and SCSS styles in dev environment;
  • Isomorphic fetch and Topcoder API Auth;
  • Loading of .svg assets as ReactJS components with babel-plugin-inline-react-svg
  • Node-Config;
  • React;
  • React CSS Modules (via Babel plugin);
  • react-css-super-themr;
  • React Router;
  • Redux with Flux Standard Actions, redux-promise middleware, support of server-side rendering, and DevTools for dev environment;
  • SCSS support;
  • CSS support for third party modules;
  • StyleFMT;
  • Stylelint for scss (standard Stylelint style);
  • Unit testing with Jest;
  • Various examples;
  • Webpack;

Pending low-priority stuff (these are important, but can be added along the way):

CI / CD

Deploy scripts are setup to use AWS ECS + CircleCI. Make sure the following environment variables are setup in CircleCI:

  • AWS_ECS_SERVICE
  • AWS_REPOSITORY
  • DEV_AWS_ACCESS_KEY_ID
  • DEV_AWS_ACCOUNT_ID
  • DEV_AWS_ECS_CLUSTER
  • DEV_AWS_REGION
  • DEV_AWS_SECRET_ACCESS_KEY
  • DEV_SERVER_API_KEY
  • DEV_AUTH0_CLIENT_ID
  • PROD_AWS_ACCESS_KEY_ID
  • PROD_AWS_ACCOUNT_ID
  • PROD_AWS_ECS_CLUSTER
  • PROD_AWS_REGION
  • PROD_AWS_SECRET_ACCESS_KEY
  • PROD_SERVER_API_KEY
  • PROD_AUTH0_CLIENT_ID

Folowing environment variables should be set to configure M2M communication between Community App server and TC APIs. At the moment of writing, it is expected that these credentials give full access to the TC Groups API. XXX is a placeholder for one of DEV, PROD, PRODBETA - API environment given credentials relate to.

  • XXX_TC_M2M_CLIENT_ID
  • XXX_TC_M2M_CLIENT_SECRET
  • XXX_TC_M2M_AUDIENCE
  • XXX_TC_M2M_GRANT_TYPE

Changelog

[https://github.com/topcoder-platform/community-app/blob/master/CHANGELOG.md](Check the latest changes)

Submitting Changes

Please check the https://github.com/topcoder-platform/community-app/blob/master/CONTRIBUTING.md for guidelines on rules to be followed.

community-app's People

Contributors

a-lowe avatar ajefts avatar arku avatar birdofpreyru avatar codejamtc avatar codeminter avatar dedywahyudi avatar drasticdpk avatar gauravseta avatar gets0ul avatar gunasekar-k avatar igoroshko avatar iversonlv avatar jmgasper avatar kkartunov avatar lieutenantroger avatar luizrrodrigues avatar mtwomey avatar narekcat avatar nursoltan-s avatar prakashdurlabhji avatar rakibansary avatar rashmi73 avatar sathyajayabal avatar shubhendusaurabh avatar srjr19 avatar sumitdaga avatar suppermancool avatar sushilshinde avatar thomaskranitsas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

community-app's Issues

Create 2 new communities

I'd like to add 2 new communities as follows:

  1. Topcoder Product Development
  • This will be a community similar to Wipro. It should be restricted to a group. It can have the same pages as well.
  1. Demo Expert Community
  • This should be open to the public - no login required
  • Challenges will use a tech tag for filtering, as well as a group ID. For example, we might want to show challenges in group 1001 plus any challenge with tech=reactJS.

Log out issue

Now when Log Out is triggered via top nav menu (at the moment, we have two top nav menus in this repo: one for the main web-site, another for the TC Community mini-sites), it just redirects user to https://www.topcoder-dev.com/logout. This redirection does log out the user from Topcoder accounts-app, but it does not wipe out auth cookies associated with the community-app subdomain. It is not that obvious, because when the App is restarted it communicates with accounts-app, and cleans the cookies if the user is not authenticated, but there is a short moment before this communication, when the user may see something he is not supposed to see.

In other words, the best way to see this issue:

  1. Login as a valid user and go to Wipro community page.
  2. Log out through the top nav menu.
  3. Press back in the browser until you return to the Wipro community page: you will see the Wipro community page will be visible for a brief time, and only a moment later it will change to the You must be authenticated to access this page message.

Regroupping of code related to challenge listings

Now inside /src/shared/components/ there is a bunch of components related to challenge listings, all in their own folders. We should move them to a dedicated sub-directory, e.g. /src/shared/components/challenge-listing just to enhance navigation around the source code.

CSS loading issue in Dev

As of the moment CSS loading in development environment has some problems, as it loads pre-build css file, and then loads updates from HMR as a part of JS bundle. This is not a correct setup, and should be updated.

Font loading issue in Dev

Loading fonts as separate files in dev leads to problems with HMR. I've changed it to load fonts as data urls within JS bundle. This solves the problem with HMR, but delays proper rendering of page in dev environment. Should be further investigated and fixed.

Integrate stats with real data

These should be populated with real data from the api. I think we might want to make this configurable too. Let's chat about the api calls to determine each stat...

Challenges = Same as the All Challenges count on the /challenges page
Members = total # of people in the configured group
Prizes = sum of prizes for open challenges
Projects = we might drop this

image

[$100] - Add groups filter to challenge listing page

On the challenges page, add a filter to allow the user to switch between the challenges that are in the current community (based on the group) or All challenges. All challenges would be everything that is open (public) plus any challenges the user has access to via their groups.

We have some designs for this from challenges that chekspir ran. We should use those designs.

fix:styles brakes lint:scss

When performing npm run fix:styles it brakes linting for some files.

Let's say we checkout commit f3d273d22e09b6a34f0a090cc5be377ac3dd6b79.

How to reproduce

  1. Run npm run lint:scss. There are no errors

  2. Run npm run fix:styles. It says that 10 files are formatted.

  3. Run npm run lint:scss again. Now we get error declaration-empty-line-before in two files src/styles/_forms.scss and src/styles/mixins/_typography.scss.

In total

  • fix:styles can create declaration-empty-line-before error
  • fix:styles formats some files which lint:scss doesn't treat as broken

Wipro Community - Issues noted by reviewers

  1. ./src/shared/containers/tc-communities/Header/index.jsx still contains references to 'tcCommunities.header'
    From the challenge details page, this should be changed to 'tcCommunities.meta'
    Should be properly updated in the following files as well :
    -- ./src/shared/reducers/leaderboard.js
    -- ./src/shared/reducers/tc-communities/header.js

  2. ChallengeListing : " For this challenge we want to update it to get filter so that tag comes from from the community meta data endpoint (see header section, and the mock API there)"
    This is not implemented, the tag to be used for filtering ('Javascript' for demo purpose) should be configured (i.e in future returned by the API) in /src/server/tc-communities/wipro/metadata.json

Footer in TC communities

At the moment we re-use the standard Topcoder footer there, and it gets some problems with nav link colors:
scr-18

HMR fails for SCSS modules with @include statements

Hot Module Replacement (HMR) fails for SCSS modules containing @include statements. E.g. at the fonts test page (/examples/fonts-test endpoint) when you try to edit corresponding style.scss file while the App is running in dev mode with that page open, you'll see that most of the text will just dissapear. HMR seems to work fine in other cases, though.

Minor problems with the leaderboard component

loading-indicator component is not used correctly, it should be used in the LeaderboardPageContainer when loading the data.
it should not be used in Podium component.

Besides, if there is only 1 or 2 users on leaderboard, the Podium component won't render it properly as it accesses comps[1] and comps[2] directly.

Submission Management UI adjustments

Some feedback from DaraK...

  1. There should be a little more space between the action buttons to limit the user from accidentally clicking the wrong action.

  2. The preview image was a little too small, not sure we can see the difference on 2 different preview versions of design

01 design - manage submissions

Login and Register URL is hard coded

It looks like the login and register links in the header for communities is hard coded to wipro.topcoder.com. Can we make those always return to the page the user is on?

SMP - Delete submission

Does not work because, according to the winning submission:

  • there's no endpoint for deleting a specific submission (/challenges/{id}/resources in v3 doesn't work either)

SMP - Submission download does not work

A comment to winning submission tells

there's an endpoint in v2 (/v2/{type}/download/{submId}?submissionType=original) that states it lets you download a specific submission, doesn't seem to work

Probably it works, but submitter made some auth-related mistake?

TC header and footer

Topcoder header and footer should be copied into this repo, to be used in TC pages served from here.

CI / CD deploy broken

@birdofpreyru i dug around to figure out why deploys are failing, and builds are essentially timing out. Are there any dependencies that we dont currently need - react-draft-wysiwyg for eg. Mind removing those and giving it a try.

SMP - Challenge preview and screening/review status

Current version of SMP shows dummy submission previews and no screening / review status info.
The core problem is that TC API v3 does not allow to fetch challenges yet (or have we failed to find the right endpoints?) and TC API v2 does not provide previews and screening / review info.

Create a Skeleton app for Isomorphic React app

Must haves

Good To have

Sample boilerplate:
https://github.com/nicksp/redux-webpack-es6-boilerplate

Structure that supports isomorphic app - (https://reactjsnews.com/isomorphic-react-in-real-life)

  • Structure

node_modules /
config /
src /
  assets / --- images
  / api -- capture api calls to topcoder.com
  / shared / 
    / containers
      |--project-listing/
        |--actions/
        |--components/
          |--card/
            |--card.jsx
            |--card.js
            |--card.scss
          |--grid_header/
          |--grid_footer/
        |--reducers/
      |--projectListing.jsx
      |--projectListing.js
      |--projectListing.scss
    / components
        ..... 
    / reducers
    / actions
  / client
  / server

Error when run "npm run dev"

I just clone this repository and didn't modify any thing, when I run "npm run dev" in terminal, it shows errors. Here is the log.

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
/Users/luoxiongwen/Code/topcoder/community-app/node_modules/[email protected]@tc-accounts/exports.js:1
(function (exports, require, module, __filename, __dirname) { export { configureConnector, getFreshToken, logout } from './connector/connector-wrapper.js'
                                                               ^^^^^^
SyntaxError: Unexpected token export
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:545:28)
    at Module._extensions..js (module.js:582:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/luoxiongwen/Code/topcoder/community-app/node_modules/[email protected]@babel-register/lib/node.js:152:7)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/luoxiongwen/Code/topcoder/community-app/src/shared/actions/auth.js:8:1)

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: `NODE_ENV=development node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script 'NODE_ENV=development node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the community-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=development node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs community-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls community-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/luoxiongwen/Code/topcoder/community-app/npm-debug.log```

Community dropdown links

Let's make these real links that go to the specific community sites:

image

We should probably have some kind of config for it.

SMP - Phase end counter

scr-14
Once the challenge is finished, the counter of time till the end of the phase shows negative number.
Also in other spot we still show when submission ends, though it is not useful once the phase is finished.
In general, we should double-check and fix all logic in the page, related phase periods, etc.

Unit test coverage

After the last challenge there are some failing tests, also the global test coverage should be increased.

From that submission comments

SubmissionManagement component will fail the snapshot test since we need to dinamically show the user the time left till the current phase ends.

The time for that component comes from a call to Topcoder API. That call should be mocked with standard Jest methods, and then snapshot test will be feasible.

Server-side rendering of the leaderboard

It looks from the code that winner has supported server-side rendering of the page, but it does not work correctly, according to the warning in the browser console:

bundle.js:26959 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) .w3.org/1999/xlink" class="src-shared-co
 (server) .w3.org/1999/xlink" data-reactid="27"><t

Probably it is related to how the mocked data are handled, and will be automatically resolved, once we move to real API for fetching leaderboard data.

CSS dublication in dev.

  • in many scss file of components we import main style like @import '~styles/tc-styles' This import is being processed by scss which include imported files every time we import it and not only once like webpack.

Most probably, this is not a problem in prod, as styles are optimized by CSS optimization/uglification plugin, which is not used in dev, though. Should be double-checked and enhanced.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.