A local-first personal finance app
:fire: remove unused permissions prop from Button components (#4085)
Matiss Janis Aboltins1f2155053fa6
diff --git a/packages/desktop-client/src/components/common/Button.tsx b/packages/desktop-client/src/components/common/Button.tsxindex fdad12cd3b..8a5c170dcc 100644--- a/packages/desktop-client/src/components/common/Button.tsx+++ b/packages/desktop-client/src/components/common/Button.tsx@@ -7,8 +7,6 @@ import React, {import { css } from '@emotion/css';-import { useAuth } from '../../auth/AuthProvider';-import { type Permissions } from '../../auth/types';import { AnimatedLoading } from '../../icons/AnimatedLoading';import { styles, theme } from '../../style';@@ -27,7 +25,6 @@ type ButtonProps = HTMLProps<HTMLButtonElement> & {textStyle?: CSSProperties;bounce?: boolean;as?: ElementType;- permission?: Permissions;};type ButtonType = 'normal' | 'primary' | 'bare' | 'menu' | 'menuSelected';@@ -141,13 +138,10 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(activeStyle,bounce = true,as = 'button',- permission,...nativeProps}: ButtonProps,ref,) => {- const { hasPermission } = useAuth();-const typeWithDisabled: ButtonType | `${ButtonType}Disabled` = disabled? `${type}Disabled`: type;@@ -192,7 +186,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>({...(typeof as === 'string'? { className: css(buttonStyle) }: { style: buttonStyle })}- disabled={disabled ? disabled : !hasPermission(permission)}+ disabled={disabled}type={isSubmit ? 'submit' : 'button'}{...nativeProps}>diff --git a/packages/desktop-client/src/components/common/Button2.tsx b/packages/desktop-client/src/components/common/Button2.tsxindex d32e6f64b6..7fda685aec 100644--- a/packages/desktop-client/src/components/common/Button2.tsx+++ b/packages/desktop-client/src/components/common/Button2.tsx@@ -9,8 +9,6 @@ import { Button as ReactAriaButton } from 'react-aria-components';import { css } from '@emotion/css';-import { useAuth } from '../../auth/AuthProvider';-import { type Permissions } from '../../auth/types';import { AnimatedLoading } from '../../icons/AnimatedLoading';import { styles, theme } from '../../style';@@ -134,22 +132,13 @@ type ButtonProps = ComponentPropsWithoutRef<typeof ReactAriaButton> & {variant?: ButtonVariant;bounce?: boolean;children?: ReactNode;- permission?: Permissions;};type ButtonVariant = 'normal' | 'primary' | 'bare' | 'menu' | 'menuSelected';export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {- const {- permission,- children,- variant = 'normal',- bounce = true,- ...restProps- } = props;-- const { hasPermission } = useAuth();+ const { children, variant = 'normal', bounce = true, ...restProps } = props;const variantWithDisabled: ButtonVariant | `${ButtonVariant}Disabled` =props.isDisabled ? `${variant}Disabled` : variant;@@ -184,7 +173,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(return (<ReactAriaButtonref={ref}- isDisabled={restProps.isDisabled || !hasPermission(permission)}{...restProps}className={typeof className === 'function'diff --git a/upcoming-release-notes/4085.md b/upcoming-release-notes/4085.mdnew file mode 100644index 0000000000..d469ae6b42--- /dev/null+++ b/upcoming-release-notes/4085.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Remove unused `permission` prop from `Button` component.