Skip to content

Commit 3abf679

Browse files
authored
Merge pull request #2262 from Civolilah/bugfix/default-quick-actions
[Bugfix] Removing Default Quick Actions
2 parents 9e2ff78 + e739b31 commit 3abf679

File tree

3 files changed

+4
-48
lines changed

3 files changed

+4
-48
lines changed

src/common/hooks/useCommonActions.ts

-29
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,3 @@ export function useAllCommonActions() {
124124

125125
return actions;
126126
}
127-
128-
export function useDefaultCommonActions() {
129-
const [t] = useTranslation();
130-
131-
const actions: Record<Entity, CommonAction[]> = {
132-
invoice: [
133-
{ value: 'mark_sent', label: t('mark_sent') },
134-
{ value: 'email_invoice', label: t('email_invoice') },
135-
],
136-
credit: [
137-
{ value: 'mark_sent', label: t('mark_sent') },
138-
{ value: 'email_credit', label: t('email_credit') },
139-
],
140-
quote: [
141-
{ value: 'mark_sent', label: t('mark_sent') },
142-
{ value: 'email_quote', label: t('email_quote') },
143-
],
144-
recurring_invoice: [
145-
{ value: 'start', label: t('start') },
146-
{ value: 'view_pdf', label: t('view_pdf') },
147-
],
148-
purchase_order: [
149-
{ value: 'send_email', label: t('send_email') },
150-
{ value: 'mark_sent', label: t('mark_sent') },
151-
],
152-
};
153-
154-
return actions;
155-
}

src/common/hooks/useShowActionByPreferences.ts

+2-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
import { Entity } from '$app/components/CommonActionsPreferenceModal';
12-
import { useDefaultCommonActions } from './useCommonActions';
1312
import { useEntityPageIdentifier } from './useEntityPageIdentifier';
1413
import { useCurrentUser } from './useCurrentUser';
1514

@@ -24,8 +23,6 @@ export function useShowActionByPreferences(params: Params) {
2423

2524
const { isEditPage } = useEntityPageIdentifier({ entity });
2625

27-
const defaultCommonActions = useDefaultCommonActions();
28-
2926
return (actionKey: string) => {
3027
if (!isEditPage) {
3128
return true;
@@ -34,7 +31,7 @@ export function useShowActionByPreferences(params: Params) {
3431
const commonActionsPreferences =
3532
user?.company_user?.react_settings.common_actions;
3633

37-
if (!commonActionsPreferences) {
34+
if (!commonActionsSection && !commonActionsPreferences?.[entity]) {
3835
return true;
3936
}
4037

@@ -46,24 +43,10 @@ export function useShowActionByPreferences(params: Params) {
4643
return true;
4744
}
4845

49-
if (
50-
!commonActionsPreferences?.[entity] &&
51-
defaultCommonActions[entity].some(({ value }) => value === actionKey) &&
52-
commonActionsSection
53-
) {
54-
return true;
55-
}
56-
57-
if (commonActionsPreferences && commonActionsSection) {
46+
if (commonActionsPreferences?.[entity] && commonActionsSection) {
5847
return commonActionsPreferences[entity]?.includes(actionKey);
5948
}
6049

61-
if (!commonActionsPreferences?.[entity] && !commonActionsSection) {
62-
return !defaultCommonActions[entity]?.some(
63-
({ value }) => value === actionKey
64-
);
65-
}
66-
6750
return false;
6851
};
6952
}

src/pages/invoices/edit/components/CommonActions.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ export function CommonActions(props: Props) {
4040
const [t] = useTranslation();
4141

4242
const user = useCurrentUser();
43+
4344
const invoiceActions = useInvoiceActions({ dropdown: false });
4445
const creditActions = useCreditActions({ dropdown: false });
4546
const quoteActions = useQuoteActions({ dropdown: false });
4647
const recurringInvoiceActions = useRecurringInvoiceActions({
4748
dropdown: false,
4849
});
4950
const purchaseOrderActions = usePurchaseOrderActions({ dropdown: false });
51+
5052
const { resource, entity } = props;
5153

5254
const [isPreferenceModalOpen, setIsPreferenceModalOpen] =

0 commit comments

Comments
 (0)