mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
fix: metrics invalid date (#248)
* fix: lint * refactor: return fetch from create * fix: lint * fix: change name from featureToggle to createdToggle
This commit is contained in:
parent
8929e106cb
commit
10d95c36e0
@ -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 }) => (
|
||||
<Chip className={styles.chip}>
|
||||
@ -116,8 +117,16 @@ export default class MetricComponent extends React.Component {
|
||||
)}
|
||||
<AppsLinkList apps={seenApps} />
|
||||
<div>
|
||||
<strong>Created: </strong>
|
||||
<span>{this.formatFullDateTime(featureToggle.createdAt)}</span>
|
||||
<ConditionallyRender
|
||||
condition={featureToggle.createdAt}
|
||||
show={
|
||||
<>
|
||||
<strong>Created: </strong>
|
||||
<span>{this.formatFullDateTime(featureToggle.createdAt)}</span>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<br />
|
||||
<strong>Last seen: </strong>
|
||||
<span>{this.renderLastSeen(featureToggle.lastSeenAt)}</span>
|
||||
|
@ -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));
|
||||
};
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user