Skip to content

Commit

Permalink
feat: sync changes from v2 to v2-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarreras authored and github-actions[bot] committed Nov 21, 2024
1 parent 51de123 commit 814aa46
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-ooui",
"version": "2.36.0-rc.2",
"version": "2.38.0",
"engines": {
"node": "20.5.0"
},
Expand Down
9 changes: 8 additions & 1 deletion src/actionbar/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import ButtonWithTooltip from "@/common/ButtonWithTooltip";
import { LoadingOutlined } from "@ant-design/icons";
import { ButtonProps } from "antd";

type Props = {
type Props = ButtonProps & {
tooltip: string;
onClick: any;
icon: any;
Expand All @@ -21,6 +22,7 @@ function ActionButton(props: Props) {
icon,
label,
type = "default",
...restProps
} = props;
const finalIcon = loading ? <LoadingOutlined /> : icon;

Expand All @@ -30,11 +32,16 @@ function ActionButton(props: Props) {
tooltip={tooltip}
onClick={onClick}
disabled={disabled}
{...restProps}
>
{finalIcon}
{label}
</ButtonWithTooltip>
);
}

export const ActionDangerButton = (props: Props) => {
return <ActionButton {...props} type="primary" danger={true} />;
};

export default ActionButton;
4 changes: 2 additions & 2 deletions src/actionbar/FormActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
InfoCircleOutlined,
} from "@ant-design/icons";
import ChangeViewButton from "./ChangeViewButton";
import ActionButton from "./ActionButton";
import ActionButton, { ActionDangerButton } from "./ActionButton";
import { useActionViewContext } from "@/context/ActionViewContext";
import NewButton from "./NewButton";
import showUnsavedChangesDialog from "@/ui/UnsavedChangesDialog";
Expand Down Expand Up @@ -224,7 +224,7 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
})
}
/>
<ActionButton
<ActionDangerButton
icon={<DeleteOutlined />}
tooltip={t("delete")}
disabled={mustDisableButtons || currentId === undefined}
Expand Down
1 change: 1 addition & 0 deletions src/actionbar/NewButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function NewButton(props: Props) {
tooltip={t("new")}
onClick={onNewClicked}
disabled={disabled}
type="primary"
/>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/actionbar/TreeActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ActionViewContextType,
} from "@/context/ActionViewContext";
import NewButton from "./NewButton";
import ActionButton from "./ActionButton";
import ActionButton, { ActionDangerButton } from "./ActionButton";
import Icon, {
DeleteOutlined,
PrinterOutlined,
Expand Down Expand Up @@ -260,7 +260,7 @@ function TreeActionBar(props: Props) {
loading={duplicatingItem}
onClick={tryDuplicate}
/>
<ActionButton
<ActionDangerButton
icon={<DeleteOutlined />}
tooltip={t("delete")}
disabled={
Expand Down
26 changes: 15 additions & 11 deletions src/widgets/base/one2many/One2manyTopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ApiOutlined,
} from "@ant-design/icons";
import { ViewType } from "@/types";
import { theme } from "antd";
import { theme, Badge } from "antd";
const { useToken } = theme;

type One2manyTopBarProps = {
Expand Down Expand Up @@ -74,16 +74,20 @@ export const One2manyTopBar = (props: One2manyTopBarProps) => {

function deleteButton() {
return (
<ButtonWithTooltip
tooltip={isMany2Many ? "Unlink" : "Delete"}
icon={isMany2Many ? <ApiOutlined /> : <DeleteOutlined />}
onClick={onDelete}
disabled={
totalItems === 0 ||
readOnly ||
(mode !== "form" && selectedRowKeys.length === 0)
}
/>
<Badge count={selectedRowKeys.length}>
<ButtonWithTooltip
tooltip={isMany2Many ? "Unlink" : "Delete"}
icon={isMany2Many ? <ApiOutlined /> : <DeleteOutlined />}
onClick={onDelete}
danger={!isMany2Many}
type={isMany2Many ? "default" : "primary"}
disabled={
totalItems === 0 ||
readOnly ||
(mode !== "form" && selectedRowKeys.length === 0)
}
/>
</Badge>
);
}

Expand Down

0 comments on commit 814aa46

Please sign in to comment.