From 0bf11112e1a4c8045c8432c091d1de642addbb12 Mon Sep 17 00:00:00 2001 From: maxceem Date: Thu, 10 Dec 2020 20:19:25 +0200 Subject: [PATCH] fix: show links for unsigned terms error ref issue #949 --- .../ChallengeEditor.module.scss | 16 +++++++++ src/components/ChallengeEditor/index.js | 34 +++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/components/ChallengeEditor/ChallengeEditor.module.scss b/src/components/ChallengeEditor/ChallengeEditor.module.scss index b66f644a..4d7f5b24 100644 --- a/src/components/ChallengeEditor/ChallengeEditor.module.scss +++ b/src/components/ChallengeEditor/ChallengeEditor.module.scss @@ -403,3 +403,19 @@ } } +ul.linkList { + display: inline; + margin: 0; + padding: 0; + + > li { + display: inline; + list-style: none; + margin: 0; + padding: 0; + } + + > li + li:before { + content:',\0000a0'; /* Non-breaking space */ + } +} diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index adedeeda..a9007b85 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -17,7 +17,8 @@ import { DEFAULT_NDA_UUID, SUBMITTER_ROLE_UUID, CREATE_FORUM_TYPE_IDS, - MESSAGE + MESSAGE, + COMMUNITY_APP_URL } from '../../config/constants' import { PrimaryButton, OutlineButton } from '../Buttons' import TrackField from './Track-Field' @@ -948,11 +949,40 @@ class ChallengeEditor extends Component { challenge: newChallenge, isSaving: false }, cb) } catch (e) { - const error = _.get(e, 'response.data.message', `Unable to update the challenge to status ${status}`) + const error = this.formatResponseError(e) || `Unable to update the challenge to status ${status}` this.setState({ isSaving: false, error }, cb) } } + /** + * Format the error we might get from some API endpoint. + * + * @param {Error} error error + * + * @returns {import('react').ReactNode} + */ + formatResponseError (error) { + const errorMessage = _.get(error, 'response.data.message') + const errorMetadata = _.get(error, 'response.data.metadata') + + if (errorMetadata.missingTerms && errorMetadata.missingTerms.length > 0) { + return <> + {errorMessage} + + + } + + // if no special error data, just use message + return errorMessage + } + async onActiveChallenge () { this.updateAllChallengeInfo('Active') }