diff --git a/.circleci/config.yml b/.circleci/config.yml index 475a2cf2..ca35642d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,10 +16,10 @@ install_deploysuite: &install_deploysuite cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . restore_cache_settings_for_build: &restore_cache_settings_for_build - key: docker-node-modules-{{ checksum "package-lock.json" }} + key: docker-node-modules-temp1-{{ checksum "package-lock.json" }} save_cache_settings: &save_cache_settings - key: docker-node-modules-{{ checksum "package-lock.json" }} + key: docker-node-modules-temp1-{{ checksum "package-lock.json" }} paths: - node_modules diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 601e8c39..ef74ecb5 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -1199,6 +1199,9 @@ class ChallengeEditor extends Component { } } {!isLoading && isActive &&
+
+ +
{isTask && (
diff --git a/src/config/constants.js b/src/config/constants.js index 5ae0d333..73dbd65d 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -147,6 +147,11 @@ export const ALLOWED_USER_ROLES = [ 'connect copilot' ] +export const ADMIN_ROLES = [ + 'administrator', + 'connect admin' +] + export const downloadAttachmentURL = (challengeId, attachmentId, token) => `${CHALLENGE_API_URL}/${challengeId}/attachments/${attachmentId}?token=${token}` diff --git a/src/containers/ChallengeEditor/index.js b/src/containers/ChallengeEditor/index.js index f000a2c6..fe5cd17b 100644 --- a/src/containers/ChallengeEditor/index.js +++ b/src/containers/ChallengeEditor/index.js @@ -5,6 +5,7 @@ import { withRouter, Route } from 'react-router-dom' import ChallengeEditorComponent from '../../components/ChallengeEditor' import ChallengeViewComponent from '../../components/ChallengeEditor/ChallengeView' import Loader from '../../components/Loader' +import { checkAdmin } from '../../util/tc' import styles from './ChallengeEditor.module.scss' import { @@ -120,7 +121,11 @@ class ChallengeEditor extends Component { } isEditable () { - const { hasProjectAccess, metadata: { resourceRoles }, challengeResources, loggedInUser } = this.props + const { hasProjectAccess, metadata: { resourceRoles }, challengeResources, loggedInUser, token } = this.props + const isAdmin = checkAdmin(token) + if (isAdmin) { + return true + } if (!hasProjectAccess) { return false } diff --git a/src/services/challenges.js b/src/services/challenges.js index 333920b8..1c2a4b4f 100644 --- a/src/services/challenges.js +++ b/src/services/challenges.js @@ -74,7 +74,7 @@ export async function fetchTimelineTemplates () { * @returns {Promise<*>} */ export async function fetchChallengeTimelines () { - const response = await axiosInstance.get(`${CHALLENGE_TIMELINES_URL}?page=1&perPage=100`) + const response = await axiosInstance.get(`${CHALLENGE_TIMELINES_URL}?isDefault=true&page=1&perPage=100`) return _.get(response, 'data', []) } diff --git a/src/util/tc.js b/src/util/tc.js index fb056b11..9b732949 100644 --- a/src/util/tc.js +++ b/src/util/tc.js @@ -1,7 +1,9 @@ /** * Topcoder related utilities */ -import { MARATHON_MATCH_SUBTRACKS, CHALLENGE_TRACKS, ALLOWED_USER_ROLES } from '../config/constants' +import { MARATHON_MATCH_SUBTRACKS, CHALLENGE_TRACKS, ALLOWED_USER_ROLES, ADMIN_ROLES } from '../config/constants' +import _ from 'lodash' +import jwtDecode from 'jwt-decode' export const RATING_COLORS = [{ color: '#9D9FA0' /* Grey */, @@ -48,3 +50,12 @@ export function fixedTrack (track, subTrack) { * @param roles */ export const checkAllowedRoles = (roles) => roles.some(val => ALLOWED_USER_ROLES.indexOf(val.toLowerCase()) > -1) + +/** + * Checks if token has any of the admin roles + * @param token + */ +export const checkAdmin = (token) => { + const roles = _.get(jwtDecode(token), 'roles') + return roles.some(val => ADMIN_ROLES.indexOf(val.toLowerCase()) > -1) +}