forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/generic editable cell chip (twentyhq#982)
* Added generic relation cell * Deactivated debug * Added default warning * Put back display component * Removed unused types * wip * Renamed to view field * Use new view field structure to have chip working * Finished * Added a temp feature flag
- Loading branch information
1 parent
dda3fa8
commit ec4fda0
Showing
30 changed files
with
416 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
front/src/modules/companies/constants/companyFieldMetadataArray.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { IconBuildingSkyscraper } from '@tabler/icons-react'; | ||
|
||
import { Entity } from '@/ui/relation-picker/types/EntityTypeForSelect'; | ||
import { | ||
ViewFieldChipMetadata, | ||
ViewFieldDefinition, | ||
} from '@/ui/table/types/ViewField'; | ||
|
||
export const companyViewFields: ViewFieldDefinition<unknown>[] = [ | ||
{ | ||
columnLabel: 'Name', | ||
columnIcon: <IconBuildingSkyscraper size={16} />, | ||
columnSize: 150, | ||
type: 'chip', | ||
columnOrder: 1, | ||
metadata: { | ||
urlFieldName: 'domainName', | ||
contentFieldName: 'name', | ||
relationType: Entity.Company, | ||
}, | ||
} as ViewFieldDefinition<ViewFieldChipMetadata>, | ||
]; |
54 changes: 54 additions & 0 deletions
54
front/src/modules/companies/table/components/CompanyTableV2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useCallback, useMemo, useState } from 'react'; | ||
|
||
import { companyViewFields } from '@/companies/constants/companyFieldMetadataArray'; | ||
import { CompaniesSelectedSortType, defaultOrderBy } from '@/companies/queries'; | ||
import { GenericEntityTableData } from '@/people/components/GenericEntityTableData'; | ||
import { reduceSortsToOrderBy } from '@/ui/filter-n-sort/helpers'; | ||
import { filtersScopedState } from '@/ui/filter-n-sort/states/filtersScopedState'; | ||
import { turnFilterIntoWhereClause } from '@/ui/filter-n-sort/utils/turnFilterIntoWhereClause'; | ||
import { IconList } from '@/ui/icon'; | ||
import { useRecoilScopedValue } from '@/ui/recoil-scope/hooks/useRecoilScopedValue'; | ||
import { EntityTable } from '@/ui/table/components/EntityTableV2'; | ||
import { TableContext } from '@/ui/table/states/TableContext'; | ||
import { | ||
CompanyOrderByWithRelationInput, | ||
useGetCompaniesQuery, | ||
useUpdateOneCompanyMutation, | ||
} from '~/generated/graphql'; | ||
import { companiesFilters } from '~/pages/companies/companies-filters'; | ||
import { availableSorts } from '~/pages/companies/companies-sorts'; | ||
|
||
export function CompanyTable() { | ||
const [orderBy, setOrderBy] = | ||
useState<CompanyOrderByWithRelationInput[]>(defaultOrderBy); | ||
|
||
const updateSorts = useCallback((sorts: Array<CompaniesSelectedSortType>) => { | ||
setOrderBy(sorts.length ? reduceSortsToOrderBy(sorts) : defaultOrderBy); | ||
}, []); | ||
|
||
const filters = useRecoilScopedValue(filtersScopedState, TableContext); | ||
|
||
const whereFilters = useMemo(() => { | ||
return { AND: filters.map(turnFilterIntoWhereClause) }; | ||
}, [filters]) as any; | ||
|
||
return ( | ||
<> | ||
<GenericEntityTableData | ||
getRequestResultKey="companies" | ||
useGetRequest={useGetCompaniesQuery} | ||
orderBy={orderBy} | ||
whereFilters={whereFilters} | ||
viewFields={companyViewFields} | ||
filterDefinitionArray={companiesFilters} | ||
/> | ||
<EntityTable | ||
viewName="All Companies" | ||
viewIcon={<IconList size={16} />} | ||
availableSorts={availableSorts} | ||
onSortsUpdate={updateSorts} | ||
useUpdateEntityMutation={useUpdateOneCompanyMutation} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.