Skip to content

Commit 7a3c2a3

Browse files
bexsoftBenjamin Perez
andauthored
Disabled selected buttons in table wrapper (#692)
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent d8ac8cc commit 7a3c2a3

File tree

9 files changed

+46
-25
lines changed

9 files changed

+46
-25
lines changed

portal-ui/build/asset-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"files": {
33
"main.css": "/static/css/main.a19f3d53.chunk.css",
4-
"main.js": "/static/js/main.20231044.chunk.js",
5-
"main.js.map": "/static/js/main.20231044.chunk.js.map",
4+
"main.js": "/static/js/main.a8ae7284.chunk.js",
5+
"main.js.map": "/static/js/main.a8ae7284.chunk.js.map",
66
"runtime-main.js": "/static/js/runtime-main.f48e99e5.js",
77
"runtime-main.js.map": "/static/js/runtime-main.f48e99e5.js.map",
88
"static/css/2.f324abd6.chunk.css": "/static/css/2.f324abd6.chunk.css",
@@ -20,6 +20,6 @@
2020
"static/css/2.f324abd6.chunk.css",
2121
"static/js/2.26e254ca.chunk.js",
2222
"static/css/main.a19f3d53.chunk.css",
23-
"static/js/main.20231044.chunk.js"
23+
"static/js/main.a8ae7284.chunk.js"
2424
]
2525
}

portal-ui/build/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.f324abd6.chunk.css" rel="stylesheet"><link href="/static/css/main.a19f3d53.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.26e254ca.chunk.js"></script><script src="/static/js/main.20231044.chunk.js"></script></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.f324abd6.chunk.css" rel="stylesheet"><link href="/static/css/main.a19f3d53.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.26e254ca.chunk.js"></script><script src="/static/js/main.a8ae7284.chunk.js"></script></body></html>

portal-ui/build/static/js/main.20231044.chunk.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

portal-ui/build/static/js/main.20231044.chunk.js renamed to portal-ui/build/static/js/main.a8ae7284.chunk.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/build/static/js/main.a8ae7284.chunk.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/screens/Console/Buckets/ViewBucket/ViewBucket.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ const ViewBucket = ({
600600
{
601601
type: "delete",
602602
onClick: confirmDeleteReplication,
603-
hideButtonFunction: () => replicationRules.length <= 1,
603+
disableButtonFunction: () => replicationRules.length <= 1,
604604
},
605605
];
606606

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ const styles = () =>
3232
spacing: {
3333
margin: "0 8px",
3434
},
35+
buttonDisabled: {
36+
"&.MuiButtonBase-root.Mui-disabled": {
37+
cursor: "not-allowed",
38+
filter: "grayscale(100%)",
39+
opacity: "30%",
40+
},
41+
},
3542
});
3643

3744
interface IActionButton {
@@ -42,6 +49,7 @@ interface IActionButton {
4249
selected: boolean;
4350
sendOnlyId?: boolean;
4451
idField: string;
52+
disabled: boolean;
4553
classes: any;
4654
}
4755

@@ -76,6 +84,7 @@ const TableActionButton = ({
7684
selected,
7785
to,
7886
sendOnlyId = false,
87+
disabled = false,
7988
classes,
8089
}: IActionButton) => {
8190
const valueClick = sendOnlyId ? valueToSend[idField] : valueToSend;
@@ -88,11 +97,16 @@ const TableActionButton = ({
8897
onClick
8998
? (e) => {
9099
e.stopPropagation();
91-
onClick(valueClick);
100+
if (!disabled) {
101+
onClick(valueClick);
102+
} else {
103+
e.preventDefault();
104+
}
92105
}
93106
: () => null
94107
}
95-
className={classes.spacing}
108+
className={`${classes.spacing} ${disabled ? classes.buttonDisabled : ""}`}
109+
disabled={disabled}
96110
>
97111
{defineIcon(type, selected)}
98112
</IconButton>
@@ -103,16 +117,20 @@ const TableActionButton = ({
103117
}
104118

105119
if (isString(to)) {
106-
return (
107-
<Link
108-
to={`${to}/${valueClick}`}
109-
onClick={(e) => {
110-
e.stopPropagation();
111-
}}
112-
>
113-
{buttonElement}
114-
</Link>
115-
);
120+
if (!disabled) {
121+
return (
122+
<Link
123+
to={`${to}/${valueClick}`}
124+
onClick={(e) => {
125+
e.stopPropagation();
126+
}}
127+
>
128+
{buttonElement}
129+
</Link>
130+
);
131+
}
132+
133+
return buttonElement;
116134
}
117135

118136
return null;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface ItemActions {
4545
type: string;
4646
to?: string;
4747
sendOnlyId?: boolean;
48-
hideButtonFunction?: (itemValue: any) => boolean;
48+
disableButtonFunction?: (itemValue: any) => boolean;
4949
showLoaderFunction?: (itemValue: any) => boolean;
5050

5151
onClick?(valueToSend: any): any;
@@ -434,9 +434,11 @@ const elementActions = (
434434
const vlSend =
435435
typeof valueToSend === "string" ? valueToSend : valueToSend[idField];
436436

437-
if (action.hideButtonFunction) {
438-
if (action.hideButtonFunction(vlSend)) {
439-
return null;
437+
let disabled = false;
438+
439+
if (action.disableButtonFunction) {
440+
if (action.disableButtonFunction(vlSend)) {
441+
disabled = true;
440442
}
441443
}
442444

@@ -465,6 +467,7 @@ const elementActions = (
465467
key={`actions-${action.type}-${index.toString()}`}
466468
idField={idField}
467469
sendOnlyId={!!action.sendOnlyId}
470+
disabled={disabled}
468471
/>
469472
);
470473
});

portal-ui/src/screens/Console/Users/Users.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const Users = ({ classes, setErrorSnackMessage }: IUsersProps) => {
176176
{
177177
type: "delete",
178178
onClick: deleteAction,
179-
hideButtonFunction: (topValue: any) => topValue === userLoggedIn,
179+
disableButtonFunction: (topValue: any) => topValue === userLoggedIn,
180180
},
181181
];
182182

0 commit comments

Comments
 (0)