chore: added disabled prop to multiple select components (#4724)
* chore: added disabled prop to mutliple select group hoc * style: fix empty space
This commit is contained in:
parent
cdb932ab67
commit
1c849103f9
13 changed files with 62 additions and 18 deletions
|
|
@ -18,6 +18,8 @@ export const MultipleSelectEntityAction: React.FC<Props> = (props) => {
|
|||
// derived values
|
||||
const isSelected = selectionHelpers.getIsEntitySelected(id);
|
||||
|
||||
if (selectionHelpers.isSelectionDisabled) return null;
|
||||
|
||||
return (
|
||||
<Checkbox
|
||||
className={cn("!outline-none size-3.5", className)}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ export const MultipleSelectGroupAction: React.FC<Props> = (props) => {
|
|||
// derived values
|
||||
const groupSelectionStatus = selectionHelpers.isGroupSelected(groupID);
|
||||
|
||||
if (selectionHelpers.isSelectionDisabled) return null;
|
||||
|
||||
return (
|
||||
<Checkbox
|
||||
className={cn("size-3.5 !outline-none", className)}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ import { TSelectionHelper, useMultipleSelect } from "@/hooks/use-multiple-select
|
|||
type Props = {
|
||||
children: (helpers: TSelectionHelper) => React.ReactNode;
|
||||
containerRef: React.MutableRefObject<HTMLElement | null>;
|
||||
disabled?: boolean;
|
||||
entities: Record<string, string[]>; // { groupID: entityIds[] }
|
||||
};
|
||||
|
||||
export const MultipleSelectGroup: React.FC<Props> = observer((props) => {
|
||||
const { children, containerRef, entities } = props;
|
||||
const { children, containerRef, disabled = false, entities } = props;
|
||||
|
||||
const helpers = useMultipleSelect({
|
||||
containerRef,
|
||||
disabled,
|
||||
entities,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ export const GanttChartMainContent: React.FC<Props> = observer((props) => {
|
|||
entities={{
|
||||
[GANTT_SELECT_GROUP]: chartBlocks?.map((block) => block.id) ?? [],
|
||||
}}
|
||||
disabled
|
||||
>
|
||||
{(helpers) => (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ type Props = {
|
|||
};
|
||||
|
||||
export const IssueBulkOperationsRoot: React.FC<Props> = observer((props) => {
|
||||
const { className } = props;
|
||||
const { className, selectionHelpers } = props;
|
||||
// store hooks
|
||||
const { isSelectionActive } = useMultipleSelectStore();
|
||||
|
||||
if (!isSelectionActive) return null;
|
||||
if (!isSelectionActive || selectionHelpers.isSelectionDisabled) return null;
|
||||
|
||||
return <BulkOperationsUpgradeBanner className={className} />;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||
enableBlockMove={isAllowed}
|
||||
enableReorder={appliedDisplayFilters?.order_by === "sort_order" && isAllowed}
|
||||
enableAddBlock={isAllowed}
|
||||
enableSelection={isAllowed}
|
||||
enableSelection={false}
|
||||
quickAdd={
|
||||
enableIssueCreation && isAllowed ? (
|
||||
<GanttQuickAddIssueForm quickAddCallback={issues.quickAddIssue} viewId={viewId} />
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ export const IssueBlock = observer((props: IssueBlockProps) => {
|
|||
const isIssueSelected = selectionHelpers.getIsEntitySelected(issue.id);
|
||||
const isIssueActive = selectionHelpers.getIsEntityActive(issue.id);
|
||||
const isSubIssue = nestingLevel !== 0;
|
||||
const canSelectIssues = canEditIssueProperties && !selectionHelpers.isSelectionDisabled;
|
||||
|
||||
const marginLeft = `${spacingLeft}px`;
|
||||
|
||||
|
|
@ -149,7 +150,7 @@ export const IssueBlock = observer((props: IssueBlockProps) => {
|
|||
<div className="flex flex-grow items-center gap-0.5 truncate">
|
||||
<div className="flex items-center gap-1" style={isSubIssue ? { marginLeft } : {}}>
|
||||
{/* select checkbox */}
|
||||
{projectId && canEditIssueProperties && (
|
||||
{projectId && canSelectIssues && (
|
||||
<Tooltip
|
||||
tooltipContent={
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ const GroupByList: React.FC<IGroupByList> = observer((props) => {
|
|||
return (
|
||||
<div className="relative size-full flex flex-col">
|
||||
{groups && (
|
||||
<MultipleSelectGroup containerRef={containerRef} entities={entities}>
|
||||
<MultipleSelectGroup containerRef={containerRef} entities={entities} disabled>
|
||||
{(helpers) => (
|
||||
<>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export const HeaderGroupByCard = observer((props: IHeaderGroupByCard) => {
|
|||
const existingIssuesListModalPayload = moduleId ? { module: moduleId.toString() } : { cycle: true };
|
||||
const isGroupSelectionEmpty = selectionHelpers.isGroupSelected(groupID) === "empty";
|
||||
// auth
|
||||
const canSelectIssues = canEditProperties(projectId?.toString());
|
||||
const canSelectIssues = canEditProperties(projectId?.toString()) && !selectionHelpers.isSelectionDisabled;
|
||||
|
||||
const handleAddIssuesToView = async (data: ISearchIssueResponse[]) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
|
@ -83,7 +83,7 @@ export const HeaderGroupByCard = observer((props: IHeaderGroupByCard) => {
|
|||
|
||||
return (
|
||||
<>
|
||||
<div className="group/list-header relative w-full flex-shrink-0 flex items-center gap-2 py-1.5">
|
||||
<div className="group/list-header relative w-full flex-shrink-0 flex items-center gap-2 py-1.5 pl-1">
|
||||
{canSelectIssues && (
|
||||
<div className="flex-shrink-0 flex items-center w-3.5">
|
||||
<MultipleSelectGroupAction
|
||||
|
|
|
|||
|
|
@ -222,6 +222,8 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => {
|
|||
const subIssuesCount = issueDetail?.sub_issues_count ?? 0;
|
||||
const isIssueSelected = selectionHelpers.getIsEntitySelected(issueDetail.id);
|
||||
|
||||
const canSelectIssues = !disableUserActions && !selectionHelpers.isSelectionDisabled;
|
||||
|
||||
//TODO: add better logic. This is to have a min width for ID/Key based on the length of project identifier
|
||||
const keyMinWidth = (getProjectIdentifierById(issueDetail.project_id)?.length ?? 0 + 5) * 7;
|
||||
|
||||
|
|
@ -250,7 +252,7 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => {
|
|||
>
|
||||
<div className="flex items-center gap-0.5 min-w-min py-2.5 pl-2">
|
||||
{/* select checkbox */}
|
||||
{projectId && !disableUserActions && (
|
||||
{projectId && canSelectIssues && (
|
||||
<Tooltip
|
||||
tooltipContent={
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export const SpreadsheetHeader = observer((props: Props) => {
|
|||
// derived values
|
||||
const isGroupSelectionEmpty = selectionHelpers.isGroupSelected(SPREADSHEET_SELECT_GROUP) === "empty";
|
||||
// auth
|
||||
const canSelectIssues = canEditProperties(projectId?.toString());
|
||||
const canSelectIssues = canEditProperties(projectId?.toString()) && !selectionHelpers.isSelectionDisabled;
|
||||
|
||||
return (
|
||||
<thead className="sticky top-0 left-0 z-[12] border-b-[0.5px] border-custom-border-100">
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
|||
entities={{
|
||||
[SPREADSHEET_SELECT_GROUP]: issueIds,
|
||||
}}
|
||||
disabled
|
||||
>
|
||||
{(helpers) => (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue