From abd9768bd9063abbc89bbe7b2262d4af309bc4d8 Mon Sep 17 00:00:00 2001
From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Date: Wed, 10 Nov 2021 22:38:18 -0800
Subject: [PATCH] Recover Icon. Add Tooltip support for TableActionButton
(#1215)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
---
portal-ui/src/icons/RecoverIcon.tsx | 33 +++++++++++++++++++
portal-ui/src/icons/index.ts | 1 +
.../Objects/ObjectDetails/ObjectDetails.tsx | 6 +++-
.../Common/TableWrapper/TableActionButton.tsx | 32 +++++++++---------
.../Common/TableWrapper/TableWrapper.tsx | 4 ++-
5 files changed, 58 insertions(+), 18 deletions(-)
create mode 100644 portal-ui/src/icons/RecoverIcon.tsx
diff --git a/portal-ui/src/icons/RecoverIcon.tsx b/portal-ui/src/icons/RecoverIcon.tsx
new file mode 100644
index 000000000..4fd4b8378
--- /dev/null
+++ b/portal-ui/src/icons/RecoverIcon.tsx
@@ -0,0 +1,33 @@
+// This file is part of MinIO Console Server
+// Copyright (c) 2021 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+import React from "react";
+import { SvgIcon, SvgIconProps } from "@mui/material";
+
+const RecoverIcon = (props: SvgIconProps) => {
+ return (
+
+
+
+ );
+};
+
+export default RecoverIcon;
diff --git a/portal-ui/src/icons/index.ts b/portal-ui/src/icons/index.ts
index 70c6622ec..028710a7f 100644
--- a/portal-ui/src/icons/index.ts
+++ b/portal-ui/src/icons/index.ts
@@ -103,4 +103,5 @@ export { default as LambdaIcon } from "./LambdaIcon";
export { default as TiersIcon } from "./TiersIcon";
export { default as OpenListIcon } from "./OpenListIcon";
export { default as ToolsIcon } from "./ToolsIcon";
+export { default as RecoverIcon } from "./RecoverIcon";
export { default as PrometheusIcon } from "./PrometheusIcon";
diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx
index 7f16bdb89..d8c438fb6 100644
--- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx
+++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx
@@ -94,6 +94,7 @@ import ObjectBrowserIcon from "../../../../../../icons/ObjectBrowserIcon";
import PreviewFileContent from "../Preview/PreviewFileContent";
import RestoreFileVersion from "./RestoreFileVersion";
import BoxIconButton from "../../../../Common/BoxIconButton";
+import { RecoverIcon } from "../../../../../../icons";
const styles = (theme: Theme) =>
createStyles({
@@ -446,6 +447,7 @@ const ObjectDetails = ({
const tableActions: ItemActions[] = [
{
+ label: "Share",
type: "share",
onClick: (item: any) => {
setObjectToShare(item);
@@ -461,6 +463,7 @@ const ObjectDetails = ({
},
},
{
+ label: "Download",
type: "download",
onClick: (item: IFileInfo) => {
downloadObject(item);
@@ -474,7 +477,8 @@ const ObjectDetails = ({
},
},
{
- type: "restore",
+ label: "Restore",
+ type: ,
onClick: (item: IFileInfo) => {
setRestoreVersion(item.version_id || "");
setRestoreVersionOpen(true);
diff --git a/portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx b/portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx
index 4347a56b8..7d8c4fc38 100644
--- a/portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx
+++ b/portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx
@@ -13,24 +13,19 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-import React from "react";
+import React, { Component } from "react";
import isString from "lodash/isString";
import { Link } from "react-router-dom";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
-import { IconButton } from "@mui/material";
+import { IconButton, Tooltip } from "@mui/material";
import CloudIcon from "./TableActionIcons/CloudIcon";
import ConsoleIcon from "./TableActionIcons/ConsoleIcon";
import DisableIcon from "./TableActionIcons/DisableIcon";
import FormatDriveIcon from "./TableActionIcons/FormatDriveIcon";
import EditIcon from "../../../../icons/EditIcon";
import TrashIcon from "../../../../icons/TrashIcon";
-import {
- IAMPoliciesIcon,
- PreviewIcon,
- ShareIcon,
- HistoryIcon,
-} from "../../../../icons";
+import { IAMPoliciesIcon, PreviewIcon, ShareIcon } from "../../../../icons";
import DownloadIcon from "../../../../icons/DownloadIcon";
const styles = () =>
@@ -48,7 +43,8 @@ const styles = () =>
});
interface IActionButton {
- type: string;
+ label?: string;
+ type: string | Component;
onClick?: (id: string) => any;
to?: string;
valueToSend: any;
@@ -83,8 +79,6 @@ const defineIcon = (type: string, selected: boolean) => {
return ;
case "preview":
return ;
- case "restore":
- return ;
}
return null;
@@ -100,13 +94,17 @@ const TableActionButton = ({
sendOnlyId = false,
disabled = false,
classes,
+ label,
}: IActionButton) => {
const valueClick = sendOnlyId ? valueToSend[idField] : valueToSend;
- const buttonElement = (
+ const icon = typeof type === "string" ? defineIcon(type, selected) : type;
+ let buttonElement = (
{
@@ -119,13 +117,15 @@ const TableActionButton = ({
}
: () => null
}
- className={`${classes.spacing} ${disabled ? classes.buttonDisabled : ""}`}
- disabled={disabled}
>
- {defineIcon(type, selected)}
+ {icon}
);
+ if (label && label !== "") {
+ buttonElement = {buttonElement};
+ }
+
if (onClick) {
return buttonElement;
}
diff --git a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx
index 2fbd5fca2..6b970379b 100644
--- a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx
+++ b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx
@@ -43,7 +43,8 @@ import CheckboxWrapper from "../FormComponents/CheckboxWrapper/CheckboxWrapper";
//Interfaces for table Items
export interface ItemActions {
- type: string;
+ label?: string;
+ type: string | any;
to?: string;
sendOnlyId?: boolean;
disableButtonFunction?: (itemValue: any) => boolean;
@@ -466,6 +467,7 @@ const elementActions = (
return (