diff --git a/frontend/src/component/feature/view/metric-component.jsx b/frontend/src/component/feature/view/metric-component.jsx index 00ab4a7aa2..d6cd5d1597 100644 --- a/frontend/src/component/feature/view/metric-component.jsx +++ b/frontend/src/component/feature/view/metric-component.jsx @@ -6,6 +6,7 @@ import { Link } from 'react-router-dom'; import { AppsLinkList, calc } from '../../common'; import { formatFullDateTimeWithLocale } from '../../common/util'; import styles from './metric.module.scss'; +import ConditionallyRender from '../../common/conditionally-render'; const StrategyChipItem = ({ strategy }) => ( @@ -116,8 +117,16 @@ export default class MetricComponent extends React.Component { )}
- Created: - {this.formatFullDateTime(featureToggle.createdAt)} + + Created: + {this.formatFullDateTime(featureToggle.createdAt)} + + } + /> +
Last seen: {this.renderLastSeen(featureToggle.lastSeenAt)} diff --git a/frontend/src/store/feature-toggle/actions.js b/frontend/src/store/feature-toggle/actions.js index f255ecbd29..49ba7bc323 100644 --- a/frontend/src/store/feature-toggle/actions.js +++ b/frontend/src/store/feature-toggle/actions.js @@ -76,6 +76,7 @@ export function fetchFeatureToggles() { export function fetchFeatureToggle(name) { debug('Start fetching feature toggles'); + return dispatch => { dispatch({ type: START_FETCH_FEATURE_TOGGLE }); @@ -92,7 +93,13 @@ export function createFeatureToggles(featureToggle) { return api .create(featureToggle) - .then(() => dispatch({ type: ADD_FEATURE_TOGGLE, featureToggle })) + .then(res => res.json()) + .then(createdFeature => { + dispatch({ + type: ADD_FEATURE_TOGGLE, + featureToggle: createdFeature, + }); + }) .catch(dispatchAndThrow(dispatch, ERROR_CREATING_FEATURE_TOGGLE)); }; } @@ -148,7 +155,11 @@ export function requestUpdateFeatureToggleStrategies(featureToggle, newStrategie .then(() => { const info = `${featureToggle.name} successfully updated!`; setTimeout(() => dispatch({ type: MUTE_ERROR, error: info }), 1000); - return dispatch({ type: UPDATE_FEATURE_TOGGLE_STRATEGIES, featureToggle, info }); + return dispatch({ + type: UPDATE_FEATURE_TOGGLE_STRATEGIES, + featureToggle, + info, + }); }) .catch(dispatchAndThrow(dispatch, ERROR_UPDATE_FEATURE_TOGGLE)); }; @@ -164,7 +175,11 @@ export function requestUpdateFeatureToggleVariants(featureToggle, newVariants) { .then(() => { const info = `${featureToggle.name} successfully updated!`; setTimeout(() => dispatch({ type: MUTE_ERROR, error: info }), 1000); - return dispatch({ type: UPDATE_FEATURE_TOGGLE_STRATEGIES, featureToggle, info }); + return dispatch({ + type: UPDATE_FEATURE_TOGGLE_STRATEGIES, + featureToggle, + info, + }); }) .catch(dispatchAndThrow(dispatch, ERROR_UPDATE_FEATURE_TOGGLE)); }; diff --git a/frontend/src/store/feature-toggle/api.js b/frontend/src/store/feature-toggle/api.js index e7e54f5452..4ba86e0b1f 100644 --- a/frontend/src/store/feature-toggle/api.js +++ b/frontend/src/store/feature-toggle/api.js @@ -24,17 +24,15 @@ function fetchFeatureToggle(name) { .then(response => response.json()); } -function create(featureToggle) { - return validateToggle(featureToggle) - .then(() => - fetch(URI, { - method: 'POST', - headers, - credentials: 'include', - body: JSON.stringify(featureToggle), - }) - ) - .then(throwIfNotSuccess); +async function create(featureToggle) { + await validateToggle(featureToggle); + + return fetch(URI, { + method: 'POST', + headers, + credentials: 'include', + body: JSON.stringify(featureToggle), + }).then(throwIfNotSuccess); } function validate(featureToggle) {