Fix views reordering (#11431)

As per title
This commit is contained in:
Charles Bochet
2025-04-07 19:18:05 +02:00
committed by GitHub
parent 17b7e703b4
commit 20895f1129
3 changed files with 18 additions and 13 deletions

View File

@ -11,8 +11,8 @@ export const prefetchViewsFromObjectMetadataItemFamilySelector = selectorFamily<
({ objectMetadataItemId }) =>
({ get }) => {
const views = get(prefetchViewsState);
return views.filter(
(view) => view.objectMetadataId === objectMetadataItemId,
);
return views
.filter((view) => view.objectMetadataId === objectMetadataItemId)
.sort((a, b) => a.position - b.position);
},
});

View File

@ -20,9 +20,9 @@ import { viewPickerReferenceViewIdComponentState } from '@/views/view-picker/sta
import { useLingui } from '@lingui/react/macro';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared/utils';
import { moveArrayItem } from '~/utils/array/moveArrayItem';
import { IconPlus } from 'twenty-ui/display';
import { MenuItem } from 'twenty-ui/navigation';
import { moveArrayItem } from '~/utils/array/moveArrayItem';
const StyledBoldDropdownMenuItemsContainer = styled(DropdownMenuItemsContainer)`
font-weight: ${({ theme }) => theme.font.weight.regular};
@ -74,17 +74,21 @@ export const ViewPickerListContent = () => {
};
const handleDragEnd = useCallback(
(result: DropResult) => {
async (result: DropResult) => {
if (!result.destination) return;
moveArrayItem(viewsOnCurrentObject, {
const viewsReordered = moveArrayItem(viewsOnCurrentObject, {
fromIndex: result.source.index,
toIndex: result.destination.index,
}).forEach((view, index) => {
if (view.position !== index) {
updateView({ ...view, position: index });
}
});
Promise.all(
viewsReordered.map(async (view, index) => {
if (view.position !== index) {
await updateView({ ...view, position: index });
}
}),
);
},
[updateView, viewsOnCurrentObject],
);

View File

@ -181,6 +181,9 @@ export const ChooseYourPlan = () => {
? BillingPlanKey.ENTERPRISE
: BillingPlanKey.PRO;
const planName = plans?.plans.find((plan) => plan.planKey === currentPlan)
?.baseProduct.name;
return (
<>
{isDefined(baseProductPrice) && isDefined(billing) ? (
@ -191,9 +194,7 @@ export const ChooseYourPlan = () => {
: t`Get your subscription`}
</Title>
{hasWithoutCreditCardTrialPeriod ? (
<SubTitle>
<Trans>Cancel anytime</Trans>
</SubTitle>
<SubTitle>{planName}</SubTitle>
) : (
withCreditCardTrialPeriod && (
<SubTitle>