Skip to content

Commit abd9768

Browse files
authored
Recover Icon. Add Tooltip support for TableActionButton (#1215)
Signed-off-by: Daniel Valdivia <[email protected]>
1 parent 0e778a7 commit abd9768

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2021 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React from "react";
18+
import { SvgIcon, SvgIconProps } from "@mui/material";
19+
20+
const RecoverIcon = (props: SvgIconProps) => {
21+
return (
22+
<SvgIcon {...props}>
23+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 255.999">
24+
<path
25+
d="M39.2213+256.001C40.6927+255.994+42.1568+255.792+43.5753+255.401L100.813+239.901C104.645+238.898+107.914+236.399+109.887+232.964C111.86+229.528+112.371+225.445+111.305+221.63L95.7702+164.495C90.6702+145.747+62.1182+153.481+67.2132+172.229L73.0132+193.562L74.0462+197.062C73.8702+196.968+73.7042+196.862+73.5212+196.774C31.3819+176.285+13.8232+125.52+34.2982+83.374C46.3933+58.6766+69.6654+41.3358+96.7903+36.809C100.154+36.251+103.157+34.3788+105.14+31.6049C107.122+28.8309+107.92+25.3828+107.358+22.02C106.18+15.0178+99.5504+10.2948+92.5473+11.468C57.2167+17.3704+26.9074+39.9628+11.1583+72.135C3.87084+87.0355+0.0559253+103.394+0.000251187+119.981L0.000251187+120.664C0.113227+162.907+24.2688+201.4+62.2582+219.874C62.3172+219.906+62.3792+219.923+62.4382+219.951L52.8662+222.279L35.8212+226.894C18.5692+231.567+23.7062+256.005+39.2142+256.005L39.2213+256.001ZM161.326+244.717C162.041+244.716+162.755+244.658+163.461+244.542C198.791+238.639+229.099+216.046+244.848+183.875C252.172+168.901+255.986+152.456+256.002+135.787L256.002+135.558C255.976+93.2388+231.809+54.6428+193.75+36.137C193.686+36.105+193.627+36.087+193.564+36.056L203.14+33.733L220.181+29.118C237.415+24.449+232.31+0.064988+216.847+0.00298769L216.716+0.00298769C215.268+0.0183407+213.829+0.222051+212.433+0.608988L155.191+16.109C151.359+17.112+148.09+19.6118+146.118+23.0473C144.146+26.4827+143.637+30.5661+144.703+34.381L160.234+91.515C165.334+110.264+193.892+102.53+188.796+83.781L182.996+62.445L181.957+58.945C182.133+59.039+182.303+59.145+182.488+59.233C224.628+79.7218+242.185+130.489+221.705+172.633C209.614+197.332+186.343+214.674+159.219+219.202C155.856+219.759+152.853+221.631+150.87+224.404C148.887+227.177+148.089+230.624+148.649+233.987C149.691+240.177+155.047+244.711+161.323+244.718L161.326+244.717ZM149.004+128.001C149.004+116.403+139.602+107.001+128.004+107.001C116.406+107.001+107.004+116.403+107.004+128.001C107.004+139.599+116.406+149.001+128.004+149.001C139.602+149.001+149.004+139.599+149.004+128.001Z"
26+
opacity="1"
27+
/>
28+
</svg>
29+
</SvgIcon>
30+
);
31+
};
32+
33+
export default RecoverIcon;

portal-ui/src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,5 @@ export { default as LambdaIcon } from "./LambdaIcon";
103103
export { default as TiersIcon } from "./TiersIcon";
104104
export { default as OpenListIcon } from "./OpenListIcon";
105105
export { default as ToolsIcon } from "./ToolsIcon";
106+
export { default as RecoverIcon } from "./RecoverIcon";
106107
export { default as PrometheusIcon } from "./PrometheusIcon";

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import ObjectBrowserIcon from "../../../../../../icons/ObjectBrowserIcon";
9494
import PreviewFileContent from "../Preview/PreviewFileContent";
9595
import RestoreFileVersion from "./RestoreFileVersion";
9696
import BoxIconButton from "../../../../Common/BoxIconButton";
97+
import { RecoverIcon } from "../../../../../../icons";
9798

9899
const styles = (theme: Theme) =>
99100
createStyles({
@@ -446,6 +447,7 @@ const ObjectDetails = ({
446447

447448
const tableActions: ItemActions[] = [
448449
{
450+
label: "Share",
449451
type: "share",
450452
onClick: (item: any) => {
451453
setObjectToShare(item);
@@ -461,6 +463,7 @@ const ObjectDetails = ({
461463
},
462464
},
463465
{
466+
label: "Download",
464467
type: "download",
465468
onClick: (item: IFileInfo) => {
466469
downloadObject(item);
@@ -474,7 +477,8 @@ const ObjectDetails = ({
474477
},
475478
},
476479
{
477-
type: "restore",
480+
label: "Restore",
481+
type: <RecoverIcon />,
478482
onClick: (item: IFileInfo) => {
479483
setRestoreVersion(item.version_id || "");
480484
setRestoreVersionOpen(true);

portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,19 @@
1313
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
import React from "react";
16+
import React, { Component } from "react";
1717
import isString from "lodash/isString";
1818
import { Link } from "react-router-dom";
1919
import createStyles from "@mui/styles/createStyles";
2020
import withStyles from "@mui/styles/withStyles";
21-
import { IconButton } from "@mui/material";
21+
import { IconButton, Tooltip } from "@mui/material";
2222
import CloudIcon from "./TableActionIcons/CloudIcon";
2323
import ConsoleIcon from "./TableActionIcons/ConsoleIcon";
2424
import DisableIcon from "./TableActionIcons/DisableIcon";
2525
import FormatDriveIcon from "./TableActionIcons/FormatDriveIcon";
2626
import EditIcon from "../../../../icons/EditIcon";
2727
import TrashIcon from "../../../../icons/TrashIcon";
28-
import {
29-
IAMPoliciesIcon,
30-
PreviewIcon,
31-
ShareIcon,
32-
HistoryIcon,
33-
} from "../../../../icons";
28+
import { IAMPoliciesIcon, PreviewIcon, ShareIcon } from "../../../../icons";
3429
import DownloadIcon from "../../../../icons/DownloadIcon";
3530

3631
const styles = () =>
@@ -48,7 +43,8 @@ const styles = () =>
4843
});
4944

5045
interface IActionButton {
51-
type: string;
46+
label?: string;
47+
type: string | Component;
5248
onClick?: (id: string) => any;
5349
to?: string;
5450
valueToSend: any;
@@ -83,8 +79,6 @@ const defineIcon = (type: string, selected: boolean) => {
8379
return <FormatDriveIcon active={selected} />;
8480
case "preview":
8581
return <PreviewIcon />;
86-
case "restore":
87-
return <HistoryIcon />;
8882
}
8983

9084
return null;
@@ -100,13 +94,17 @@ const TableActionButton = ({
10094
sendOnlyId = false,
10195
disabled = false,
10296
classes,
97+
label,
10398
}: IActionButton) => {
10499
const valueClick = sendOnlyId ? valueToSend[idField] : valueToSend;
105100

106-
const buttonElement = (
101+
const icon = typeof type === "string" ? defineIcon(type, selected) : type;
102+
let buttonElement = (
107103
<IconButton
108-
aria-label={type}
104+
aria-label={typeof type === "string" ? type : ""}
109105
size={"small"}
106+
className={`${classes.spacing} ${disabled ? classes.buttonDisabled : ""}`}
107+
disabled={disabled}
110108
onClick={
111109
onClick
112110
? (e) => {
@@ -119,13 +117,15 @@ const TableActionButton = ({
119117
}
120118
: () => null
121119
}
122-
className={`${classes.spacing} ${disabled ? classes.buttonDisabled : ""}`}
123-
disabled={disabled}
124120
>
125-
{defineIcon(type, selected)}
121+
{icon}
126122
</IconButton>
127123
);
128124

125+
if (label && label !== "") {
126+
buttonElement = <Tooltip title={label}>{buttonElement}</Tooltip>;
127+
}
128+
129129
if (onClick) {
130130
return buttonElement;
131131
}

portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import CheckboxWrapper from "../FormComponents/CheckboxWrapper/CheckboxWrapper";
4343
//Interfaces for table Items
4444

4545
export interface ItemActions {
46-
type: string;
46+
label?: string;
47+
type: string | any;
4748
to?: string;
4849
sendOnlyId?: boolean;
4950
disableButtonFunction?: (itemValue: any) => boolean;
@@ -466,6 +467,7 @@ const elementActions = (
466467

467468
return (
468469
<TableActionButton
470+
label={action.label}
469471
type={action.type}
470472
onClick={action.onClick}
471473
to={action.to}

0 commit comments

Comments
 (0)