Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(tasks): clear the project when the selected one is clicked again (#9112)

gbirman0f37e56a0c84
diff --git a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx
index 50295bff3c..97742b4feb 100644
--- a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx
+++ b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx
@@ -35,23 +35,41 @@ vi.mock('@core/component/UserIcon', () => ({ UserIcon: () => <span /> }));
vi.mock('@core/context/quickAccess', () => ({
useQuickAccess: () => ({
isLoading: () => false,
- useList: () => ({
- items: () => [
- {
- kind: 'user',
- id: 'macro|[email protected]',
- data: {
- id: 'macro|[email protected]',
- name: 'Alice',
- email: '[email protected]',
- },
- },
- ],
+ useList: (...buckets: string[]) => ({
+ items: () =>
+ buckets.includes('initiative')
+ ? [
+ {
+ kind: 'initiative',
+ id: 'project-launch',
+ data: {
+ type: 'initiative',
+ id: 'project-launch',
+ name: 'Launch',
+ },
+ },
+ ]
+ : [
+ {
+ kind: 'user',
+ id: 'macro|[email protected]',
+ data: {
+ id: 'macro|[email protected]',
+ name: 'Alice',
+ email: '[email protected]',
+ },
+ },
+ ],
}),
}),
}));
vi.mock('@entity', () => ({
- Entity: {},
+ Entity: {
+ Icon: () => <span />,
+ Title: (props: { entity: { name: string } }) => (
+ <span>{props.entity.name}</span>
+ ),
+ },
isTaskEntity: () => false,
createEmailsInfiniteQuery: () => ({
data: [],
@@ -214,3 +232,25 @@ describe('assigning an agent through task and project properties', () => {
).toBeNull();
});
});
+
+describe('the Project property', () => {
+ it('clears the project when the selected project is clicked again', async () => {
+ const project: EntityProperty = {
+ ...property,
+ propertyId: 'project-property',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ isMultiSelect: false,
+ specificEntityType: 'INITIATIVE',
+ value: [{ entity_id: 'project-launch', entity_type: 'INITIATIVE' }],
+ };
+ const onSave = setup({ entityType: 'TASK', blockId: 'task-id' }, project);
+ fireEvent.click(screen.getByText('Launch'));
+ await waitFor(() =>
+ expect(onSave).toHaveBeenCalledExactlyOnceWith(project, {
+ valueType: 'ENTITY',
+ refs: null,
+ })
+ );
+ });
+});
diff --git a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
index 23b02388de..0b22bf1289 100644
--- a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
+++ b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
@@ -359,7 +359,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
}
} else {
newSelected.clear();
- newSelected.add(entity.id);
+ if (!isCurrentlySelected) newSelected.add(entity.id);
}
props.setSelectedOptions(newSelected, [