diff --git a/web/packages/shared/components/UnifiedResources/FilterPanel.tsx b/web/packages/shared/components/UnifiedResources/FilterPanel.tsx index 21e98ab0af72c..dd0240d26cba8 100644 --- a/web/packages/shared/components/UnifiedResources/FilterPanel.tsx +++ b/web/packages/shared/components/UnifiedResources/FilterPanel.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import React, { useState, FormEvent } from 'react'; +import React, { useState } from 'react'; import styled from 'styled-components'; import { ButtonBorder, ButtonPrimary, ButtonSecondary } from 'design/Button'; import { SortDir } from 'design/DataTable/types'; -import { Text, Flex } from 'design'; +import { Text, Flex, Toggle } from 'design'; import Menu, { MenuItem } from 'design/Menu'; import { StyledCheckbox } from 'design/Checkbox'; import { @@ -512,17 +512,6 @@ function ViewModeSwitch({ ); } -const options: { value: IncludedResourceMode; label: string }[] = [ - { - value: 'accessible', - label: 'Available', - }, - { - value: 'requestable', - label: 'Can be requested', - }, -]; - const IncludedResourcesSelector = ({ onChange, availabilityFilter, @@ -540,29 +529,15 @@ const IncludedResourcesSelector = ({ setAnchorEl(null); }; - function applyFilter(e: FormEvent) { - e.preventDefault(); - handleClose(); - - const formData = new FormData(e.currentTarget); - const availabilityOptionsForm = formData.getAll('availabilityOptions'); - - if (availabilityOptionsForm.length === 0) { - onChange('none'); + function handleToggle() { + if ( + availabilityFilter.mode === 'requestable' || + availabilityFilter.mode === 'all' + ) { + onChange('accessible'); return; } - if (availabilityOptionsForm.length === 2) { - onChange('all'); - return; - } - - onChange(availabilityOptionsForm.at(0) as IncludedResourceMode); - } - - function isCheckboxPreSelected(option: IncludedResourceMode): boolean { - return ( - availabilityFilter.mode === option || availabilityFilter.mode === 'all' - ); + onChange(availabilityFilter.canRequestAll ? 'all' : 'requestable'); } return ( @@ -577,16 +552,17 @@ const IncludedResourcesSelector = ({ size="small" onClick={handleOpen} > - Availability + Access Requests - {availabilityFilter.canRequestAll === true && - availabilityFilter.mode !== 'none' && } + {availabilityFilter.mode === 'accessible' && ( + + )} ` // TODO (avatus): fix popover component to calculate correct height/anchor - margin-top: 76px; + margin-top: 36px; `} transformOrigin={{ vertical: 'top', @@ -600,35 +576,16 @@ const IncludedResourcesSelector = ({ open={Boolean(anchorEl)} onClose={handleClose} > -
- {options.map(option => ( - - - - {option.label} - - - ))} - - - Apply Filter - - - Cancel - - -
+ + Show requestable resources + +
); @@ -677,3 +634,17 @@ const FiltersExistIndicator = styled.div` border-radius: 50%; display: inline-block; `; + +const AccessRequestsToggleItem = styled.div` + min-height: 40px; + box-sizing: border-box; + padding-left: ${props => props.theme.space[2]}px; + padding-right: ${props => props.theme.space[2]}px; + display: flex; + justify-content: flex-start; + align-items: center; + min-width: 140px; + overflow: hidden; + text-decoration: none; + white-space: nowrap; +`;