mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: lifecycle button permissions (#7395)
This commit is contained in:
		
							parent
							
								
									708183ce26
								
							
						
					
					
						commit
						7e565760f6
					
				@ -8,6 +8,7 @@ import {
 | 
			
		||||
    DELETE_FEATURE,
 | 
			
		||||
    UPDATE_FEATURE,
 | 
			
		||||
} from 'component/providers/AccessProvider/permissions';
 | 
			
		||||
import { Route, Routes } from 'react-router-dom';
 | 
			
		||||
 | 
			
		||||
const currentTime = '2024-04-25T08:05:00.000Z';
 | 
			
		||||
const twoMinutesAgo = '2024-04-25T08:03:00.000Z';
 | 
			
		||||
@ -22,16 +23,24 @@ const renderOpenTooltip = (
 | 
			
		||||
    loading = false,
 | 
			
		||||
) => {
 | 
			
		||||
    render(
 | 
			
		||||
        <FeatureLifecycleTooltip
 | 
			
		||||
            stage={stage}
 | 
			
		||||
            onArchive={onArchive}
 | 
			
		||||
            onComplete={onComplete}
 | 
			
		||||
            onUncomplete={onUncomplete}
 | 
			
		||||
            loading={loading}
 | 
			
		||||
        >
 | 
			
		||||
            <span>child</span>
 | 
			
		||||
        </FeatureLifecycleTooltip>,
 | 
			
		||||
        <Routes>
 | 
			
		||||
            <Route
 | 
			
		||||
                path={'/projects/:projectId'}
 | 
			
		||||
                element={
 | 
			
		||||
                    <FeatureLifecycleTooltip
 | 
			
		||||
                        stage={stage}
 | 
			
		||||
                        onArchive={onArchive}
 | 
			
		||||
                        onComplete={onComplete}
 | 
			
		||||
                        onUncomplete={onUncomplete}
 | 
			
		||||
                        loading={loading}
 | 
			
		||||
                    >
 | 
			
		||||
                        <span>child</span>
 | 
			
		||||
                    </FeatureLifecycleTooltip>
 | 
			
		||||
                }
 | 
			
		||||
            />
 | 
			
		||||
        </Routes>,
 | 
			
		||||
        {
 | 
			
		||||
            route: '/projects/default',
 | 
			
		||||
            permissions: [
 | 
			
		||||
                { permission: DELETE_FEATURE },
 | 
			
		||||
                { permission: UPDATE_FEATURE },
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ import { isSafeToArchive } from './isSafeToArchive';
 | 
			
		||||
import { useLocationSettings } from 'hooks/useLocationSettings';
 | 
			
		||||
import { formatDateYMDHMS } from 'utils/formatDate';
 | 
			
		||||
import { formatDistanceToNow, parseISO } from 'date-fns';
 | 
			
		||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
 | 
			
		||||
 | 
			
		||||
const TimeLabel = styled('span')(({ theme }) => ({
 | 
			
		||||
    color: theme.palette.text.secondary,
 | 
			
		||||
@ -267,6 +268,8 @@ const LiveStageDescription: FC<{
 | 
			
		||||
    loading: boolean;
 | 
			
		||||
    children?: React.ReactNode;
 | 
			
		||||
}> = ({ children, onComplete, loading }) => {
 | 
			
		||||
    const projectId = useRequiredPathParam('projectId');
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <>
 | 
			
		||||
            <BoldTitle>Is this feature complete?</BoldTitle>
 | 
			
		||||
@ -285,6 +288,7 @@ const LiveStageDescription: FC<{
 | 
			
		||||
                size='small'
 | 
			
		||||
                onClick={onComplete}
 | 
			
		||||
                disabled={loading}
 | 
			
		||||
                projectId={projectId}
 | 
			
		||||
            >
 | 
			
		||||
                Mark completed
 | 
			
		||||
            </PermissionButton>
 | 
			
		||||
@ -303,6 +307,8 @@ const SafeToArchive: FC<{
 | 
			
		||||
    onUncomplete: () => void;
 | 
			
		||||
    loading: boolean;
 | 
			
		||||
}> = ({ onArchive, onUncomplete, loading }) => {
 | 
			
		||||
    const projectId = useRequiredPathParam('projectId');
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <>
 | 
			
		||||
            <BoldTitle>Safe to archive</BoldTitle>
 | 
			
		||||
@ -319,6 +325,7 @@ const SafeToArchive: FC<{
 | 
			
		||||
                sx={{
 | 
			
		||||
                    display: 'flex',
 | 
			
		||||
                    flexDirection: 'row',
 | 
			
		||||
                    flexWrap: 'wrap',
 | 
			
		||||
                    gap: 2,
 | 
			
		||||
                }}
 | 
			
		||||
            >
 | 
			
		||||
@ -329,6 +336,7 @@ const SafeToArchive: FC<{
 | 
			
		||||
                    size='small'
 | 
			
		||||
                    onClick={onUncomplete}
 | 
			
		||||
                    disabled={loading}
 | 
			
		||||
                    projectId={projectId}
 | 
			
		||||
                >
 | 
			
		||||
                    Revert to live
 | 
			
		||||
                </PermissionButton>
 | 
			
		||||
@ -339,6 +347,7 @@ const SafeToArchive: FC<{
 | 
			
		||||
                    size='small'
 | 
			
		||||
                    sx={{ mb: 2 }}
 | 
			
		||||
                    onClick={onArchive}
 | 
			
		||||
                    projectId={projectId}
 | 
			
		||||
                >
 | 
			
		||||
                    Archive feature
 | 
			
		||||
                </PermissionButton>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user