Skip to content

Commit 576abde

Browse files
authored
Fix Hop hiding menu (#1621)
* Fix Hop hiding menu Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * Fix Menu Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent 04da7ec commit 576abde

File tree

15 files changed

+94
-90
lines changed

15 files changed

+94
-90
lines changed

operatorapi/configure_operator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func AuthenticationMiddleware(next http.Handler) http.Handler {
140140
// proxyMiddleware adds the proxy capability
141141
func proxyMiddleware(next http.Handler) http.Handler {
142142
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
143-
if strings.HasPrefix(r.URL.Path, "/api/proxy") {
143+
if strings.HasPrefix(r.URL.Path, "/api/proxy") || strings.HasPrefix(r.URL.Path, "/api/hop") {
144144
serveProxy(w, r)
145145
} else {
146146
next.ServeHTTP(w, r)

operatorapi/operator_login.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package operatorapi
1818

1919
import (
2020
"context"
21+
"fmt"
22+
"math/rand"
2123
"net/http"
2224
"time"
2325

@@ -174,6 +176,8 @@ func getLoginOperatorResponse(lmr *models.LoginOperatorRequest) (*models.LoginRe
174176
return nil, prepareError(err)
175177
}
176178
consoleCreds := restapi.ConsoleCredentials{ConsoleCredentials: creds}
179+
// Set a random as access key as session identifier
180+
consoleCreds.AccountAccessKey = fmt.Sprintf("%d", rand.Intn(100000-10000)+10000)
177181
token, err := login(consoleCreds)
178182
if err != nil {
179183
return nil, prepareError(errInvalidCredentials, nil, err)

operatorapi/proxy.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import (
4141

4242
func serveProxy(responseWriter http.ResponseWriter, req *http.Request) {
4343
urlParts := strings.Split(req.URL.Path, "/")
44+
// Either proxy or hop, will decide the type of session
45+
proxyMethod := urlParts[2]
4446

4547
if len(urlParts) < 5 {
4648
log.Println(len(urlParts))
@@ -99,7 +101,7 @@ func serveProxy(responseWriter http.ResponseWriter, req *http.Request) {
99101

100102
h := sha1.New()
101103
h.Write([]byte(nsTenant))
102-
tenantCookieName := fmt.Sprintf("token-%x", string(h.Sum(nil)))
104+
tenantCookieName := fmt.Sprintf("token-%s-%s-%x", proxyMethod, claims.AccountAccessKey, string(h.Sum(nil)))
103105
tenantCookie, err := req.Cookie(tenantCookieName)
104106
if err != nil {
105107
// login to tenantName
@@ -126,9 +128,12 @@ func serveProxy(responseWriter http.ResponseWriter, req *http.Request) {
126128
data := map[string]interface{}{
127129
"accessKey": tenantConfiguration["accesskey"],
128130
"secretKey": tenantConfiguration["secretkey"],
129-
"features": map[string]bool{
131+
}
132+
// if this a proxy request hide the menu
133+
if proxyMethod == "proxy" {
134+
data["features"] = map[string]bool{
130135
"hide_menu": true,
131-
},
136+
}
132137
}
133138
payload, _ := json.Marshal(data)
134139

@@ -188,7 +193,7 @@ func serveProxy(responseWriter http.ResponseWriter, req *http.Request) {
188193
responseWriter.WriteHeader(500)
189194
return
190195
}
191-
tenantBase := fmt.Sprintf("/api/proxy/%s/%s", tenant.Namespace, tenant.Name)
196+
tenantBase := fmt.Sprintf("/api/%s/%s/%s", proxyMethod, tenant.Namespace, tenant.Name)
192197
targetURL.Path = strings.Replace(req.URL.Path, tenantBase, "", -1)
193198

194199
proxiedCookie := &http.Cookie{

portal-ui/src/icons/BackCaretIcon.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ import * as React from "react";
1818
import { SVGProps } from "react";
1919

2020
const BackCaretIcon = (props: SVGProps<SVGSVGElement>) => (
21-
<svg
22-
xmlns="http://www.w3.org/2000/svg"
23-
className={`min-icon`}
24-
fill={"currentcolor"}
25-
viewBox="0 0 256 256"
26-
{...props}
27-
>
28-
<g id="noun_chevron_2320228" transform="translate(5.595 10) rotate(180)">
29-
<path id="Path_6842" d="M-178.01,7.8c-3.9-0.03-7.62-1.63-10.34-4.43c-5.81-5.68-5.92-15-0.25-20.81
21+
<svg
22+
xmlns="http://www.w3.org/2000/svg"
23+
className={`min-icon`}
24+
fill={"currentcolor"}
25+
viewBox="0 0 256 256"
26+
{...props}
27+
>
28+
<g id="noun_chevron_2320228" transform="translate(5.595 10) rotate(180)">
29+
<path
30+
id="Path_6842"
31+
d="M-178.01,7.8c-3.9-0.03-7.62-1.63-10.34-4.43c-5.81-5.68-5.92-15-0.25-20.81
3032
c0.08-0.08,0.16-0.16,0.25-0.25l100.13-100.13l-100.13-100.48c-5.81-5.68-5.92-15-0.25-20.81c0.08-0.08,0.16-0.16,0.25-0.25
3133
c5.68-5.81,15-5.92,20.81-0.25c0.08,0.08,0.16,0.16,0.25,0.25l110.82,110.82c2.8,2.72,4.39,6.44,4.43,10.34
32-
c0.11,3.93-1.51,7.71-4.43,10.34L-167.29,2.99C-170.07,5.97-173.93,7.71-178.01,7.8z"/>
33-
</g>
34-
</svg>
34+
c0.11,3.93-1.51,7.71-4.43,10.34L-167.29,2.99C-170.07,5.97-173.93,7.71-178.01,7.8z"
35+
/>
36+
</g>
37+
</svg>
3538
);
3639

3740
export default BackCaretIcon;

portal-ui/src/icons/FolderIcon.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ const FolderIcon = (props: SVGProps<SVGSVGElement>) => (
2626
{...props}
2727
>
2828
<g>
29-
<path d="M235.3,72.5c-0.2-15.5-12.8-27.9-28.3-27.9h-78l-1.1-1.5c-5.1-9.3-14.5-15.5-25.1-16.6h-50c-15.6,0-28.3,12.6-28.3,28.3
29+
<path
30+
d="M235.3,72.5c-0.2-15.5-12.8-27.9-28.3-27.9h-78l-1.1-1.5c-5.1-9.3-14.5-15.5-25.1-16.6h-50c-15.6,0-28.3,12.6-28.3,28.3
3031
c0,1,0.1,2,0.2,3v12.9c-11.6,3.9-19.4,14.8-19.4,27c0,0.6,0,1.2,0.1,1.7L14.8,202c0.6,15.4,13.2,27.5,28.6,27.5h168.9
3132
c15.4,0,28-12.1,28.6-27.5l9.5-102.5c0-0.6,0.1-1.2,0.1-1.8C250.6,87.1,244.7,77.4,235.3,72.5z M32.5,88.4c11.7-3.3,12-11,12-11
32-
h172c0.2,4.6,2.9,8.8,6.9,11H32.5z"/>
33+
h172c0.2,4.6,2.9,8.8,6.9,11H32.5z"
34+
/>
3335
</g>
3436
</svg>
3537
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const CreateFolderModal = ({
107107
};
108108

109109
const keyPressed = (e: any) => {
110-
if(e.code === "Enter" && pathUrl !== "") {
110+
if (e.code === "Enter" && pathUrl !== "") {
111111
createProcess();
112112
}
113113
};

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const styles = (theme: Theme) =>
178178
"& .min-icon": {
179179
width: 20,
180180
height: 20,
181-
}
181+
},
182182
},
183183
...objectBrowserCommon,
184184
...containerForHeader(theme.spacing(4)),
@@ -666,8 +666,6 @@ const ListObjects = ({
666666
}
667667
};
668668

669-
670-
671669
const handleUploadButton = (e: any) => {
672670
if (
673671
e === null ||
@@ -1270,7 +1268,7 @@ const ListObjects = ({
12701268
variant="dot"
12711269
invisible={!rewindEnabled}
12721270
className={classes.badgeOverlap}
1273-
sx={{height: 12}}
1271+
sx={{ height: 12 }}
12741272
>
12751273
<HistoryIcon />
12761274
</Badge>
@@ -1336,9 +1334,9 @@ const ListObjects = ({
13361334
</Grid>
13371335
<Grid item xs={12}>
13381336
<BrowserBreadcrumbs
1339-
bucketName={bucketName}
1340-
internalPaths={pageTitle}
1341-
existingFiles={records || []}
1337+
bucketName={bucketName}
1338+
internalPaths={pageTitle}
1339+
existingFiles={records || []}
13421340
/>
13431341
</Grid>
13441342
<div

portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export const objectBrowserCommon = {
381381
"& .min-icon": {
382382
width: 14,
383383
minWidth: 14,
384-
}
384+
},
385385
},
386386
smallLabel: {
387387
color: "#9C9C9C",
@@ -414,7 +414,7 @@ export const selectorsCommon = {
414414
},
415415
};
416416

417-
export const settingsCommon:any = {
417+
export const settingsCommon: any = {
418418
customTitle: {
419419
fontSize: 18,
420420
color: "#000",
@@ -1152,7 +1152,7 @@ export const spacingUtils: any = {
11521152
},
11531153
};
11541154

1155-
export const formFieldStyles:any = {
1155+
export const formFieldStyles: any = {
11561156
formFieldRow: {
11571157
marginBottom: ".8rem",
11581158
"& .MuiInputLabel-root": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const ConsoleKBar = ({
8484
operatorMode: boolean;
8585
features: string[] | null;
8686
}) => {
87+
// if we are hiding the menu also disable the k-bar so just return console
8788
if (features?.includes("hide-menu")) {
8889
return <Console />;
8990
}

portal-ui/src/screens/Console/Tenants/TenantDetails/PodsSummary.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { AppState } from "../../../../store";
3333
import { setTenantDetailsLoad } from "../actions";
3434
import { ErrorResponseHandler } from "../../../../common/types";
3535
import DeletePod from "./DeletePod";
36-
import {Grid, InputAdornment, TextField} from "@mui/material";
36+
import { Grid, InputAdornment, TextField } from "@mui/material";
3737
import SearchIcon from "../../../../icons/SearchIcon";
3838

3939
interface IPodsSummary {
@@ -137,22 +137,22 @@ const PodsSummary = ({
137137
<h1 className={classes.sectionTitle}>Pods</h1>
138138
<Grid item xs={12} className={classes.actionsTray}>
139139
<TextField
140-
placeholder="Search Pods"
141-
className={classes.searchField}
142-
id="search-resource"
143-
label=""
144-
InputProps={{
145-
disableUnderline: true,
146-
startAdornment: (
147-
<InputAdornment position="start">
148-
<SearchIcon />
149-
</InputAdornment>
150-
),
151-
}}
152-
onChange={(e) => {
153-
setFilter(e.target.value);
154-
}}
155-
variant="standard"
140+
placeholder="Search Pods"
141+
className={classes.searchField}
142+
id="search-resource"
143+
label=""
144+
InputProps={{
145+
disableUnderline: true,
146+
startAdornment: (
147+
<InputAdornment position="start">
148+
<SearchIcon />
149+
</InputAdornment>
150+
),
151+
}}
152+
onChange={(e) => {
153+
setFilter(e.target.value);
154+
}}
155+
variant="standard"
156156
/>
157157
</Grid>
158158
<Grid item xs={12} className={classes.tableBlock}>

0 commit comments

Comments
 (0)