Skip to content

Commit

Permalink
Tag current board as deprecated to make room for the new record board…
Browse files Browse the repository at this point in the history
… implementation (#3601)
  • Loading branch information
charlesBochet authored Jan 24, 2024
1 parent e54c141 commit f48814f
Show file tree
Hide file tree
Showing 93 changed files with 449 additions and 426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import styled from '@emotion/styled';
import { mapBoardFieldDefinitionsToViewFields } from '@/companies/utils/mapBoardFieldDefinitionsToViewFields';
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import {
RecordBoard,
RecordBoardProps,
} from '@/object-record/record-board/components/RecordBoard';
import { RecordBoardEffect } from '@/object-record/record-board/components/RecordBoardEffect';
import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId';
import { RecordBoardOptionsDropdown } from '@/object-record/record-board/options/components/RecordBoardOptionsDropdown';
import { BoardColumnDefinition } from '@/object-record/record-board/types/BoardColumnDefinition';
RecordBoardDeprecated,
RecordBoardDeprecatedProps,
} from '@/object-record/record-board-deprecated/components/RecordBoardDeprecated';
import { RecordBoardDeprecatedEffect } from '@/object-record/record-board-deprecated/components/RecordBoardDeprecatedEffect';
import { BoardOptionsDropdownId } from '@/object-record/record-board-deprecated/constants/BoardOptionsDropdownId';
import { RecordBoardDeprecatedOptionsDropdown } from '@/object-record/record-board-deprecated/options/components/RecordBoardDeprecatedOptionsDropdown';
import { BoardColumnDefinition } from '@/object-record/record-board-deprecated/types/BoardColumnDefinition';
import { ViewBar } from '@/views/components/ViewBar';
import { useViewFields } from '@/views/hooks/internal/useViewFields';
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
Expand All @@ -26,7 +26,7 @@ const StyledContainer = styled.div`
`;

type CompanyBoardProps = Pick<
RecordBoardProps,
RecordBoardDeprecatedProps,
'onColumnAdd' | 'onColumnDelete' | 'onEditColumnTitle'
>;

