The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Open link in new tab and added cell url (#782)
Lucas Bordeaubf41182810b4
diff --git a/front/src/modules/companies/table/components/EditableCompanyDomainNameCell.tsx b/front/src/modules/companies/table/components/EditableCompanyDomainNameCell.tsxindex 2b12dcf792a..3accda9f394 100644--- a/front/src/modules/companies/table/components/EditableCompanyDomainNameCell.tsx+++ b/front/src/modules/companies/table/components/EditableCompanyDomainNameCell.tsx@@ -2,10 +2,11 @@ import { useEffect, useState } from 'react';import { useRecoilValue } from 'recoil';import { companyDomainNameFamilyState } from '@/companies/states/companyDomainNameFamilyState';-import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText';import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';import { useUpdateOneCompanyMutation } from '~/generated/graphql';+import { EditableCellURL } from '../../../ui/table/editable-cell/types/EditableCellURL';+export function EditableCompanyDomainNameCell() {const currentRowEntityId = useCurrentRowEntityId();@@ -20,8 +21,8 @@ export function EditableCompanyDomainNameCell() {}, [name]);return (- <EditableCellText- value={internalValue}+ <EditableCellURL+ url={internalValue}onChange={setInternalValue}onSubmit={() =>updateCompany({diff --git a/front/src/modules/ui/link/components/RawLink.tsx b/front/src/modules/ui/link/components/RawLink.tsxindex b0d3973542e..e9be8d2f92c 100644--- a/front/src/modules/ui/link/components/RawLink.tsx+++ b/front/src/modules/ui/link/components/RawLink.tsx@@ -20,7 +20,7 @@ const StyledClickable = styled.div`export function RawLink({ className, href, children, onClick }: OwnProps) {return (<StyledClickable className={className}>- <ReactLink onClick={onClick} to={href}>+ <ReactLink target="_blank" onClick={onClick} to={href}>{children}</ReactLink></StyledClickable>diff --git a/front/src/modules/ui/table/editable-cell/types/EditableCellURL.tsx b/front/src/modules/ui/table/editable-cell/types/EditableCellURL.tsxnew file mode 100644index 00000000000..0390d8f77ad--- /dev/null+++ b/front/src/modules/ui/table/editable-cell/types/EditableCellURL.tsx@@ -0,0 +1,64 @@+import { ChangeEvent, useEffect, useState } from 'react';++import { InplaceInputTextEditMode } from '@/ui/inplace-input/components/InplaceInputTextEditMode';++import { RawLink } from '../../../link/components/RawLink';+import { CellSkeleton } from '../components/CellSkeleton';+import { EditableCell } from '../components/EditableCell';++type OwnProps = {+ placeholder?: string;+ url: string;+ onChange: (newURL: string) => void;+ editModeHorizontalAlign?: 'left' | 'right';+ loading?: boolean;+ onSubmit?: () => void;+ onCancel?: () => void;+};++export function EditableCellURL({+ url,+ placeholder,+ onChange,+ editModeHorizontalAlign,+ loading,+ onCancel,+ onSubmit,+}: OwnProps) {+ const [internalValue, setInternalValue] = useState(url);++ useEffect(() => {+ setInternalValue(url);+ }, [url]);++ return (+ <EditableCell+ editModeHorizontalAlign={editModeHorizontalAlign}+ editModeContent={+ <InplaceInputTextEditMode+ placeholder={placeholder || ''}+ autoFocus+ value={internalValue}+ onChange={(event: ChangeEvent<HTMLInputElement>) => {+ setInternalValue(event.target.value);+ onChange(event.target.value);+ }}+ />+ }+ onSubmit={onSubmit}+ onCancel={onCancel}+ nonEditModeContent={+ loading ? (+ <CellSkeleton />+ ) : (+ <RawLink+ onClick={(e) => e.stopPropagation()}+ href={internalValue ? 'https://' + internalValue : ''}+ >+ {internalValue}+ </RawLink>+ )+ }+ ></EditableCell>+ );+}