From ced260599f340c8c0017fa2da95f80607b07fc63 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Wed, 15 Mar 2023 18:19:53 +0600 Subject: [PATCH 01/17] feat: change primary user role * speed up intellisense by excluding node_modules * make sure app is rendered only on client side to avoid window not defined error Signed-off-by: Rakib Ansary --- jsconfig.json | 3 +- package-lock.json | 70 +++-- src/shared/actions/identity.js | 27 ++ src/shared/app.jsx | 8 +- .../MyPrimaryRole/FormInputRadio/index.jsx | 43 +++ .../MyPrimaryRole/FormInputRadio/styles.scss | 93 +++++++ .../Settings/Account/MyPrimaryRole/index.jsx | 102 +++++++ .../Account/MyPrimaryRole/styles.scss | 252 ++++++++++++++++++ .../components/Settings/Account/index.jsx | 2 + src/shared/containers/Settings.jsx | 5 + src/shared/reducers/identity.js | 53 ++++ src/shared/reducers/index.js | 2 + src/shared/services/identity.js | 64 +++++ 13 files changed, 703 insertions(+), 21 deletions(-) create mode 100644 src/shared/actions/identity.js create mode 100644 src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/index.jsx create mode 100644 src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss create mode 100644 src/shared/components/Settings/Account/MyPrimaryRole/index.jsx create mode 100644 src/shared/components/Settings/Account/MyPrimaryRole/styles.scss create mode 100644 src/shared/reducers/identity.js create mode 100644 src/shared/services/identity.js diff --git a/jsconfig.json b/jsconfig.json index a2efdbf5d4..03b7395706 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -4,5 +4,6 @@ "paths": { "*": ["src/shared/*", "src/*", "node_modules/*"] } - } + }, + "exclude": ["node_modules", "build"] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5d5f2e2602..d613edef86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7440,6 +7440,15 @@ "defined": "1.0.1" } }, + "dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "requires": { + "asap": "2.0.6", + "wrappy": "1.0.2" + } + }, "dicer": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", @@ -11632,6 +11641,11 @@ "dasherize": "2.0.0" } }, + "hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==" + }, "hide-powered-by": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.1.0.tgz", @@ -25746,9 +25760,9 @@ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, "topcoder-react-lib": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/topcoder-react-lib/-/topcoder-react-lib-1.2.10.tgz", - "integrity": "sha512-Z8XICIvYbrciM+8vOJCRGiqEX4EzJ50pNApJnJyGfutjplmB1ns0m7/DezJJuB2mrb3A5hNki9KGV2EM+W7lOQ==", + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/topcoder-react-lib/-/topcoder-react-lib-1.2.11.tgz", + "integrity": "sha512-0xa8Ik3z75fDrcFD5as3HOcM3CfCb+HMwaURneRWXpEKGh1Ss810WqBmuFCW8WiRTf92ATa+0xv+rwMB7J22bQ==", "requires": { "@topcoder-platform/tc-auth-lib": "git+https://github.com/topcoder-platform/tc-auth-lib.git#68fdc22464810c51b703a33e529cdbd6d09437de", "auth0-js": "6.8.4", @@ -25844,6 +25858,27 @@ } } }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.8", + "mime-types": "2.1.35" + } + }, + "formidable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.1.tgz", + "integrity": "sha512-0EcS9wCFEzLvfiks7omJ+SiYJAiD+TzK4Pcw1UlUoGnhUxDcMKjt0P7x8wEb0u6OHu8Nb98WG3nxtlF5C7bvUQ==", + "requires": { + "dezalgo": "1.0.4", + "hexoid": "1.0.0", + "once": "1.4.0", + "qs": "6.11.0" + } + }, "json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -25878,9 +25913,9 @@ } }, "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "requires": { "inherits": "2.0.4", "string_decoder": "1.1.1", @@ -25901,27 +25936,27 @@ "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==" }, "superagent": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.3.1.tgz", - "integrity": "sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-7.1.6.tgz", + "integrity": "sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==", "requires": { "component-emitter": "1.3.0", "cookiejar": "2.1.4", "debug": "4.3.4", "fast-safe-stringify": "2.1.1", - "form-data": "3.0.1", - "formidable": "1.2.6", + "form-data": "4.0.0", + "formidable": "2.1.1", "methods": "1.1.2", "mime": "2.6.0", "qs": "6.11.0", - "readable-stream": "3.6.0", + "readable-stream": "3.6.2", "semver": "7.3.8" } }, "tc-core-library-js": { "version": "github:appirio-tech/tc-core-library-js#d16413db30b1eed21c0cf426e185bedb2329ddab", "requires": { - "auth0-js": "9.20.1", + "auth0-js": "9.20.2", "axios": "0.12.0", "bunyan": "1.8.15", "jsonwebtoken": "8.5.1", @@ -25933,15 +25968,16 @@ }, "dependencies": { "auth0-js": { - "version": "9.20.1", - "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-9.20.1.tgz", - "integrity": "sha512-m7k3O0Qs3Emr7cC2OPbbOp1duzgMzuTeESHgWK+FimGV6FjBX53dYtNIgQ49J7mkACeKje/Jlto9/6CO9YQhcQ==", + "version": "9.20.2", + "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-9.20.2.tgz", + "integrity": "sha512-a6tFTYYK2+DQA3+A/mTKAWt/XOaMeiGWu644SnyAL5P84K79G53QOwtn/ok3DbM9MRfRp+2jYE6U4czTLJnj/g==", "requires": { "base64-js": "1.5.1", "idtoken-verifier": "2.2.3", "js-cookie": "2.2.1", + "minimist": "1.2.8", "qs": "6.11.0", - "superagent": "5.3.1", + "superagent": "7.1.6", "url-join": "4.0.1", "winchan": "0.2.2" } diff --git a/src/shared/actions/identity.js b/src/shared/actions/identity.js new file mode 100644 index 0000000000..3f701985b9 --- /dev/null +++ b/src/shared/actions/identity.js @@ -0,0 +1,27 @@ +import { createActions } from 'redux-actions'; +import { getService } from '../services/identity'; + +/** + * @static + * @desc Creates an action that signals beginning of updating users primary role. + * @return {Action} + */ +function updatePrimaryRoleInit() {} + +/** + * @static + * @desc Update users primary role + * @param {String} role - role to be updated can be 'Topcoder Talent' or 'Topcoder Customer' + * @return {Action} + */ +async function updatePrimaryRoleDone(role, tokenV3) { + return getService(tokenV3).updatePrimaryRole(role); +} + + +export default createActions({ + IDENTITY: { + UPDATE_PRIMARY_ROLE_INIT: updatePrimaryRoleInit, + UPDATE_PRIMARY_ROLE_DONE: updatePrimaryRoleDone, + }, +}); diff --git a/src/shared/app.jsx b/src/shared/app.jsx index 9f98dad665..a455b0f82f 100644 --- a/src/shared/app.jsx +++ b/src/shared/app.jsx @@ -33,6 +33,10 @@ if (process.env.NODE_ENV === 'production') { /* eslint-enable global-require */ export default function App() { + if (!isomorphy.isClientSide()) { + return null; + } + return (
@@ -54,9 +58,7 @@ export default function App() { /> {isomorphy.isDevBuild() ? : undefined} { - config.GAMIFICATION.ENABLE_SKILLS_REMIND_MODAL - && isomorphy.isClientSide() - ? : undefined + config.GAMIFICATION.ENABLE_SKILLS_REMIND_MODAL ? : undefined }
); diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/index.jsx b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/index.jsx new file mode 100644 index 0000000000..cb594d043f --- /dev/null +++ b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/index.jsx @@ -0,0 +1,43 @@ +import React from 'react'; +import PT from 'prop-types'; + +import './styles.scss'; + +const FormInputRadio = ({ + text, value, selectedValue, onSelectionChange, +}) => { + const handleChange = () => { + onSelectionChange(value); + }; + + const inputId = `roundedInputFieldRadioGroup-${value}`; + return ( +
+
+ {text} +
+ +
+ ); +}; + + +FormInputRadio.propTypes = { + text: PT.string.isRequired, + value: PT.string.isRequired, + selectedValue: PT.string.isRequired, + onSelectionChange: PT.func.isRequired, +}; + +export default FormInputRadio; diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss new file mode 100644 index 0000000000..ca01017729 --- /dev/null +++ b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss @@ -0,0 +1,93 @@ +@import "~styles/mixins"; + +.rounded-input-field { + box-sizing: border-box; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + padding-left: 16px; + width: calc(50% - 32px); // Subtract half the gap size from each button width + height: 72px; + background: #ffffff; + border: 1px solid #d4d4d4; + border-radius: 8px; + margin-right: 32px; // Add the other half of the gap size as margin + &:last-child { + margin-right: 0; // Remove margin from the last button + } +} + + +.input-option { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + width: 100%; +} + +.input-text-wrapper { + display: flex; + align-items: center; +} + +.input-text { + @include roboto-medium; + + font-size: 16px; + line-height: 20px; + letter-spacing: 0.5px; + text-transform: capitalize; + color: $tco-black; + flex-grow: 0; +} + +.input-radio-wrapper { + position: relative; + display: flex; + align-items: center; + flex: none; + order: 0; + align-self: stretch; + flex-grow: 0; +} + +.input-radio { + position: absolute; + opacity: 0; + width: 20px; + height: 20px; + cursor: pointer; + z-index: 1; +} + +.custom-radio { + position: absolute; + right: 16px; + top: 55%; + transform: translateY(-50%); + width: 20px; + height: 20px; + background-color: white; + border: 2px solid #aaa; + border-radius: 50%; + cursor: pointer; +} + +.input-radio:checked ~ .custom-radio { + border-color: #137D60; +} + +.input-radio:checked ~ .custom-radio::after { + content: ""; + position: absolute; + width: 10px; + height: 10px; + background-color: #137D60; + border-radius: 50%; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); +} + diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/index.jsx b/src/shared/components/Settings/Account/MyPrimaryRole/index.jsx new file mode 100644 index 0000000000..efdb4ff540 --- /dev/null +++ b/src/shared/components/Settings/Account/MyPrimaryRole/index.jsx @@ -0,0 +1,102 @@ +import React, { useState, useEffect } from 'react'; +import { withRouter } from 'react-router-dom'; +import { SettingBannerV2 as Collapse } from 'components/Settings/SettingsBanner'; +import { Modal } from 'topcoder-react-ui-kit'; +import PT from 'prop-types'; +import FormInputRadio from './FormInputRadio'; + +import style from './styles.scss'; + +const MyPrimaryRole = ({ + user, tokenV3, updatePrimaryRole, history, +}) => { + const [primaryRole, setPrimaryRole] = useState(''); + const [showModal, setShowModal] = useState(false); + + useEffect(() => { + if (user.roles.indexOf('Topcoder Talent') !== -1) { + setPrimaryRole('Topcoder Talent'); + } else { + setPrimaryRole('Topcoder Customer'); + } + }, [user.roles]); + + const handleRoleChange = (value) => { + setPrimaryRole(value); + updatePrimaryRole(value, tokenV3); + setShowModal(true); + }; + + const handleSignoutClick = () => { + history.push('/logout'); + }; + + return ( + + {showModal && ( + +
+ +
+
+ CONFIRMED +
+
+ +
+ + You have successfully changed your account role. Please sign out of your account + and login to complete this update. + +
+ +
+ +
+ +
+
+ )} +
+ +

