feat(task-management): add configuration buttons and permission checks to task filters
- Introduced ConfigPhaseButton and CreateStatusButton components for enhanced task filtering options. - Implemented permission checks to conditionally render configuration buttons based on user roles (owner/admin or project manager). - Removed the TaskManagementDemo component as it was no longer needed, streamlining the codebase.
This commit is contained in:
@@ -56,6 +56,12 @@ import {
|
||||
setBoardLabels,
|
||||
} from '@/features/board/board-slice';
|
||||
|
||||
// Import ConfigPhaseButton and CreateStatusButton components
|
||||
import ConfigPhaseButton from '@/features/projects/singleProject/phase/ConfigPhaseButton';
|
||||
import CreateStatusButton from '@/components/project-task-filters/create-status-button/create-status-button';
|
||||
import { useAuthService } from '@/hooks/useAuth';
|
||||
import useIsProjectManager from '@/hooks/useIsProjectManager';
|
||||
|
||||
// Performance constants
|
||||
const FILTER_DEBOUNCE_DELAY = 300; // ms
|
||||
const SEARCH_DEBOUNCE_DELAY = 500; // ms
|
||||
@@ -324,6 +330,10 @@ const FilterDropdown: React.FC<{
|
||||
isDarkMode: boolean;
|
||||
className?: string;
|
||||
}> = ({ section, onSelectionChange, isOpen, onToggle, themeClasses, isDarkMode, className = '' }) => {
|
||||
// Add permission checks for groupBy section
|
||||
const isOwnerOrAdmin = useAuthService().isOwnerOrAdmin();
|
||||
const isProjectManager = useIsProjectManager();
|
||||
const canConfigure = isOwnerOrAdmin || isProjectManager;
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [filteredOptions, setFilteredOptions] = useState(section.options);
|
||||
const dropdownRef = useRef<HTMLDivElement>(null);
|
||||
@@ -412,6 +422,14 @@ const FilterDropdown: React.FC<{
|
||||
/>
|
||||
</button>
|
||||
|
||||
{/* Configuration Buttons for GroupBy section */}
|
||||
{section.id === 'groupBy' && canConfigure && (
|
||||
<div className="inline-flex items-center gap-1 ml-2">
|
||||
{section.selectedValues[0] === 'phase' && <ConfigPhaseButton />}
|
||||
{section.selectedValues[0] === 'status' && <CreateStatusButton />}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Dropdown Panel */}
|
||||
{isOpen && (
|
||||
<div className={`absolute top-full left-0 z-50 mt-1 w-64 ${themeClasses.dropdownBg} rounded-md shadow-sm border ${themeClasses.dropdownBorder}`}>
|
||||
|
||||
Reference in New Issue
Block a user