Skip to content

Commit

Permalink
Merge pull request #782 from invoiceninja/develop
Browse files Browse the repository at this point in the history
Sync develop and main
  • Loading branch information
beganovich authored Jun 16, 2023
2 parents a0b5ff6 + 2b858fa commit 4962958
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 63 deletions.
4 changes: 1 addition & 3 deletions src/components/forms/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,7 @@ export function ComboboxAsync<T = any>({

const onEmptyValues = (query: string) => {
setUrl((current) => {
if (query.length > 0 && current) {
current.searchParams.set('filter', query);
}
current.searchParams.set('filter', query);

return new URL(current.href);
});
Expand Down
67 changes: 27 additions & 40 deletions src/components/forms/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { DebounceInput } from 'react-debounce-input';
import { AiFillEye, AiFillEyeInvisible } from 'react-icons/ai';
import CommonProps from '../../common/interfaces/common-props.interface';
import { InputLabel } from './InputLabel';
import { DatePicker } from '$app/components/forms/Datepicker';

interface Props extends CommonProps {
label?: string | null;
Expand Down Expand Up @@ -64,45 +63,33 @@ export function InputField(props: Props) {
)}

<div className="relative">
{props.type === 'date' ? (
<DatePicker
id={props.id}
required={props.required}
value={props.value}
onChange={props.onChange}
onValueChange={props.onValueChange}
disabled={props.disabled}
minDate={props.min}
/>
) : (
<DebounceInput
min={props.min}
maxLength={props.maxLength}
disabled={props.disabled}
element={props.element || 'input'}
inputRef={props.innerRef}
debounceTimeout={props.debounceTimeout ?? 300}
required={props.required}
id={props.id}
type={inputType}
className={classNames(
`w-full py-2 px-3 rounded text-sm text-gray-900 dark:bg-gray-800 dark:border-transparent dark:text-gray-100 disabled:bg-gray-100 disabled:cursor-not-allowed ${props.className}`,
{
'border border-gray-300': props.border !== false,
}
)}
placeholder={props.placeholder || ''}
onChange={(event) => {
props.onValueChange && props.onValueChange(event.target.value);
props.onChange && props.onChange(event);
}}
value={props.value}
list={props.list}
rows={props.textareaRows || 5}
step={props.step}
data-cy={props.cypressRef}
/>
)}
<DebounceInput
min={props.min}
maxLength={props.maxLength}
disabled={props.disabled}
element={props.element || 'input'}
inputRef={props.innerRef}
debounceTimeout={props.debounceTimeout ?? 300}
required={props.required}
id={props.id}
type={inputType}
className={classNames(
`w-full py-2 px-3 rounded text-sm text-gray-900 dark:bg-gray-800 dark:border-transparent dark:text-gray-100 disabled:bg-gray-100 disabled:cursor-not-allowed ${props.className}`,
{
'border border-gray-300': props.border !== false,
}
)}
placeholder={props.placeholder || ''}
onChange={(event) => {
props.onValueChange && props.onValueChange(event.target.value);
props.onChange && props.onChange(event);
}}
value={props.value}
list={props.list}
rows={props.textareaRows || 5}
step={props.step}
data-cy={props.cypressRef}
/>

{isInitialTypePassword && (
<span className="absolute top-1/4 right-3 cursor-pointer">
Expand Down
1 change: 1 addition & 0 deletions src/pages/credits/edit/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default function Edit() {
onContactCheckboxChange={handleInvitationChange}
errorMessage={errors?.errors.client_id}
readonly
textOnly
/>

<CreditDetails handleChange={handleChange} errors={errors} />
Expand Down
59 changes: 41 additions & 18 deletions src/pages/invoices/common/components/ClientSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ChangeEvent, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ClientSelector as Selector } from '$app/components/clients/ClientSelector';
import { route } from '$app/common/helpers/route';
import { useHasPermission } from '$app/common/hooks/permissions/useHasPermission';

interface Props {
readonly?: boolean;
Expand All @@ -27,6 +28,7 @@ interface Props {
onContactCheckboxChange: (contactId: string, value: boolean) => unknown;
errorMessage?: string | string[];
disableWithSpinner?: boolean;
textOnly?: boolean;
}

export function ClientSelector(props: Props) {
Expand All @@ -52,32 +54,53 @@ export function ClientSelector(props: Props) {
.then((client) => setClient(client));
}, [resource?.client_id]);

const hasPermission = useHasPermission();

return (
<Card className="col-span-12 xl:col-span-4 h-max" withContainer>
<div className="flex flex-col justify-between space-y-2">
<Selector
inputLabel={t('client')}
onChange={(client) => props.onChange(client.id)}
value={resource?.client_id}
readonly={props.readonly || !resource}
clearButton={Boolean(resource?.client_id)}
onClearButtonClick={props.onClearButtonClick}
initiallyVisible={!resource?.client_id}
errorMessage={props.errorMessage}
disableWithSpinner={props.disableWithSpinner}
/>
{hasPermission('view_client') ? (
props.textOnly ? (
<p className="text-gray-900 text-sm">
{resource?.client?.display_name}
</p>
) : (
<Selector
inputLabel={t('client')}
onChange={(client) => props.onChange(client.id)}
value={resource?.client_id}
readonly={props.readonly || !resource}
clearButton={Boolean(resource?.client_id)}
onClearButtonClick={props.onClearButtonClick}
initiallyVisible={!resource?.client_id}
errorMessage={props.errorMessage}
disableWithSpinner={props.disableWithSpinner}
/>
)
) : (
<p className="text-gray-900 text-sm">
{resource?.client?.display_name}
</p>
)}

{client && (
<div className="space-x-2">
<Link to={route('/clients/:id/edit', { id: client.id })}>
{t('edit_client')}
</Link>
{hasPermission('edit_client') && (
<Link to={route('/clients/:id/edit', { id: client.id })}>
{t('edit_client')}
</Link>
)}

<span className="text-sm text-gray-800">/</span>
{hasPermission('view_client') ||
(hasPermission('edit_client') && (
<span className="text-sm text-gray-800">/</span>
))}

<Link to={route('/clients/:id', { id: client.id })}>
{t('view_client')}
</Link>
{hasPermission('view_client') && (
<Link to={route('/clients/:id', { id: client.id })}>
{t('view_client')}
</Link>
)}
</div>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/invoices/edit/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default function Edit() {
onClearButtonClick={() => handleChange('client_id', '')}
onContactCheckboxChange={handleInvitationChange}
errorMessage={errors?.errors.client_id}
textOnly
readonly
/>

Expand Down
1 change: 1 addition & 0 deletions src/pages/quotes/edit/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default function Edit() {
onClearButtonClick={() => handleChange('client_id', '')}
onContactCheckboxChange={handleInvitationChange}
errorMessage={errors?.errors.client_id}
textOnly
readonly
/>

Expand Down
1 change: 1 addition & 0 deletions src/pages/recurring-invoices/edit/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export default function Edit() {
onClearButtonClick={() => handleChange('client_id', '')}
onContactCheckboxChange={handleInvitationChange}
errorMessage={errors?.errors.client_id}
textOnly
readonly
/>

Expand Down
4 changes: 2 additions & 2 deletions src/pages/settings/account-management/component/Plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license https://www.elastic.co/licensing/elastic-license
*/

import { date, isHosted, isSelfHosted } from '$app/common/helpers';
import { date, isDemo, isHosted, isSelfHosted } from '$app/common/helpers';
import { useCurrentAccount } from '$app/common/hooks/useCurrentAccount';
import { useCurrentCompanyDateFormats } from '$app/common/hooks/useCurrentCompanyDateFormats';
import { useCurrentUser } from '$app/common/hooks/useCurrentUser';
Expand Down Expand Up @@ -54,7 +54,7 @@ export function Plan() {
</Element>
)}

{isSelfHosted() && <License />}
{isSelfHosted() && !isDemo() && <License />}
</Card>
);
}

0 comments on commit 4962958

Please sign in to comment.