Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: view groups #7176

Merged
merged 37 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b45b652
feat: wip view groups
magrinj Sep 20, 2024
5375890
feat: wip create record group
magrinj Sep 20, 2024
1835bc1
feat: construct columns from view groups
magrinj Sep 23, 2024
3776a83
Merge remote-tracking branch 'origin/main' into feat/view-groups
magrinj Sep 23, 2024
9230495
feat: wip reorder
magrinj Sep 25, 2024
7379b41
fix: finally align column records with column id
magrinj Sep 26, 2024
d770255
fix: can hide board columns
magrinj Sep 27, 2024
b9ea518
fix
magrinj Sep 27, 2024
d28675c
Merge branch 'main' into feat/view-groups
magrinj Oct 14, 2024
7d27a03
feat: view group actions
magrinj Oct 15, 2024
0fd7080
Merge branch 'main' into feat/view-groups
magrinj Oct 15, 2024
b11be8d
fix: set menu to viewGroups when hidden groups are empty
magrinj Oct 15, 2024
e00cf0e
fix: use css for border instead of code logic
magrinj Oct 15, 2024
b0609f6
Merge branch 'main' into feat/view-groups
magrinj Oct 15, 2024
defa000
fix: lint
magrinj Oct 15, 2024
c06c6d7
fix: small fixes
magrinj Oct 16, 2024
7615d50
Merge branch 'main' into feat/view-groups
magrinj Oct 16, 2024
ed723ca
feat: scope recordGroupDefinitionState by viewId
magrinj Oct 21, 2024
b0f5833
Merge remote-tracking branch 'origin/main' into feat/view-groups
magrinj Oct 21, 2024
d3058d7
fix: drop again isFirstColumn and isLastColumn states
magrinj Oct 21, 2024
ee13123
Merge remote-tracking branch 'origin/main' into feat/view-groups
magrinj Oct 21, 2024
2d09ce8
fix: merge issues
magrinj Oct 21, 2024
64b4232
fix: board borders
magrinj Oct 21, 2024
8264951
Merge branch 'main' into feat/view-groups
magrinj Oct 22, 2024
a76ea95
fix: make changes required by the review
magrinj Oct 22, 2024
46c58bd
Merge branch 'main' into feat/view-groups
lucasbordeau Oct 23, 2024
7714331
Fix
lucasbordeau Oct 23, 2024
3ce3314
Fix
lucasbordeau Oct 23, 2024
9bc63d3
Fix
lucasbordeau Oct 23, 2024
86d1488
Fix creation
lucasbordeau Oct 23, 2024
04a3d07
Fix no value
lucasbordeau Oct 23, 2024
2f59bab
Fix lint
lucasbordeau Oct 23, 2024
529d819
Fix coverage
lucasbordeau Oct 23, 2024
5751bd9
Fix msw log
lucasbordeau Oct 23, 2024
c9604d3
Fix sb logs
lucasbordeau Oct 23, 2024
7d72880
Merge branch 'main' into feat/view-groups
lucasbordeau Oct 24, 2024
f7922df
Fix CI
lucasbordeau Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum CoreObjectNameSingular {
ViewField = 'viewField',
ViewFilter = 'viewFilter',
ViewSort = 'viewSort',
ViewGroup = 'viewGroup',
Webhook = 'webhook',
WorkspaceMember = 'workspaceMember',
MessageThreadSubscriber = 'messageThreadSubscriber',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const StyledContainer = styled.div`
flex: 1;
flex-direction: row;
min-height: calc(100% - 1px);
& > *:not(:first-child) {
border-left: 1px solid ${({ theme }) => theme.border.color.light};
}
lucasbordeau marked this conversation as resolved.
Show resolved Hide resolved
magrinj marked this conversation as resolved.
Show resolved Hide resolved
`;

const StyledWrapper = styled.div`
Expand Down Expand Up @@ -67,6 +70,11 @@ export const RecordBoard = ({ recordBoardId }: RecordBoardProps) => {
const { resetRecordSelection, setRecordAsSelected } =
useRecordBoardSelection(recordBoardId);

// const isPersistingViewGroups = useRecoilComponentValueV2(
magrinj marked this conversation as resolved.
Show resolved Hide resolved
// isPersistingViewGroupsComponentState,
// recordBoardId,
// );

useListenClickOutsideByClassName({
classNames: ['record-board-card'],
excludeClassNames: ['bottom-bar', 'context-menu'],
Expand Down Expand Up @@ -140,6 +148,12 @@ export const RecordBoard = ({ recordBoardId }: RecordBoardProps) => {
],
);

// FixMe: Check if we really need this as it depends on the times it takes to update the view groups
// if (isPersistingViewGroups) {
// // TODO: Add skeleton state
// return null;
// }
Comment on lines +145 to +149
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To determine during testing

Comment on lines +145 to +149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Remove or implement the commented code for persisting view groups


return (
<RecordBoardScope
recordBoardScopeId={getScopeIdFromComponentId(recordBoardId)}
Expand All @@ -151,10 +165,11 @@ export const RecordBoard = ({ recordBoardId }: RecordBoardProps) => {
<ScrollWrapper contextProviderName="recordBoard">
<StyledContainer ref={boardRef}>
<DragDropContext onDragEnd={onDragEnd}>
{columnIds.map((columnId) => (
{columnIds.map((columnId, index) => (
<RecordBoardColumn
key={columnId}
recordBoardColumnId={columnId}
__indexDebug={index}
magrinj marked this conversation as resolved.
Show resolved Hide resolved
/>
))}
</DragDropContext>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext';
import { isFirstRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState';
import { isLastRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState';
import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState';
import { isRecordBoardCompactModeActiveComponentState } from '@/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState';
import { isRecordBoardFetchingRecordsByColumnFamilyState } from '@/object-record/record-board/states/isRecordBoardFetchingRecordsByColumnFamilyState';
Expand Down Expand Up @@ -51,14 +49,6 @@ export const useRecordBoardStates = (recordBoardId?: string) => {
recordBoardColumnIdsComponentState,
scopeId,
),
isFirstColumnFamilyState: extractComponentFamilyState(
isFirstRecordBoardColumnComponentFamilyState,
scopeId,
),
isLastColumnFamilyState: extractComponentFamilyState(
isLastRecordBoardColumnComponentFamilyState,
scopeId,
),
columnsFamilySelector: extractComponentFamilyState(
recordBoardColumnsComponentFamilySelector,
scopeId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import { useRecoilCallback } from 'recoil';

import { useRecordBoardStates } from '@/object-record/record-board/hooks/internal/useRecordBoardStates';
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';

export const useSetRecordBoardColumns = (recordBoardId?: string) => {
const { scopeId, columnIdsState, columnsFamilySelector } =
useRecordBoardStates(recordBoardId);

const setColumns = useRecoilCallback(
({ set, snapshot }) =>
(columns: RecordBoardColumnDefinition[]) => {
(columns: RecordGroupDefinition[]) => {
const currentColumnsIds = snapshot
.getLoadable(columnIdsState)
.getValue();

const columnIds = columns.map(({ id }) => id);
const columnIds = columns
.filter(({ isVisible }) => isVisible)
.map(({ id }) => id);

if (isDeeplyEqual(currentColumnsIds, columnIds)) {
return;
}

set(
columnIdsState,
columns.map((column) => column.id),
);
set(columnIdsState, columnIds);
magrinj marked this conversation as resolved.
Show resolved Hide resolved

columns.forEach((column) => {
const currentColumn = snapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import { RecordBoardColumnCardsContainer } from '@/object-record/record-board/re
import { RecordBoardColumnHeader } from '@/object-record/record-board/record-board-column/components/RecordBoardColumnHeader';
import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext';

const StyledColumn = styled.div<{ isFirstColumn: boolean }>`
const StyledColumn = styled.div`
background-color: ${({ theme }) => theme.background.primary};
border-left: 1px solid
${({ theme, isFirstColumn }) =>
isFirstColumn ? 'none' : theme.border.color.light};
display: flex;
flex-direction: column;
max-width: 200px;
Expand All @@ -23,29 +20,19 @@ const StyledColumn = styled.div<{ isFirstColumn: boolean }>`

type RecordBoardColumnProps = {
recordBoardColumnId: string;
__indexDebug: number;
magrinj marked this conversation as resolved.
Show resolved Hide resolved
};

export const RecordBoardColumn = ({
recordBoardColumnId,
__indexDebug,
}: RecordBoardColumnProps) => {
const {
isFirstColumnFamilyState,
isLastColumnFamilyState,
columnsFamilySelector,
recordIdsByColumnIdFamilyState,
} = useRecordBoardStates();
const { columnsFamilySelector, recordIdsByColumnIdFamilyState } =
useRecordBoardStates();
const columnDefinition = useRecoilValue(
columnsFamilySelector(recordBoardColumnId),
);

const isFirstColumn = useRecoilValue(
isFirstColumnFamilyState(recordBoardColumnId),
);

const isLastColumn = useRecoilValue(
isLastColumnFamilyState(recordBoardColumnId),
);

const recordIds = useRecoilValue(
recordIdsByColumnIdFamilyState(recordBoardColumnId),
);
Expand All @@ -58,14 +45,12 @@ export const RecordBoardColumn = ({
<RecordBoardColumnContext.Provider
value={{
columnDefinition: columnDefinition,
isFirstColumn: isFirstColumn,
isLastColumn: isLastColumn,
recordCount: recordIds.length,
}}
>
<Droppable droppableId={recordBoardColumnId}>
{(droppableProvided) => (
<StyledColumn isFirstColumn={isFirstColumn}>
<StyledColumn>
<RecordBoardColumnHeader />
<RecordBoardColumnCardsContainer
droppableProvided={droppableProvided}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from '@emotion/styled';
import { useCallback, useContext, useRef } from 'react';
import { useCallback, useRef } from 'react';

import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext';
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
import { useRecordGroupActions } from '@/object-record/record-group/hooks/useRecordGroupActions';

const StyledMenuContainer = styled.div`
position: absolute;
Expand All @@ -25,6 +25,8 @@ export const RecordBoardColumnDropdownMenu = ({
}: RecordBoardColumnDropdownMenuProps) => {
const boardColumnMenuRef = useRef<HTMLDivElement>(null);

const recordGroupActions = useRecordGroupActions();

const closeMenu = useCallback(() => {
onClose();
}, [onClose]);
Expand All @@ -34,13 +36,11 @@ export const RecordBoardColumnDropdownMenu = ({
callback: closeMenu,
});

const { columnDefinition } = useContext(RecordBoardColumnContext);

return (
<StyledMenuContainer ref={boardColumnMenuRef}>
<DropdownMenu data-select-disable>
<DropdownMenuItemsContainer>
{columnDefinition.actions.map((action) => (
{recordGroupActions.map((action) => (
<MenuItem
key={action.id}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { RecordBoardColumnContext } from '@/object-record/record-board/record-bo
import { useColumnNewCardActions } from '@/object-record/record-board/record-board-column/hooks/useColumnNewCardActions';
import { useIsOpportunitiesCompanyFieldDisabled } from '@/object-record/record-board/record-board-column/hooks/useIsOpportunitiesCompanyFieldDisabled';
import { RecordBoardColumnHotkeyScope } from '@/object-record/record-board/types/BoardColumnHotkeyScope';
import { RecordBoardColumnDefinitionType } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { SingleEntitySelect } from '@/object-record/relation-picker/components/SingleEntitySelect';
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { RecordGroupDefinitionType } from '@/object-record/record-group/types/RecordGroupDefinition';

const StyledHeader = styled.div`
align-items: center;
Expand Down Expand Up @@ -113,18 +113,18 @@ export const RecordBoardColumnHeader = () => {
<Tag
onClick={handleBoardColumnMenuOpen}
variant={
columnDefinition.type === RecordBoardColumnDefinitionType.Value
columnDefinition.type === RecordGroupDefinitionType.Value
? 'solid'
: 'outline'
}
color={
columnDefinition.type === RecordBoardColumnDefinitionType.Value
columnDefinition.type === RecordGroupDefinitionType.Value
? columnDefinition.color
: 'transparent'
}
text={columnDefinition.title}
weight={
columnDefinition.type === RecordBoardColumnDefinitionType.Value
columnDefinition.type === RecordGroupDefinitionType.Value
? 'regular'
: 'medium'
}
Expand All @@ -137,13 +137,11 @@ export const RecordBoardColumnHeader = () => {
<StyledRightContainer>
{isHeaderHovered && (
<StyledHeaderActions>
{columnDefinition.actions.length > 0 && (
<LightIconButton
accent="tertiary"
Icon={IconDotsVertical}
onClick={handleBoardColumnMenuOpen}
/>
)}
<LightIconButton
accent="tertiary"
Icon={IconDotsVertical}
onClick={handleBoardColumnMenuOpen}
/>

<LightIconButton
accent="tertiary"
Expand All @@ -155,7 +153,7 @@ export const RecordBoardColumnHeader = () => {
</StyledRightContainer>
</StyledHeaderContainer>
</StyledHeader>
{isBoardColumnMenuOpen && columnDefinition.actions.length > 0 && (
{isBoardColumnMenuOpen && (
<RecordBoardColumnDropdownMenu
onClose={handleBoardColumnMenuClose}
stageId={columnDefinition.id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { createContext } from 'react';

import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';

type RecordBoardColumnContextProps = {
columnDefinition: RecordBoardColumnDefinition;
isFirstColumn: boolean;
isLastColumn: boolean;
columnDefinition: RecordGroupDefinition;
recordCount: number;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ReactNode } from 'react';

import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext';
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';

type RecordBoardScopeProps = {
children: ReactNode;
recordBoardScopeId: string;
onFieldsChange: (fields: FieldDefinition<FieldMetadata>[]) => void;
onColumnsChange: (column: RecordBoardColumnDefinition[]) => void;
onColumnsChange: (column: RecordGroupDefinition[]) => void;
};

export const RecordBoardScope = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey';

type RecordBoardScopeInternalContextProps = RecoilComponentStateKey & {
onFieldsChange: (fields: FieldDefinition<FieldMetadata>[]) => void;
onColumnsChange: (column: RecordBoardColumnDefinition[]) => void;
onColumnsChange: (column: RecordGroupDefinition[]) => void;
};

export const RecordBoardScopeInternalContext =
Expand Down
magrinj marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';

export const recordBoardColumnsComponentFamilyState =
createComponentFamilyState<RecordBoardColumnDefinition | undefined, string>({
createComponentFamilyState<RecordGroupDefinition | undefined, string>({
key: 'recordBoardColumnsComponentFamilyState',
defaultValue: undefined,
});
Loading
Loading