mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
fix:handle non-existing feature toggle
This commit is contained in:
parent
195cded10b
commit
b5072928b3
@ -75,8 +75,22 @@ const App = ({ location, user, fetchUiBootstrap, feedback }: IAppProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SWRConfig value={{
|
<SWRConfig
|
||||||
onError: (error) => {
|
value={{
|
||||||
|
onErrorRetry: (
|
||||||
|
error,
|
||||||
|
_key,
|
||||||
|
_config,
|
||||||
|
revalidate,
|
||||||
|
{ retryCount }
|
||||||
|
) => {
|
||||||
|
// Never retry on 404.
|
||||||
|
if (error.status === 404) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
setTimeout(() => revalidate({ retryCount }), 5000);
|
||||||
|
},
|
||||||
|
onError: error => {
|
||||||
if (!isUnauthorized()) {
|
if (!isUnauthorized()) {
|
||||||
setToastData({
|
setToastData({
|
||||||
show: true,
|
show: true,
|
||||||
@ -85,7 +99,8 @@ const App = ({ location, user, fetchUiBootstrap, feedback }: IAppProps) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<LayoutPicker location={location}>
|
<LayoutPicker location={location}>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
@ -18,10 +18,12 @@ import FeatureVariants from './FeatureVariants/FeatureVariants';
|
|||||||
import { useStyles } from './FeatureView2.styles';
|
import { useStyles } from './FeatureView2.styles';
|
||||||
import FeatureSettings from './FeatureSettings/FeatureSettings';
|
import FeatureSettings from './FeatureSettings/FeatureSettings';
|
||||||
import useLoading from '../../../hooks/useLoading';
|
import useLoading from '../../../hooks/useLoading';
|
||||||
|
import ConditionallyRender from '../../common/ConditionallyRender';
|
||||||
|
import { getCreateTogglePath } from '../../../utils/route-path-helpers';
|
||||||
|
|
||||||
const FeatureView2 = () => {
|
const FeatureView2 = () => {
|
||||||
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
||||||
const { feature, loading } = useFeature(projectId, featureId);
|
const { feature, loading, error } = useFeature(projectId, featureId);
|
||||||
const { a11yProps } = useTabs(0);
|
const { a11yProps } = useTabs(0);
|
||||||
const { archiveFeatureToggle } = useFeatureApi();
|
const { archiveFeatureToggle } = useFeatureApi();
|
||||||
const { toast, setToastData } = useToast();
|
const { toast, setToastData } = useToast();
|
||||||
@ -97,11 +99,30 @@ const FeatureView2 = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderFeatureNotExist = () => {
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
The feature <strong>{featureId} </strong>does not exist. Do
|
||||||
|
you want to
|
||||||
|
<Link to={getCreateTogglePath(projectId)}>create it</Link>
|
||||||
|
?
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={error === undefined}
|
||||||
|
show={
|
||||||
<div ref={ref}>
|
<div ref={ref}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<div className={styles.innerContainer}>
|
<div className={styles.innerContainer}>
|
||||||
<h2 className={styles.featureViewHeader} data-loading>
|
<h2
|
||||||
|
className={styles.featureViewHeader}
|
||||||
|
data-loading
|
||||||
|
>
|
||||||
{feature.name}
|
{feature.name}
|
||||||
</h2>
|
</h2>
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
@ -173,6 +194,9 @@ const FeatureView2 = () => {
|
|||||||
</Dialogue>
|
</Dialogue>
|
||||||
{toast}
|
{toast}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
elseShow={renderFeatureNotExist()}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user