Account Role

+
+
+ Access to Topcoder tools and applications are based on your account + role. If you change this setting, you will be required to sign out + of your account and login. +
+
+
+ + + +
+
+
+
+
+ ); +}; + +MyPrimaryRole.propTypes = { + user: PT.shape().isRequired, + tokenV3: PT.string.isRequired, + updatePrimaryRole: PT.func.isRequired, + history: PT.shape().isRequired, +}; + + +export default withRouter(MyPrimaryRole); diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss b/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss new file mode 100644 index 0000000000..36d18f9f62 --- /dev/null +++ b/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss @@ -0,0 +1,252 @@ +@import "../../style"; +@import "~styles/mixins"; + +.hide { + display: none; +} + +.form-container-default { + display: flex; + flex-direction: column; + + .form-default { + display: block; + + @include upto-sm { + display: none; + } + } + + .form-mobile { + display: none; + + @include upto-sm { + display: block; + + .row { + display: flex; + flex-direction: column; + } + } + } + + + input { + @include roboto-regular; + + height: 40px; + font-size: 15px; + line-height: 20px; + font-weight: 400; + color: $tc-black; + border: 1px solid $tc-gray-20; + border-radius: $corner-radius * 2 $corner-radius * 2 $corner-radius * 2 $corner-radius * 2; + margin-bottom: 0; + } + + .form-field { + background: white; + color: black; + + &:disabled { + color: #b7b7b7; + } + + &.grey { + background-color: #fcfcfc; + color: #151516; + } + } +} + +.form-container { + padding: $pad-xxxxl; + background-color: $color-tc-white; + border-radius: 4px; + margin: $margin-sm 0 $margin-xxxxl 0; + + .account-form { + display: flex; + justify-content: space-between; + width: 100%; + } + +} + +.form-title { + @include barlow-semi-bold; + + font-size: 20px; + line-height: 22px; + color: inherit; + text-transform: uppercase; + padding-bottom: $pad-xxxxl; +} + +.form-content { + display: flex; + flex-wrap: wrap; + align-items: flex-start; +} + +.form-label { + flex: 0 0 calc(50% - 13px); + padding-right: 230px; + + @include roboto-regular; + + font-size: 16px; + line-height: 26px; + color: inherit; +} + +.form-body { + flex: 0 0 calc(50% + 13px); +} + +@include xs-to-md { + .form-container { + padding: $pad-xxl $pad-lg; + } + + .form-title { + @include barlow-semi-bold; + + font-size: 20px; + line-height: 22px; + padding-bottom: $pad-xxl; + } + + .form-label { + flex: 1 1 100%; + padding: 0; + margin-bottom: $margin-xxl; + font-size: 14px; + line-height: 20px; + } + + .form-body { + flex: 1 1 100%; + } + + .form-footer { + margin: 0; + } +} + + +.nagModal { + display: flex; + flex-direction: column; + margin: 32px; + + @include xs-to-md { + flex-direction: column; + margin-top: 24px; + } + + .header { + display: flex; + align-items: flex-start; + justify-content: space-between; + border-bottom: 2px solid #e9e9e9; + + @include xs-to-md { + margin-top: 24px; + text-align: center; + } + + .title { + @include barlow-bold; + + color: $tco-black; + font-size: 22px; + font-weight: 600; + line-height: 26px; + margin-bottom: 12px; + text-transform: uppercase; + + @include xs-to-md { + text-align: center; + } + } + + .icon { + cursor: pointer; + } + } + + .description { + @include roboto-regular; + + font-weight: 400; + color: $tco-black; + font-size: 16px; + line-height: 24px; + margin-top: 24px; + + strong { + font-weight: 700; + } + + .badgeWrap { + display: flex; + justify-content: center; + margin-bottom: 12px; + } + + span span { + color: #137d60; + font-weight: bold; + } + } +} + +.container { + box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); + border-radius: 8px; + min-width: 600px; + + @include xs-to-sm { + width: 90%; + min-width: unset; + } +} + +.overlay { + background-color: #0c0c0c; + opacity: 0.85; +} + +.actionButtons { + display: flex; + align-items: center; + justify-content: flex-end; + margin-top: 32px; + padding-top: 24px; + border-top: 2px solid #e9e9e9; + + .primaryBtn { + background-color: #137d60; + border-radius: 24px; + color: #fff; + font-size: 13px; + font-weight: bolder; + text-decoration: none; + text-transform: uppercase; + line-height: 32px; + padding: 0 20px; + border: none; + outline: none; + display: flex; + + &:hover { + box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.2); + background-color: #0ab88a; + } + + @include xs-to-sm { + margin-bottom: 20px; + } + } +} diff --git a/src/shared/components/Settings/Account/index.jsx b/src/shared/components/Settings/Account/index.jsx index 01cefef021..ff6370da5a 100644 --- a/src/shared/components/Settings/Account/index.jsx +++ b/src/shared/components/Settings/Account/index.jsx @@ -3,6 +3,7 @@ import React from 'react'; import PT from 'prop-types'; import { PrimaryButton } from 'topcoder-react-ui-kit'; import MyAccount from './MyAccount'; +import MyPrimaryRole from './MyPrimaryRole'; import Security from './Security'; import ErrorWrapper from '../ErrorWrapper'; @@ -75,6 +76,7 @@ export default class Account extends React.Component {

Account information & Security

+ { + dispatch(identityActions.identity.updatePrimaryRoleInit()); + dispatch(identityActions.identity.updatePrimaryRoleDone(role, tokenV3)); + }, }; } diff --git a/src/shared/reducers/identity.js b/src/shared/reducers/identity.js new file mode 100644 index 0000000000..d1c34c860c --- /dev/null +++ b/src/shared/reducers/identity.js @@ -0,0 +1,53 @@ +/** + * Reducer for identity service + */ + +import actions from 'actions/mfa'; +import { handleActions } from 'redux-actions'; +import { errors } from 'topcoder-react-lib'; +import _ from 'lodash'; + +/** + * Handles IDENTITY_SERVICE/UPDATE_PRIMARY_ROLE_DONE action. + * @param {Object} state + * @param {Object} action Payload will be JSON from api call + * @return {Object} New state + */ +function onUpdatePrimaryRoleDone(state, { payload, error }) { + if (error) { + errors.fireErrorMessage('Failed to update users primary role', payload.message); + return { ...state, updatingPrimaryRole: false }; + } + + return ({ + ...state, + updatingPrimaryRole: false, + }); +} + +/** + * Creates a new mfa reducer with the specified initial state. + * @param {Object} initialState Optional. Initial state. + * @return {Function} mfa reducer. + */ +function create(initialState) { + const a = actions.usermfa; + return handleActions({ + [a.updatePrimaryRoleInit]: state => ({ ...state, updatingPrimaryRole: true }), + [a.updatePrimaryRoleDone]: onUpdatePrimaryRoleDone, + }, _.defaults(initialState, { + updatingPrimaryRole: false, + })); +} + +/** + * Factory which creates a new reducer. + * @return {Promise} + * @resolves {Function(state, action): state} New reducer. + */ +export function factory() { + return Promise.resolve(create()); +} + +/* Default reducer with empty initial state. */ +export default create(); diff --git a/src/shared/reducers/index.js b/src/shared/reducers/index.js index c27bf01ad8..5c0b88db5a 100644 --- a/src/shared/reducers/index.js +++ b/src/shared/reducers/index.js @@ -47,6 +47,7 @@ import growSurf from './growSurf'; import thrive from './contentful/thrive'; import dashboard from './dashboard'; import blog from './blog'; +import identity from './identity'; /** * Given HTTP request, generates options for SSR by topcoder-react-lib's reducer @@ -186,6 +187,7 @@ export function factory(req) { dashboard, blog, timelineWall, + identity, })); } diff --git a/src/shared/services/identity.js b/src/shared/services/identity.js new file mode 100644 index 0000000000..54031098a8 --- /dev/null +++ b/src/shared/services/identity.js @@ -0,0 +1,64 @@ + +import { services } from 'topcoder-react-lib'; + +const { getApi } = services.api; + +/** + * Handles the response from identity service + * @param {Object} res response + * @return {Promise} Resolves to the payload. + */ +async function handleResponse(res) { + const { result } = await res.json(); + + if (!res.ok) { + throw new Error(result ? result.content : ''); + } + + if (!result) { + return null; + } + + if ((!result.success)) { + throw new Error(result.content); + } + return result.content; +} + +class IdentityService { + /** + * @param {String} tokenV3 Auth token for Topcoder API v3. + */ + constructor(tokenV3) { + this.private = { + api: getApi('V3', tokenV3), + tokenV3, + }; + } + + /** + * Update users primary role + * @param {String} role - role to be updated can be 'Topcoder Talent' or 'Topcoder Customer' + * @return {Promise} + */ + async updatePrimaryRole(role) { + const res = await this.private.api.postJson('/users/updatePrimaryRole', { param: { primaryRole: role } }); + return handleResponse(res); + } +} + +let lastInstance = null; +/** + * Returns a new or existing lookup service. + * @param {String} tokenV3 Optional. Auth token for Topcoder API v3. + * @return {IdentityService} Mfa service object + */ +export function getService(tokenV3) { + if (!lastInstance || tokenV3 !== lastInstance.private.tokenV3) { + lastInstance = new IdentityService(tokenV3); + } + return lastInstance; +} + +/* Using default export would be confusing in this case. */ +export default undefined; From eff7c592c321410bd07bbac421eee293890d7307 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Wed, 15 Mar 2023 18:20:30 +0600 Subject: [PATCH 02/17] ci: deploy to dev --- .circleci/config.yml | 691 +++++++++++++++++++++---------------------- 1 file changed, 341 insertions(+), 350 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 52c5ec8476..ecfb5bc7b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,314 +1,305 @@ version: 2.1 parameters: - run_basedeployment: - default: true - type: boolean - run_smoketesting: - default: false - type: boolean - run_performancetesting: - default: false - type: boolean + run_basedeployment: + default: true + type: boolean + run_smoketesting: + default: false + type: boolean + run_performancetesting: + default: false + type: boolean defaults: &defaults - docker: - - image: docker:20.10.21-git - environment: - ENV: $BASH_ENV + docker: + - image: docker:20.10.21-git + environment: + ENV: $BASH_ENV install_dependency: &install_dependency - name: Installation of build and deployment dependencies. - command: | - apk update - apk add --no-cache bash openssl curl - apk upgrade - apk add --no-cache jq py-pip sudo - sudo pip install awscli --upgrade + name: Installation of build and deployment dependencies. + command: | + apk update + apk add --no-cache bash openssl curl + apk upgrade + apk add --no-cache jq py-pip sudo + sudo pip install awscli --upgrade install_deploysuite: &install_deploysuite - name: Installation of install_deploysuite. - command: | - git clone --branch v1.4.14 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript - cp ./../buildscript/master_deploy.sh . - cp ./../buildscript/buildenv.sh . - cp ./../buildscript/awsconfiguration.sh . + name: Installation of install_deploysuite. + command: | + git clone --branch v1.4.14 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + cp ./../buildscript/master_deploy.sh . + cp ./../buildscript/buildenv.sh . + cp ./../buildscript/awsconfiguration.sh . restore_cache_settings_for_build: &restore_cache_settings_for_build key: docker-node-modules-v3-{{ checksum "package-lock.json" }} save_cache_settings: &save_cache_settings key: docker-node-modules-v3-{{ checksum "package-lock.json" }} paths: - - node_modules + - node_modules build_docker_image: &build_docker_image - name: Build of Docker image - command: | - source buildenvvar - ./build.sh - no_output_timeout: 20m + name: Build of Docker image + command: | + source buildenvvar + ./build.sh + no_output_timeout: 20m jobs: # Build & Deploy against development backend "build-dev": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - # Build of Docker image. - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + # Build of Docker image. + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp # Build & Deploy against testing backend "build-test": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b test_communityapp_buildvar,test_communityapp_deployvar -l dev_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b test_communityapp_buildvar,test_communityapp_deployvar -l dev_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp # Build & Deploy against testing backend "build-qa": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar -l dev_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar -l dev_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp # Build & Deploy against prod api backend "build-prod-beta": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b beta_communityapp_buildvar,beta_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e PROD -t latest -s beta_communityapp_taskvar, -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b beta_communityapp_buildvar,beta_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e PROD -t latest -s beta_communityapp_taskvar, -i communityapp # Build & Deploy against prod api backend "build-prod-staging": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e PROD -t latest -s staging_communityapp_taskvar, -i communityapp - curl --request POST \ - --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ - --header "Circle-Token: ${CIRCLE_TOKEN}" \ - --header 'content-type: application/json' \ - --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' - + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: "source awsenvconf\nsource buildenvvar\n./master_deploy.sh -d ECS -e PROD -t latest -s staging_communityapp_taskvar, -i communityapp \ncurl --request POST \\\n--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \\\n--header \"Circle-Token: ${CIRCLE_TOKEN}\" \\\n--header 'content-type: application/json' \\\n--data '{\"branch\":\"'\"$CIRCLE_BRANCH\"'\",\"parameters\":{\"run_smoketesting\":true , \"run_performancetesting\":false, \"run_basedeployment\": false}}'\n#magic___^_^___line\n" # Build & Deploy against production backend "build-prod": - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e PROD -t latest -s prod_communityapp_taskvar -i communityapp - curl --request POST \ - --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ - --header "Circle-Token: ${CIRCLE_TOKEN}" \ - --header 'content-type: application/json' \ - --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e PROD -t latest -s prod_communityapp_taskvar -i communityapp + curl --request POST \ + --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ + --header "Circle-Token: ${CIRCLE_TOKEN}" \ + --header 'content-type: application/json' \ + --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' # Automated Smoke Testing against Staging Smoke-Testing-On-Staging: - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar - - run: - name: "Run automation" - no_output_timeout: 20m - command: | - source awsenvconf - source buildenvvar - ./automated-smoke-test/smoketest.sh automation-config-staging.json prod - - store_artifacts: - path: ./automated-smoke-test/test-results + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar + - run: + name: "Run automation" + no_output_timeout: 20m + command: | + source awsenvconf + source buildenvvar + ./automated-smoke-test/smoketest.sh automation-config-staging.json prod + - store_artifacts: + path: ./automated-smoke-test/test-results - # Automated Smoke Testing against Production + # Automated Smoke Testing against Production Smoke-Testing-On-Production: - <<: *defaults + !!merge <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar - - run: - name: "Run automation" - no_output_timeout: 20m - command: | - source awsenvconf - source buildenvvar - ./automated-smoke-test/smoketest.sh automation-config-prod.json prod - - store_artifacts: - path: ./automated-smoke-test/test-results + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar + - run: + name: "Run automation" + no_output_timeout: 20m + command: | + source awsenvconf + source buildenvvar + ./automated-smoke-test/smoketest.sh automation-config-prod.json prod + - store_artifacts: + path: ./automated-smoke-test/test-results # Test job for the cases when we do not need deployment. It just rapidly # installs (updates) app dependencies, and runs tests (ESLint, Stylelint, # Jest unit-tests). test: docker: - - image: circleci/node:8.11.1 + - image: circleci/node:8.11.1 steps: - - checkout - - restore_cache: - key: test-node-modules-{{ checksum "package-lock.json" }} - - run: - name: Config Git - command: git config --global url."https://git@".insteadOf git:// - - run: - name: App npm install - command: npm install - no_output_timeout: 20m - - save_cache: - key: test-node-modules-{{ checksum "package-lock.json" }} - paths: - - node_modules - - run: npm test + - checkout + - restore_cache: + key: test-node-modules-{{ checksum "package-lock.json" }} + - run: + name: Config Git + command: git config --global url."https://git@".insteadOf git:// + - run: + name: App npm install + command: npm install + no_output_timeout: 20m + - save_cache: + key: test-node-modules-{{ checksum "package-lock.json" }} + paths: + - node_modules + - run: npm test Performance-Testing: docker: - # specify the version you desire here - - image: circleci/openjdk:8-jdk + # specify the version you desire here + - image: circleci/openjdk:8-jdk - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/postgres:9.4 + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 working_directory: ~/repo @@ -317,118 +308,118 @@ jobs: MAVEN_OPTS: -Xmx3200m steps: - - checkout + - checkout - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "pom.xml" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- - - run: mvn dependency:go-offline + - run: mvn dependency:go-offline - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "pom.xml" }} + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} - - run: mvn verify + - run: mvn verify - - store_artifacts: - path: target/jmeter/reports + - store_artifacts: + path: target/jmeter/reports workflows: version: 2 Build: when: << pipeline.parameters.run_basedeployment >> jobs: - # Development builds are executed on "new-develop" branch only. - - "build-dev": - context : org-global - filters: - branches: - only: - - free - # This is alternate dev env for parallel testing - - "build-test": - context : org-global - filters: - branches: - only: - - free - # This is alternate dev env for parallel testing - - "build-qa": - context : org-global - filters: - branches: - only: - - universal_nav - - marathon_match_submission_download - - feat/badges-box - # This is beta env for production soft releases - - "build-prod-beta": - context : org-global - filters: - branches: - only: - - free - # This is stage env for production QA releases - - "build-prod-staging": - context : org-global - filters: &filters-staging - branches: - only: - - develop - # Production builds are exectuted - # when PR is merged to the master - # Don't change anything in this configuration - # That might trigger wrong branch to be - # deployed on the production - # master branch. - - "build-prod": - context : org-global - filters: &filters-prod - branches: - only: - - master - # Simple testing is executed for any branch other than "develop" and - # "master". - - test: - filters: - branches: - ignore: - - develop - - submission_delete_button + # Development builds are executed on "new-develop" branch only. + - "build-dev": + context: org-global + filters: + branches: + only: + - feature/un-677 + # This is alternate dev env for parallel testing + - "build-test": + context: org-global + filters: + branches: + only: + - free + # This is alternate dev env for parallel testing + - "build-qa": + context: org-global + filters: + branches: + only: + - universal_nav + - marathon_match_submission_download + - feat/badges-box + # This is beta env for production soft releases + - "build-prod-beta": + context: org-global + filters: + branches: + only: + - free + # This is stage env for production QA releases + - "build-prod-staging": + context: org-global + filters: &filters-staging + branches: + only: + - develop + # Production builds are exectuted + # when PR is merged to the master + # Don't change anything in this configuration + # That might trigger wrong branch to be + # deployed on the production + # master branch. + - "build-prod": + context: org-global + filters: &filters-prod + branches: + only: + - master + # Simple testing is executed for any branch other than "develop" and + # "master". + - test: + filters: + branches: + ignore: + - develop + - submission_delete_button Smoke Testing: when: << pipeline.parameters.run_smoketesting >> jobs: - - Hold [Smoke-Testing]: - type: approval - - Smoke-Testing-On-Staging: - context : org-global - requires: - - Hold [Smoke-Testing] - filters: - <<: *filters-staging - - Smoke-Testing-On-Production: - context : org-global - requires: - - Hold [Smoke-Testing] - filters: - <<: *filters-prod + - Hold [Smoke-Testing]: + type: approval + - Smoke-Testing-On-Staging: + context: org-global + requires: + - Hold [Smoke-Testing] + filters: + !!merge <<: *filters-staging + - Smoke-Testing-On-Production: + context: org-global + requires: + - Hold [Smoke-Testing] + filters: + !!merge <<: *filters-prod Performance Testing: when: << pipeline.parameters.run_performancetesting >> jobs: - - Hold [Performance-Testing]: - type: approval - - Performance-Testing: - requires: - - Hold [Performance-Testing] - filters: - branches: - only: - - master - - develop + - Hold [Performance-Testing]: + type: approval + - Performance-Testing: + requires: + - Hold [Performance-Testing] + filters: + branches: + only: + - master + - develop From 80c2eca3330069a5b825f429bae572367a9a10e0 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Wed, 15 Mar 2023 18:32:53 +0600 Subject: [PATCH 03/17] fix: lint errors --- .circleci/config.yml | 691 +++++++++--------- .../MyPrimaryRole/FormInputRadio/styles.scss | 10 +- .../Account/MyPrimaryRole/styles.scss | 3 - 3 files changed, 354 insertions(+), 350 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ecfb5bc7b1..e14a08fc78 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,305 +1,314 @@ version: 2.1 parameters: - run_basedeployment: - default: true - type: boolean - run_smoketesting: - default: false - type: boolean - run_performancetesting: - default: false - type: boolean + run_basedeployment: + default: true + type: boolean + run_smoketesting: + default: false + type: boolean + run_performancetesting: + default: false + type: boolean defaults: &defaults - docker: - - image: docker:20.10.21-git - environment: - ENV: $BASH_ENV + docker: + - image: docker:20.10.21-git + environment: + ENV: $BASH_ENV install_dependency: &install_dependency - name: Installation of build and deployment dependencies. - command: | - apk update - apk add --no-cache bash openssl curl - apk upgrade - apk add --no-cache jq py-pip sudo - sudo pip install awscli --upgrade + name: Installation of build and deployment dependencies. + command: | + apk update + apk add --no-cache bash openssl curl + apk upgrade + apk add --no-cache jq py-pip sudo + sudo pip install awscli --upgrade install_deploysuite: &install_deploysuite - name: Installation of install_deploysuite. - command: | - git clone --branch v1.4.14 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript - cp ./../buildscript/master_deploy.sh . - cp ./../buildscript/buildenv.sh . - cp ./../buildscript/awsconfiguration.sh . + name: Installation of install_deploysuite. + command: | + git clone --branch v1.4.14 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + cp ./../buildscript/master_deploy.sh . + cp ./../buildscript/buildenv.sh . + cp ./../buildscript/awsconfiguration.sh . restore_cache_settings_for_build: &restore_cache_settings_for_build key: docker-node-modules-v3-{{ checksum "package-lock.json" }} save_cache_settings: &save_cache_settings key: docker-node-modules-v3-{{ checksum "package-lock.json" }} paths: - - node_modules + - node_modules build_docker_image: &build_docker_image - name: Build of Docker image - command: | - source buildenvvar - ./build.sh - no_output_timeout: 20m + name: Build of Docker image + command: | + source buildenvvar + ./build.sh + no_output_timeout: 20m jobs: # Build & Deploy against development backend "build-dev": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - # Build of Docker image. - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + # Build of Docker image. + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp # Build & Deploy against testing backend "build-test": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b test_communityapp_buildvar,test_communityapp_deployvar -l dev_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b test_communityapp_buildvar,test_communityapp_deployvar -l dev_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp # Build & Deploy against testing backend "build-qa": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar -l dev_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar -l dev_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp # Build & Deploy against prod api backend "build-prod-beta": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b beta_communityapp_buildvar,beta_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e PROD -t latest -s beta_communityapp_taskvar, -i communityapp + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b beta_communityapp_buildvar,beta_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e PROD -t latest -s beta_communityapp_taskvar, -i communityapp # Build & Deploy against prod api backend "build-prod-staging": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: "source awsenvconf\nsource buildenvvar\n./master_deploy.sh -d ECS -e PROD -t latest -s staging_communityapp_taskvar, -i communityapp \ncurl --request POST \\\n--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \\\n--header \"Circle-Token: ${CIRCLE_TOKEN}\" \\\n--header 'content-type: application/json' \\\n--data '{\"branch\":\"'\"$CIRCLE_BRANCH\"'\",\"parameters\":{\"run_smoketesting\":true , \"run_performancetesting\":false, \"run_basedeployment\": false}}'\n#magic___^_^___line\n" + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e PROD -t latest -s staging_communityapp_taskvar, -i communityapp + curl --request POST \ + --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ + --header "Circle-Token: ${CIRCLE_TOKEN}" \ + --header 'content-type: application/json' \ + --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' + # Build & Deploy against production backend "build-prod": - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar -l prod_communityapp_buildvar_ps - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e PROD -t latest -s prod_communityapp_taskvar -i communityapp - curl --request POST \ - --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ - --header "Circle-Token: ${CIRCLE_TOKEN}" \ - --header 'content-type: application/json' \ - --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar -l prod_communityapp_buildvar_ps + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e PROD -t latest -s prod_communityapp_taskvar -i communityapp + curl --request POST \ + --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \ + --header "Circle-Token: ${CIRCLE_TOKEN}" \ + --header 'content-type: application/json' \ + --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}' # Automated Smoke Testing against Staging Smoke-Testing-On-Staging: - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar - - run: - name: "Run automation" - no_output_timeout: 20m - command: | - source awsenvconf - source buildenvvar - ./automated-smoke-test/smoketest.sh automation-config-staging.json prod - - store_artifacts: - path: ./automated-smoke-test/test-results + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar + - run: + name: "Run automation" + no_output_timeout: 20m + command: | + source awsenvconf + source buildenvvar + ./automated-smoke-test/smoketest.sh automation-config-staging.json prod + - store_artifacts: + path: ./automated-smoke-test/test-results - # Automated Smoke Testing against Production + # Automated Smoke Testing against Production Smoke-Testing-On-Production: - !!merge <<: *defaults + <<: *defaults steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh PROD - ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar - - run: - name: "Run automation" - no_output_timeout: 20m - command: | - source awsenvconf - source buildenvvar - ./automated-smoke-test/smoketest.sh automation-config-prod.json prod - - store_artifacts: - path: ./automated-smoke-test/test-results + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh PROD + ./buildenv.sh -e PROD -b prod_communityapp_buildvar,prod_communityapp_deployvar + - run: + name: "Run automation" + no_output_timeout: 20m + command: | + source awsenvconf + source buildenvvar + ./automated-smoke-test/smoketest.sh automation-config-prod.json prod + - store_artifacts: + path: ./automated-smoke-test/test-results # Test job for the cases when we do not need deployment. It just rapidly # installs (updates) app dependencies, and runs tests (ESLint, Stylelint, # Jest unit-tests). test: docker: - - image: circleci/node:8.11.1 + - image: circleci/node:8.11.1 steps: - - checkout - - restore_cache: - key: test-node-modules-{{ checksum "package-lock.json" }} - - run: - name: Config Git - command: git config --global url."https://git@".insteadOf git:// - - run: - name: App npm install - command: npm install - no_output_timeout: 20m - - save_cache: - key: test-node-modules-{{ checksum "package-lock.json" }} - paths: - - node_modules - - run: npm test + - checkout + - restore_cache: + key: test-node-modules-{{ checksum "package-lock.json" }} + - run: + name: Config Git + command: git config --global url."https://git@".insteadOf git:// + - run: + name: App npm install + command: npm install + no_output_timeout: 20m + - save_cache: + key: test-node-modules-{{ checksum "package-lock.json" }} + paths: + - node_modules + - run: npm test Performance-Testing: docker: - # specify the version you desire here - - image: circleci/openjdk:8-jdk + # specify the version you desire here + - image: circleci/openjdk:8-jdk - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/postgres:9.4 + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 working_directory: ~/repo @@ -308,118 +317,118 @@ jobs: MAVEN_OPTS: -Xmx3200m steps: - - checkout + - checkout - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "pom.xml" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- - - run: mvn dependency:go-offline + - run: mvn dependency:go-offline - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "pom.xml" }} + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} - - run: mvn verify + - run: mvn verify - - store_artifacts: - path: target/jmeter/reports + - store_artifacts: + path: target/jmeter/reports workflows: version: 2 Build: when: << pipeline.parameters.run_basedeployment >> jobs: - # Development builds are executed on "new-develop" branch only. - - "build-dev": - context: org-global - filters: - branches: - only: - - feature/un-677 - # This is alternate dev env for parallel testing - - "build-test": - context: org-global - filters: - branches: - only: - - free - # This is alternate dev env for parallel testing - - "build-qa": - context: org-global - filters: - branches: - only: - - universal_nav - - marathon_match_submission_download - - feat/badges-box - # This is beta env for production soft releases - - "build-prod-beta": - context: org-global - filters: - branches: - only: - - free - # This is stage env for production QA releases - - "build-prod-staging": - context: org-global - filters: &filters-staging - branches: - only: - - develop - # Production builds are exectuted - # when PR is merged to the master - # Don't change anything in this configuration - # That might trigger wrong branch to be - # deployed on the production - # master branch. - - "build-prod": - context: org-global - filters: &filters-prod - branches: - only: - - master - # Simple testing is executed for any branch other than "develop" and - # "master". - - test: - filters: - branches: - ignore: - - develop - - submission_delete_button + # Development builds are executed on "new-develop" branch only. + - "build-dev": + context : org-global + filters: + branches: + only: + - feature/un-677 + # This is alternate dev env for parallel testing + - "build-test": + context : org-global + filters: + branches: + only: + - free + # This is alternate dev env for parallel testing + - "build-qa": + context : org-global + filters: + branches: + only: + - universal_nav + - marathon_match_submission_download + - feat/badges-box + # This is beta env for production soft releases + - "build-prod-beta": + context : org-global + filters: + branches: + only: + - free + # This is stage env for production QA releases + - "build-prod-staging": + context : org-global + filters: &filters-staging + branches: + only: + - develop + # Production builds are exectuted + # when PR is merged to the master + # Don't change anything in this configuration + # That might trigger wrong branch to be + # deployed on the production + # master branch. + - "build-prod": + context : org-global + filters: &filters-prod + branches: + only: + - master + # Simple testing is executed for any branch other than "develop" and + # "master". + - test: + filters: + branches: + ignore: + - develop + - submission_delete_button Smoke Testing: when: << pipeline.parameters.run_smoketesting >> jobs: - - Hold [Smoke-Testing]: - type: approval - - Smoke-Testing-On-Staging: - context: org-global - requires: - - Hold [Smoke-Testing] - filters: - !!merge <<: *filters-staging - - Smoke-Testing-On-Production: - context: org-global - requires: - - Hold [Smoke-Testing] - filters: - !!merge <<: *filters-prod + - Hold [Smoke-Testing]: + type: approval + - Smoke-Testing-On-Staging: + context : org-global + requires: + - Hold [Smoke-Testing] + filters: + <<: *filters-staging + - Smoke-Testing-On-Production: + context : org-global + requires: + - Hold [Smoke-Testing] + filters: + <<: *filters-prod Performance Testing: when: << pipeline.parameters.run_performancetesting >> jobs: - - Hold [Performance-Testing]: - type: approval - - Performance-Testing: - requires: - - Hold [Performance-Testing] - filters: - branches: - only: - - master - - develop + - Hold [Performance-Testing]: + type: approval + - Performance-Testing: + requires: + - Hold [Performance-Testing] + filters: + branches: + only: + - master + - develop diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss index ca01017729..a0bcfa7df9 100644 --- a/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss +++ b/src/shared/components/Settings/Account/MyPrimaryRole/FormInputRadio/styles.scss @@ -9,7 +9,7 @@ padding-left: 16px; width: calc(50% - 32px); // Subtract half the gap size from each button width height: 72px; - background: #ffffff; + background: #fff; border: 1px solid #d4d4d4; border-radius: 8px; margin-right: 32px; // Add the other half of the gap size as margin @@ -18,7 +18,6 @@ } } - .input-option { display: flex; flex-direction: row; @@ -29,7 +28,7 @@ .input-text-wrapper { display: flex; - align-items: center; + align-items: center; } .input-text { @@ -76,7 +75,7 @@ } .input-radio:checked ~ .custom-radio { - border-color: #137D60; + border-color: #137d60; } .input-radio:checked ~ .custom-radio::after { @@ -84,10 +83,9 @@ position: absolute; width: 10px; height: 10px; - background-color: #137D60; + background-color: #137d60; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%, -50%); } - diff --git a/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss b/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss index 36d18f9f62..3fd6b12965 100644 --- a/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss +++ b/src/shared/components/Settings/Account/MyPrimaryRole/styles.scss @@ -30,7 +30,6 @@ } } - input { @include roboto-regular; @@ -70,7 +69,6 @@ justify-content: space-between; width: 100%; } - } .form-title { @@ -134,7 +132,6 @@ } } - .nagModal { display: flex; flex-direction: column; From 6bff80d38dfb4fd1627598abb7a8d5794f95b833 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Wed, 15 Mar 2023 18:39:13 +0600 Subject: [PATCH 04/17] fix: update test snapshots --- __tests__/shared/__snapshots__/index.jsx.snap | 86 +-- .../Account/__snapshots__/index.jsx.snap | 696 ++++++++++++++++++ .../__snapshots__/index.jsx.snap | 2 +- 3 files changed, 699 insertions(+), 85 deletions(-) diff --git a/__tests__/shared/__snapshots__/index.jsx.snap b/__tests__/shared/__snapshots__/index.jsx.snap index 2069cbf96f..0a08765a2f 100644 --- a/__tests__/shared/__snapshots__/index.jsx.snap +++ b/__tests__/shared/__snapshots__/index.jsx.snap @@ -1,87 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Snapshot match 1`] = ` -
- - - -