Expand Down Expand Up @@ -61,7 +61,7 @@ export const CompanyBoard = ({
<ViewBar
viewBarId={viewBarId}
optionsDropdownButton={
<RecordBoardOptionsDropdown
<RecordBoardDeprecatedOptionsDropdown
recordBoardId={recordBoardId}
onStageAdd={onStageAdd}
/>
Expand All @@ -73,14 +73,14 @@ export const CompanyBoard = ({
viewBarId={viewBarId}
recordBoardId={recordBoardId}
/>
<RecordBoardEffect
<RecordBoardDeprecatedEffect
recordBoardId={recordBoardId}
onFieldsChange={(fields) => {
persistViewFields(mapBoardFieldDefinitionsToViewFields(fields));
}}
/>

<RecordBoard
<RecordBoardDeprecated
recordBoardId={recordBoardId}
boardOptions={opportunitiesBoardOptions}
onColumnAdd={onColumnAdd}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
RecordUpdateHookParams,
} from '@/object-record/field/contexts/FieldContext';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { BoardCardIdContext } from '@/object-record/record-board/contexts/BoardCardIdContext';
import { useCurrentRecordBoardCardSelectedInternal } from '@/object-record/record-board/hooks/internal/useCurrentRecordBoardCardSelectedInternal';
import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { isRecordBoardCardInCompactViewFamilyState } from '@/object-record/record-board/states/isRecordBoardCardInCompactViewFamilyState';
import { BoardCardIdContext } from '@/object-record/record-board-deprecated/contexts/BoardCardIdContext';
import { useCurrentRecordBoardDeprecatedCardSelectedInternal } from '@/object-record/record-board-deprecated/hooks/internal/useCurrentRecordBoardDeprecatedCardSelectedInternal';
import { useRecordBoardDeprecatedScopedStates } from '@/object-record/record-board-deprecated/hooks/internal/useRecordBoardDeprecatedScopedStates';
import { isRecordBoardDeprecatedCardInCompactViewFamilyState } from '@/object-record/record-board-deprecated/states/isRecordBoardDeprecatedCardInCompactViewFamilyState';
import { RecordInlineCell } from '@/object-record/record-inline-cell/components/RecordInlineCell';
import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/InlineCellHotkeyScope';
import { EntityChipVariant } from '@/ui/display/chip/components/EntityChip';
Expand Down Expand Up @@ -128,20 +128,20 @@ const StyledCompactIconContainer = styled.div`

export const CompanyBoardCard = () => {
const { isCurrentCardSelected, setCurrentCardSelected } =
useCurrentRecordBoardCardSelectedInternal();
useCurrentRecordBoardDeprecatedCardSelectedInternal();
const boardCardId = useContext(BoardCardIdContext);

const [companyProgress] = useRecoilState(
companyProgressesFamilyState(boardCardId ?? ''),
);

const { isCompactViewEnabledState, visibleBoardCardFieldsSelector } =
useRecordBoardScopedStates();
useRecordBoardDeprecatedScopedStates();

const [isCompactViewEnabled] = useRecoilState(isCompactViewEnabledState);

const [isCardInCompactView, setIsCardInCompactView] = useRecoilState(
isRecordBoardCardInCompactViewFamilyState(boardCardId ?? ''),
isRecordBoardDeprecatedCardInCompactViewFamilyState(boardCardId ?? ''),
);

const showCompactView = isCompactViewEnabled && isCardInCompactView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useRecoilValue } from 'recoil';
import { useColumnDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useColumnDefinitionsFromFieldMetadata';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { availableRecordBoardCardFieldsScopedState } from '@/object-record/record-board/states/availableRecordBoardCardFieldsScopedState';
import { recordBoardCardFieldsScopedState } from '@/object-record/record-board/states/recordBoardCardFieldsScopedState';
import { recordBoardFiltersScopedState } from '@/object-record/record-board/states/recordBoardFiltersScopedState';
import { recordBoardSortsScopedState } from '@/object-record/record-board/states/recordBoardSortsScopedState';
import { useRecordBoardDeprecatedScopedStates } from '@/object-record/record-board-deprecated/hooks/internal/useRecordBoardDeprecatedScopedStates';
import { availableRecordBoardDeprecatedCardFieldsScopedState } from '@/object-record/record-board-deprecated/states/availableRecordBoardDeprecatedCardFieldsScopedState';
import { recordBoardCardFieldsScopedState } from '@/object-record/record-board-deprecated/states/recordBoardDeprecatedCardFieldsScopedState';
import { recordBoardFiltersScopedState } from '@/object-record/record-board-deprecated/states/recordBoardDeprecatedFiltersScopedState';
import { recordBoardSortsScopedState } from '@/object-record/record-board-deprecated/states/recordBoardDeprecatedSortsScopedState';
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
import { useSetRecoilScopedStateV2 } from '@/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2';
import { useViewScopedStates } from '@/views/hooks/internal/useViewScopedStates';
Expand Down Expand Up @@ -41,7 +41,7 @@ export const HooksCompanyBoardEffect = ({
useColumnDefinitionsFromFieldMetadata(objectMetadataItem);

const setAvailableBoardCardFields = useSetRecoilScopedStateV2(
availableRecordBoardCardFieldsScopedState,
availableRecordBoardDeprecatedCardFieldsScopedState,
'company-board',
);

Expand Down Expand Up @@ -128,7 +128,7 @@ export const HooksCompanyBoardEffect = ({

const { setEntityCountInCurrentView } = useViewBar({ viewBarId });

const { savedOpportunitiesState } = useRecordBoardScopedStates({
const { savedOpportunitiesState } = useRecordBoardDeprecatedScopedStates({
recordBoardScopeId: recordBoardId,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useCallback, useContext, useState } from 'react';

import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { NewButton } from '@/object-record/record-board/components/NewButton';
import { BoardColumnContext } from '@/object-record/record-board/contexts/BoardColumnContext';
import { useCreateOpportunity } from '@/object-record/record-board/hooks/internal/useCreateOpportunity';
import { NewButton } from '@/object-record/record-board-deprecated/components/NewButton';
import { BoardColumnContext } from '@/object-record/record-board-deprecated/contexts/BoardColumnContext';
import { useCreateOpportunity } from '@/object-record/record-board-deprecated/hooks/internal/useCreateOpportunity';
import { SingleEntitySelect } from '@/object-record/relation-picker/components/SingleEntitySelect';
import { useRelationPicker } from '@/object-record/relation-picker/hooks/useRelationPicker';
import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types/RelationPickerHotkeyScope';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mapBoardFieldDefinitionsToViewFields } from '@/companies/utils/mapBoardFieldDefinitionsToViewFields';
import { FieldMetadata } from '@/object-record/field/types/FieldMetadata';
import { BoardFieldDefinition } from '@/object-record/record-board/types/BoardFieldDefinition';
import { BoardFieldDefinition } from '@/object-record/record-board-deprecated/types/BoardFieldDefinition';

describe('mapBoardFieldDefinitionsToViewFields', () => {
it('should map board field definitions to view fields', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FieldMetadata } from '@/object-record/field/types/FieldMetadata';
import { BoardFieldDefinition } from '@/object-record/record-board/types/BoardFieldDefinition';
import { BoardFieldDefinition } from '@/object-record/record-board-deprecated/types/BoardFieldDefinition';
import { ViewField } from '@/views/types/ViewField';

export const mapBoardFieldDefinitionsToViewFields = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import { MockedProvider } from '@apollo/client/testing';
import { renderHook } from '@testing-library/react';
import { RecoilRoot } from 'recoil';

import { useObjectRecordBoard } from '@/object-record/hooks/useObjectRecordBoard';
import { RecordBoardScope } from '@/object-record/record-board/scopes/RecordBoardScope';
import { useObjectRecordBoardDeprecated } from '@/object-record/hooks/useObjectRecordBoardDeprecated';
import { RecordBoardDeprecatedScope } from '@/object-record/record-board-deprecated/scopes/RecordBoardDeprecatedScope';
import { SnackBarProviderScope } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarProviderScope';

const recordBoardId = '783932a0-28c7-4607-b2ce-6543fa2be892';

const Wrapper = ({ children }: { children: ReactNode }) => (
<RecoilRoot>
<RecordBoardScope recordBoardScopeId={recordBoardId}>
<RecordBoardDeprecatedScope recordBoardScopeId={recordBoardId}>
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager">
<MockedProvider addTypename={false}>{children}</MockedProvider>
</SnackBarProviderScope>
</RecordBoardScope>
</RecordBoardDeprecatedScope>
</RecoilRoot>
);

describe('useObjectRecordBoard', () => {
describe('useObjectRecordBoardDeprecated', () => {
it('should skip fetch if currentWorkspace is undefined', async () => {
const { result } = renderHook(() => useObjectRecordBoard(), {
const { result } = renderHook(() => useObjectRecordBoardDeprecated(), {
wrapper: Wrapper,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Company } from '@/companies/types/Company';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy';
import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { useRecordBoardDeprecatedScopedStates } from '@/object-record/record-board-deprecated/hooks/internal/useRecordBoardDeprecatedScopedStates';
import { turnObjectDropdownFilterIntoQueryFilter } from '@/object-record/record-filter/utils/turnObjectDropdownFilterIntoQueryFilter';
import { ObjectRecordConnection } from '@/object-record/types/ObjectRecordConnection';
import { Opportunity } from '@/pipeline/types/Opportunity';
import { PipelineStep } from '@/pipeline/types/PipelineStep';

import { useFindManyRecords } from './useFindManyRecords';

export const useObjectRecordBoard = () => {
export const useObjectRecordBoardDeprecated = () => {
const objectNameSingular = 'opportunity';

const { objectMetadataItem: foundObjectMetadataItem } = useObjectMetadataItem(
Expand All @@ -29,7 +29,7 @@ export const useObjectRecordBoard = () => {
savedCompaniesState,
savedOpportunitiesState,
savedPipelineStepsState,
} = useRecordBoardScopedStates();
} = useRecordBoardDeprecatedScopedStates();

const setIsBoardLoaded = useSetRecoilState(isBoardLoadedState);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { useRecoilValue } from 'recoil';

import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { useRecordBoardDeprecatedScopedStates } from '@/object-record/record-board-deprecated/hooks/internal/useRecordBoardDeprecatedScopedStates';
import { ActionBar } from '@/ui/navigation/action-bar/components/ActionBar';

export const RecordBoardActionBar = () => {
const { selectedCardIdsSelector } = useRecordBoardScopedStates();
export const RecordBoardDeprecatedActionBar = () => {
const { selectedCardIdsSelector } = useRecordBoardDeprecatedScopedStates();
const selectedCardIds = useRecoilValue(selectedCardIdsSelector);
return <ActionBar selectedIds={selectedCardIds}></ActionBar>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { useRecoilValue } from 'recoil';

import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { RecordBoardActionBar } from '@/object-record/record-board/action-bar/components/RecordBoardActionBar';
import { RecordBoardInternalEffect } from '@/object-record/record-board/components/RecordBoardInternalEffect';
import { RecordBoardContextMenu } from '@/object-record/record-board/context-menu/components/RecordBoardContextMenu';
import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { useSetRecordBoardCardSelectedInternal } from '@/object-record/record-board/hooks/internal/useSetRecordBoardCardSelectedInternal';
import { RecordBoardScope } from '@/object-record/record-board/scopes/RecordBoardScope';
import { RecordBoardDeprecatedActionBar } from '@/object-record/record-board-deprecated/action-bar/components/RecordBoardDeprecatedActionBar';
import { RecordBoardDeprecatedInternalEffect } from '@/object-record/record-board-deprecated/components/RecordBoardDeprecatedInternalEffect';
import { RecordBoardDeprecatedContextMenu } from '@/object-record/record-board-deprecated/context-menu/components/RecordBoardDeprecatedContextMenu';
import { useRecordBoardDeprecatedScopedStates } from '@/object-record/record-board-deprecated/hooks/internal/useRecordBoardDeprecatedScopedStates';
import { useSetRecordBoardDeprecatedCardSelectedInternal } from '@/object-record/record-board-deprecated/hooks/internal/useSetRecordBoardDeprecatedCardSelectedInternal';
import { RecordBoardDeprecatedScope } from '@/object-record/record-board-deprecated/scopes/RecordBoardDeprecatedScope';
import { Opportunity } from '@/pipeline/types/Opportunity';
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
import { DragSelect } from '@/ui/utilities/drag-select/components/DragSelect';
Expand All @@ -22,9 +22,9 @@ import { logError } from '~/utils/logError';
import { BoardColumnDefinition } from '../types/BoardColumnDefinition';
import { BoardOptions } from '../types/BoardOptions';

import { RecordBoardColumn } from './RecordBoardColumn';
import { RecordBoardDeprecatedColumn } from './RecordBoardDeprecatedColumn';

export type RecordBoardProps = {
export type RecordBoardDeprecatedProps = {
recordBoardId: string;
boardOptions: BoardOptions;
onColumnAdd?: (boardColumn: BoardColumnDefinition) => void;
Expand Down Expand Up @@ -59,15 +59,15 @@ const StyledBoardHeader = styled.div`
z-index: 1;
`;

export const RecordBoard = ({
export const RecordBoardDeprecated = ({
recordBoardId,
boardOptions,
onColumnDelete,
onEditColumnTitle,
}: RecordBoardProps) => {
}: RecordBoardDeprecatedProps) => {
const recordBoardScopeId = recordBoardId;

const { boardColumnsState } = useRecordBoardScopedStates({
const { boardColumnsState } = useRecordBoardDeprecatedScopedStates({
recordBoardScopeId,
});
const boardColumns = useRecoilValue(boardColumnsState);
Expand All @@ -78,7 +78,7 @@ export const RecordBoard = ({
});

const { unselectAllActiveCards, setCardSelected } =
useSetRecordBoardCardSelectedInternal({ recordBoardScopeId });
useSetRecordBoardDeprecatedCardSelectedInternal({ recordBoardScopeId });

const updatePipelineProgressStageInDB = useCallback(
async (pipelineProgressId: string, pipelineStepId: string) => {
Expand Down Expand Up @@ -136,18 +136,18 @@ export const RecordBoard = ({
);

return (
<RecordBoardScope recordBoardScopeId={recordBoardId}>
<RecordBoardContextMenu />
<RecordBoardActionBar />
<RecordBoardInternalEffect />
<RecordBoardDeprecatedScope recordBoardScopeId={recordBoardId}>
<RecordBoardDeprecatedContextMenu />
<RecordBoardDeprecatedActionBar />
<RecordBoardDeprecatedInternalEffect />

<StyledWrapper>
<StyledBoardHeader />
<ScrollWrapper>
<StyledBoard ref={boardRef}>
<DragDropContext onDragEnd={onDragEnd}>
{sortedBoardColumns.map((column) => (
<RecordBoardColumn
<RecordBoardDeprecatedColumn
key={column.id}
recordBoardColumnId={column.id}
columnDefinition={column}
Expand All @@ -165,6 +165,6 @@ export const RecordBoard = ({
onDragSelectionChange={setCardSelected}
/>
</StyledWrapper>
</RecordBoardScope>
</RecordBoardDeprecatedScope>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { useSetRecoilState } from 'recoil';
import { contextMenuIsOpenState } from '@/ui/navigation/context-menu/states/contextMenuIsOpenState';
import { contextMenuPositionState } from '@/ui/navigation/context-menu/states/contextMenuPositionState';

import { useCurrentRecordBoardCardSelectedInternal } from '../hooks/internal/useCurrentRecordBoardCardSelectedInternal';
import { useCurrentRecordBoardDeprecatedCardSelectedInternal } from '../hooks/internal/useCurrentRecordBoardDeprecatedCardSelectedInternal';
import { BoardOptions } from '../types/BoardOptions';

export const RecordBoardCard = ({
export const RecordBoardDeprecatedCard = ({
recordBoardOptions,
cardId,
index,
Expand All @@ -20,7 +20,7 @@ export const RecordBoardCard = ({
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);

const { setCurrentCardSelected } =
useCurrentRecordBoardCardSelectedInternal();
useCurrentRecordBoardDeprecatedCardSelectedInternal();

const handleContextMenu = (event: React.MouseEvent) => {
event.preventDefault();
Expand Down
Loading

0 comments on commit f48814f

Please sign in to comment.