mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
feat: feature completed connected to backend (#6947)
Connects feature complete to backend
This commit is contained in:
parent
78b9299ff1
commit
7d01dbb748
@ -11,9 +11,19 @@ const twoMinutesAgo = '2024-04-25T08:03:00.000Z';
|
|||||||
const oneHourAgo = '2024-04-25T07:05:00.000Z';
|
const oneHourAgo = '2024-04-25T07:05:00.000Z';
|
||||||
const twoHoursAgo = '2024-04-25T06:05:00.000Z';
|
const twoHoursAgo = '2024-04-25T06:05:00.000Z';
|
||||||
|
|
||||||
const renderOpenTooltip = (stage: LifecycleStage, onArchive = () => {}) => {
|
const renderOpenTooltip = (
|
||||||
|
stage: LifecycleStage,
|
||||||
|
onArchive = () => {},
|
||||||
|
onComplete = () => {},
|
||||||
|
loading = true,
|
||||||
|
) => {
|
||||||
render(
|
render(
|
||||||
<FeatureLifecycleTooltip stage={stage} onArchive={onArchive}>
|
<FeatureLifecycleTooltip
|
||||||
|
stage={stage}
|
||||||
|
onArchive={onArchive}
|
||||||
|
onComplete={onComplete}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
<span>child</span>
|
<span>child</span>
|
||||||
</FeatureLifecycleTooltip>,
|
</FeatureLifecycleTooltip>,
|
||||||
{ permissions: [{ permission: DELETE_FEATURE }] },
|
{ permissions: [{ permission: DELETE_FEATURE }] },
|
||||||
|
@ -257,7 +257,10 @@ const BoldTitle = styled(Typography)(({ theme }) => ({
|
|||||||
fontWeight: theme.fontWeight.bold,
|
fontWeight: theme.fontWeight.bold,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const LiveStageDescription: FC = ({ children }) => {
|
const LiveStageDescription: FC<{
|
||||||
|
onComplete: () => void;
|
||||||
|
loading: boolean;
|
||||||
|
}> = ({ children, onComplete, loading }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoldTitle>Is this feature complete?</BoldTitle>
|
<BoldTitle>Is this feature complete?</BoldTitle>
|
||||||
@ -274,6 +277,8 @@ const LiveStageDescription: FC = ({ children }) => {
|
|||||||
variant='outlined'
|
variant='outlined'
|
||||||
permission={UPDATE_FEATURE}
|
permission={UPDATE_FEATURE}
|
||||||
size='small'
|
size='small'
|
||||||
|
onClick={onComplete}
|
||||||
|
disabled={loading}
|
||||||
>
|
>
|
||||||
Mark Completed
|
Mark Completed
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
@ -351,7 +356,9 @@ export const FeatureLifecycleTooltip: FC<{
|
|||||||
children: React.ReactElement<any, any>;
|
children: React.ReactElement<any, any>;
|
||||||
stage: LifecycleStage;
|
stage: LifecycleStage;
|
||||||
onArchive: () => void;
|
onArchive: () => void;
|
||||||
}> = ({ children, stage, onArchive }) => (
|
onComplete: () => void;
|
||||||
|
loading: boolean;
|
||||||
|
}> = ({ children, stage, onArchive, onComplete, loading }) => (
|
||||||
<HtmlTooltip
|
<HtmlTooltip
|
||||||
maxHeight={800}
|
maxHeight={800}
|
||||||
maxWidth={350}
|
maxWidth={350}
|
||||||
@ -393,7 +400,10 @@ export const FeatureLifecycleTooltip: FC<{
|
|||||||
</PreLiveStageDescription>
|
</PreLiveStageDescription>
|
||||||
)}
|
)}
|
||||||
{stage.name === 'live' && (
|
{stage.name === 'live' && (
|
||||||
<LiveStageDescription>
|
<LiveStageDescription
|
||||||
|
onComplete={onComplete}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
<Environments environments={stage.environments} />
|
<Environments environments={stage.environments} />
|
||||||
</LiveStageDescription>
|
</LiveStageDescription>
|
||||||
)}
|
)}
|
||||||
|
@ -14,6 +14,7 @@ import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/Feat
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { FeatureArchiveNotAllowedDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveNotAllowedDialog';
|
import { FeatureArchiveNotAllowedDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveNotAllowedDialog';
|
||||||
import { populateCurrentStage } from '../FeatureLifecycle/populateCurrentStage';
|
import { populateCurrentStage } from '../FeatureLifecycle/populateCurrentStage';
|
||||||
|
import useFeatureLifecycleApi from 'hooks/api/actions/useFeatureLifecycleApi/useFeatureLifecycleApi';
|
||||||
|
|
||||||
const StyledContainer = styled('div')(({ theme }) => ({
|
const StyledContainer = styled('div')(({ theme }) => ({
|
||||||
borderRadius: theme.shape.borderRadiusLarge,
|
borderRadius: theme.shape.borderRadiusLarge,
|
||||||
@ -79,9 +80,10 @@ export const StyledLabel = styled('span')(({ theme }) => ({
|
|||||||
const FeatureOverviewMetaData = () => {
|
const FeatureOverviewMetaData = () => {
|
||||||
const projectId = useRequiredPathParam('projectId');
|
const projectId = useRequiredPathParam('projectId');
|
||||||
const featureId = useRequiredPathParam('featureId');
|
const featureId = useRequiredPathParam('featureId');
|
||||||
const { feature } = useFeature(projectId, featureId);
|
const { feature, refetchFeature } = useFeature(projectId, featureId);
|
||||||
const { project, description, type } = feature;
|
const { project, description, type } = feature;
|
||||||
const featureLifecycleEnabled = useUiFlag('featureLifecycle');
|
const featureLifecycleEnabled = useUiFlag('featureLifecycle');
|
||||||
|
const { markFeatureCompleted, loading } = useFeatureLifecycleApi();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [showDelDialog, setShowDelDialog] = useState(false);
|
const [showDelDialog, setShowDelDialog] = useState(false);
|
||||||
|
|
||||||
@ -89,6 +91,11 @@ const FeatureOverviewMetaData = () => {
|
|||||||
|
|
||||||
const currentStage = populateCurrentStage(feature);
|
const currentStage = populateCurrentStage(feature);
|
||||||
|
|
||||||
|
const onComplete = async () => {
|
||||||
|
await markFeatureCompleted(featureId, projectId);
|
||||||
|
refetchFeature();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<StyledPaddingContainerTop>
|
<StyledPaddingContainerTop>
|
||||||
@ -122,6 +129,8 @@ const FeatureOverviewMetaData = () => {
|
|||||||
<FeatureLifecycleTooltip
|
<FeatureLifecycleTooltip
|
||||||
stage={currentStage!}
|
stage={currentStage!}
|
||||||
onArchive={() => setShowDelDialog(true)}
|
onArchive={() => setShowDelDialog(true)}
|
||||||
|
onComplete={onComplete}
|
||||||
|
loading={loading}
|
||||||
>
|
>
|
||||||
<FeatureLifecycleStageIcon
|
<FeatureLifecycleStageIcon
|
||||||
stage={currentStage!}
|
stage={currentStage!}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
import useAPI from '../useApi/useApi';
|
||||||
|
|
||||||
|
const useFeatureLifecycleApi = () => {
|
||||||
|
const { makeRequest, makeLightRequest, createRequest, errors, loading } =
|
||||||
|
useAPI({
|
||||||
|
propagateErrors: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const markFeatureCompleted = async (name: string, project: string) => {
|
||||||
|
const path = `api/admin/projects/${project}/features/${name}/lifecycle/complete`;
|
||||||
|
const req = createRequest(path, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
|
||||||
|
return makeRequest(req.caller, req.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
markFeatureCompleted,
|
||||||
|
errors,
|
||||||
|
loading,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useFeatureLifecycleApi;
|
Loading…
Reference in New Issue
Block a user