mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +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 { AppsLinkList, calc } from '../../common';
|
||||||
import { formatFullDateTimeWithLocale } from '../../common/util';
|
import { formatFullDateTimeWithLocale } from '../../common/util';
|
||||||
import styles from './metric.module.scss';
|
import styles from './metric.module.scss';
|
||||||
|
import ConditionallyRender from '../../common/conditionally-render';
|
||||||
|
|
||||||
const StrategyChipItem = ({ strategy }) => (
|
const StrategyChipItem = ({ strategy }) => (
|
||||||
<Chip className={styles.chip}>
|
<Chip className={styles.chip}>
|
||||||
@ -116,8 +117,16 @@ export default class MetricComponent extends React.Component {
|
|||||||
)}
|
)}
|
||||||
<AppsLinkList apps={seenApps} />
|
<AppsLinkList apps={seenApps} />
|
||||||
<div>
|
<div>
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={featureToggle.createdAt}
|
||||||
|
show={
|
||||||
|
<>
|
||||||
<strong>Created: </strong>
|
<strong>Created: </strong>
|
||||||
<span>{this.formatFullDateTime(featureToggle.createdAt)}</span>
|
<span>{this.formatFullDateTime(featureToggle.createdAt)}</span>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<strong>Last seen: </strong>
|
<strong>Last seen: </strong>
|
||||||
<span>{this.renderLastSeen(featureToggle.lastSeenAt)}</span>
|
<span>{this.renderLastSeen(featureToggle.lastSeenAt)}</span>
|
||||||
|
@ -76,6 +76,7 @@ export function fetchFeatureToggles() {
|
|||||||
|
|
||||||
export function fetchFeatureToggle(name) {
|
export function fetchFeatureToggle(name) {
|
||||||
debug('Start fetching feature toggles');
|
debug('Start fetching feature toggles');
|
||||||
|
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({ type: START_FETCH_FEATURE_TOGGLE });
|
dispatch({ type: START_FETCH_FEATURE_TOGGLE });
|
||||||
|
|
||||||
@ -92,7 +93,13 @@ export function createFeatureToggles(featureToggle) {
|
|||||||
|
|
||||||
return api
|
return api
|
||||||
.create(featureToggle)
|
.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));
|
.catch(dispatchAndThrow(dispatch, ERROR_CREATING_FEATURE_TOGGLE));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -148,7 +155,11 @@ export function requestUpdateFeatureToggleStrategies(featureToggle, newStrategie
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
const info = `${featureToggle.name} successfully updated!`;
|
const info = `${featureToggle.name} successfully updated!`;
|
||||||
setTimeout(() => dispatch({ type: MUTE_ERROR, error: info }), 1000);
|
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));
|
.catch(dispatchAndThrow(dispatch, ERROR_UPDATE_FEATURE_TOGGLE));
|
||||||
};
|
};
|
||||||
@ -164,7 +175,11 @@ export function requestUpdateFeatureToggleVariants(featureToggle, newVariants) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
const info = `${featureToggle.name} successfully updated!`;
|
const info = `${featureToggle.name} successfully updated!`;
|
||||||
setTimeout(() => dispatch({ type: MUTE_ERROR, error: info }), 1000);
|
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));
|
.catch(dispatchAndThrow(dispatch, ERROR_UPDATE_FEATURE_TOGGLE));
|
||||||
};
|
};
|
||||||
|
@ -24,17 +24,15 @@ function fetchFeatureToggle(name) {
|
|||||||
.then(response => response.json());
|
.then(response => response.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(featureToggle) {
|
async function create(featureToggle) {
|
||||||
return validateToggle(featureToggle)
|
await validateToggle(featureToggle);
|
||||||
.then(() =>
|
|
||||||
fetch(URI, {
|
return fetch(URI, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body: JSON.stringify(featureToggle),
|
body: JSON.stringify(featureToggle),
|
||||||
})
|
}).then(throwIfNotSuccess);
|
||||||
)
|
|
||||||
.then(throwIfNotSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate(featureToggle) {
|
function validate(featureToggle) {
|
||||||
|
Loading…
Reference in New Issue
Block a user