Skip to content

Commit

Permalink
Merge pull request #213 from IABTechLab/ajy-UID2-Minor-sharing-permis…
Browse files Browse the repository at this point in the history
…sions-fixes

ajy-UID2-Minor-sharing-permissions-fixes
  • Loading branch information
alex-yau-ttd authored Oct 10, 2023
2 parents 525ca7c + a1fdb91 commit a98589f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/web/components/SharingPermission/ParticipantItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
width: 21px;
height: 21px;
}
.participant-checkbox {
margin-right: 16px;
.tooltip {
padding-right: 16px;
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/web/components/SharingPermission/ParticipantItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ type ParticipantItemProps = ParticipantItemSimpleProps & {
export function ParticipantItem({ site, onClick, checked }: ParticipantItemProps) {
const checkboxDisabled = isSharingParticipant(site) && !isAddedByManual(site);
const checkbox = (
<TriStateCheckbox
onClick={onClick}
status={checked}
className='participant-checkbox'
disabled={checkboxDisabled}
/>
<TriStateCheckbox onClick={onClick} status={checked} disabled={checkboxDisabled} />
);
return (
<tr className='participant-item-with-checkbox'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ export function ParticipantSearchBar({
<thead>
<tr className='participant-item-with-checkbox'>
<th>
<TriStateCheckbox
onClick={handleCheckboxChange}
status={checkboxStatus}
className='participant-checkbox'
/>
<TriStateCheckbox onClick={handleCheckboxChange} status={checkboxStatus} />
</th>
<th colSpan={3}>
<span className='select-all'>Select All {filteredSites.length} Participants</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const isAddedByManual = (site: SharingSiteWithSource) => {
return site.addedBy.includes(MANUALLY_ADDED);
};

export const disableSelectAllCheckbox = (sites: SharingSiteWithSource[]) => {
return !sites.some(isAddedByManual);
};

export function filterSites<TSharingSite extends SharingSiteDTO>(
sites: TSharingSite[],
filterText: string,
Expand Down
25 changes: 19 additions & 6 deletions src/web/components/SharingPermission/SharingPermissionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { Dialog } from '../Core/Dialog';
import { Loading } from '../Core/Loading';
import { MultiSelectDropdown } from '../Core/MultiSelectDropdown';
import { SortableTableHeader } from '../Core/SortableTableHeader';
import { Tooltip } from '../Core/Tooltip';
import { TriStateCheckbox, TriStateCheckboxState } from '../Core/TriStateCheckbox';
import { ParticipantsTable } from './ParticipantsTable';
import {
disableSelectAllCheckbox,
filterSites,
getSelectAllState,
isAddedByManual,
Expand Down Expand Up @@ -149,6 +151,14 @@ export function SharingPermissionsTableContent({
}
};

const selectAllCheckbox = (
<TriStateCheckbox
onClick={handleCheckboxChange}
status={checkboxStatus}
disabled={disableSelectAllCheckbox(filteredSites)}
/>
);

const tableHeader = (
<thead>
<tr className='participant-item-with-checkbox'>
Expand All @@ -164,11 +174,14 @@ export function SharingPermissionsTableContent({
<>
<div className='sharing-permissions-table-header-container'>
<div className='sharing-permission-actions'>
<TriStateCheckbox
onClick={handleCheckboxChange}
status={checkboxStatus}
className='participant-checkbox'
/>
{disableSelectAllCheckbox(filteredSites) ? (
<Tooltip trigger={selectAllCheckbox}>
Gray indicates participants selected in bulk permissions. To update, adjust bulk
permission settings.
</Tooltip>
) : (
selectAllCheckbox
)}
{checkedSites.size > 0 && (
<DeletePermissionDialog
onDeleteSharingPermission={handleDeletePermissions}
Expand Down Expand Up @@ -218,7 +231,7 @@ export function SharingPermissionsTable({
const getSharingParticipants: () => SharingSiteWithSource[] = () => {
return sites!
.map((p) => {
const maybeManualArray: typeof MANUALLY_ADDED[] = sharedSiteIds.includes(p.id)
const maybeManualArray: (typeof MANUALLY_ADDED)[] = sharedSiteIds.includes(p.id)
? [MANUALLY_ADDED]
: [];
const includedTypes =
Expand Down

0 comments on commit a98589f

Please sign in to comment.