Skip to content

Commit 4f02544

Browse files
author
Benjamin Perez
committed
Fixed Object Version selector visibility in Add Lifecycle Rule modal
Signed-off-by: Benjamin Perez <[email protected]>
1 parent 81e0c82 commit 4f02544

File tree

14 files changed

+110
-63
lines changed

14 files changed

+110
-63
lines changed

models/bucket_versioning_response.go

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

portal-ui/e2e/lifecycle.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2023 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 { expect } from "@playwright/test";
18+
import { test } from "./fixtures/baseFixture";
19+
import { minioadminFile } from "./consts";
20+
21+
test.use({ storageState: minioadminFile });
22+
23+
test.beforeEach(async ({ page }) => {
24+
await page.goto("http://localhost:5005/buckets");
25+
});
26+
27+
test("Test if Object Version selector is present in Lifecycle rule modal", async ({
28+
page,
29+
}) => {
30+
await page.locator("#create-bucket").click();
31+
await page.getByLabel("Bucket Name*").click();
32+
await page.getByLabel("Bucket Name*").fill("versioned-bucket");
33+
await page.locator("#versioned").check();
34+
await page.getByRole("button", { name: "Create Bucket" }).click();
35+
await page.locator("#manageBucket-versioned-bucket").click();
36+
await page.getByRole("tab", { name: "Lifecycle" }).click();
37+
await page.getByRole("button", { name: "Add Lifecycle Rule" }).click();
38+
await expect(await page.locator("#object_version")).toBeTruthy();
39+
});
40+
41+
test("Test if Object Version selector is not present when bucket is not versioned", async ({
42+
page,
43+
}) => {
44+
await page.locator("#create-bucket").click();
45+
await page.getByLabel("Bucket Name*").click();
46+
await page.getByLabel("Bucket Name*").fill("non-versioned-bucket");
47+
await page.getByRole("button", { name: "Create Bucket" }).click();
48+
await page.locator("#manageBucket-non-versioned-bucket").click();
49+
await page.getByRole("tab", { name: "Lifecycle" }).click();
50+
await page.getByRole("button", { name: "Add Lifecycle Rule" }).click();
51+
await expect(await page.locator("#object_version").count()).toEqual(0);
52+
});

portal-ui/src/api/consoleApi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,12 @@ export interface ListRemoteBucketsResponse {
791791
}
792792

793793
export interface BucketVersioningResponse {
794-
Status?: string;
794+
status?: string;
795795
MFADelete?: string;
796-
ExcludedPrefixes?: {
797-
Prefix?: string;
796+
excludedPrefixes?: {
797+
prefix?: string;
798798
}[];
799-
ExcludeFolders?: boolean;
799+
excludeFolders?: boolean;
800800
}
801801

802802
export interface SetBucketVersioning {

portal-ui/src/screens/Console/Buckets/BucketDetails/AddLifecycleModal.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ import {
4949
spacingUtils,
5050
} from "../../Common/FormComponents/common/styleLibrary";
5151
import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMenu";
52-
import { BucketVersioning } from "../types";
5352
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
5453
import { selDistSet, setModalErrorSnackMessage } from "../../../../systemSlice";
5554
import { useAppDispatch } from "../../../../store";
55+
import { BucketVersioningInfo, ITiersDropDown } from "../types";
5656

5757
interface IReplicationModal {
5858
open: boolean;
@@ -61,11 +61,6 @@ interface IReplicationModal {
6161
bucketName: string;
6262
}
6363

64-
export interface ITiersDropDown {
65-
label: string;
66-
value: string;
67-
}
68-
6964
const styles = (theme: Theme) =>
7065
createStyles({
7166
formFieldRowFilter: {
@@ -88,7 +83,8 @@ const AddLifecycleModal = ({
8883
const [loadingTiers, setLoadingTiers] = useState<boolean>(true);
8984
const [tiersList, setTiersList] = useState<ITiersDropDown[]>([]);
9085
const [addLoading, setAddLoading] = useState(false);
91-
const [isVersioned, setIsVersioned] = useState<boolean>(false);
86+
const [versioningInfo, setVersioningInfo] =
87+
useState<BucketVersioningInfo | null>(null);
9288
const [prefix, setPrefix] = useState("");
9389
const [tags, setTags] = useState<string>("");
9490
const [storageClass, setStorageClass] = useState("");
@@ -146,8 +142,8 @@ const AddLifecycleModal = ({
146142
if (loadingVersioning && distributedSetup) {
147143
api
148144
.invoke("GET", `/api/v1/buckets/${bucketName}/versioning`)
149-
.then((res: BucketVersioning) => {
150-
setIsVersioned(res.is_versioned);
145+
.then((res: BucketVersioningInfo) => {
146+
setVersioningInfo(res);
151147
setLoadingVersioning(false);
152148
})
153149
.catch((err: ErrorResponseHandler) => {
@@ -258,7 +254,7 @@ const AddLifecycleModal = ({
258254
]}
259255
/>
260256
</Grid>
261-
{isVersioned && (
257+
{versioningInfo?.status === "Enabled" && (
262258
<Grid item xs={12}>
263259
<SelectWrapper
264260
value={targetVersion}

portal-ui/src/screens/Console/Buckets/BucketDetails/BucketSummaryPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ const BucketSummary = ({ classes }: IBucketSummaryProps) => {
372372
}
373373
};
374374

375-
let versioningStatus = versioningInfo?.Status;
375+
let versioningStatus = versioningInfo?.status;
376376
let versioningText = "Unversioned (Default)";
377377
if (versioningStatus === "Enabled") {
378378
versioningText = "Versioned";
@@ -604,7 +604,7 @@ const BucketSummary = ({ classes }: IBucketSummaryProps) => {
604604
isLoading={loadingVersioning}
605605
/>
606606

607-
{versioningInfo?.Status === "Enabled" ? (
607+
{versioningInfo?.status === "Enabled" ? (
608608
<VersioningInfo versioningState={versioningInfo} />
609609
) : null}
610610
</Box>

portal-ui/src/screens/Console/Buckets/BucketDetails/EditLifecycleConfiguration.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ import {
3636
spacingUtils,
3737
} from "../../Common/FormComponents/common/styleLibrary";
3838

39-
import { LifeCycleItem } from "../types";
39+
import { ITiersDropDown, LifeCycleItem } from "../types";
4040
import { ErrorResponseHandler } from "../../../../common/types";
41-
import { ITiersDropDown } from "./AddLifecycleModal";
4241
import {
4342
ITierElement,
4443
ITierResponse,

portal-ui/src/screens/Console/Buckets/BucketDetails/EnableVersioningModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const EnableVersioningModal = ({
4040
selectedBucket,
4141
versioningInfo = {},
4242
}: IVersioningEventProps) => {
43-
const isVersioningEnabled = versioningInfo.Status === "Enabled";
43+
const isVersioningEnabled = versioningInfo.status === "Enabled";
4444

4545
const dispatch = useAppDispatch();
4646
const [versioningLoading, setVersioningLoading] = useState<boolean>(false);

portal-ui/src/screens/Console/Buckets/ListBuckets/BulkLifecycleModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapp
4040
import RadioGroupSelector from "../../Common/FormComponents/RadioGroupSelector/RadioGroupSelector";
4141
import { ErrorResponseHandler } from "../../../../common/types";
4242
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
43-
import { ITiersDropDown } from "../BucketDetails/AddLifecycleModal";
4443
import {
4544
ITierElement,
4645
ITierResponse,
4746
} from "../../Configurations/TiersConfiguration/types";
48-
import { MultiBucketResult } from "../types";
47+
import { ITiersDropDown, MultiBucketResult } from "../types";
4948
import { setModalErrorSnackMessage } from "../../../../systemSlice";
5049
import { useAppDispatch } from "../../../../store";
5150

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const DeleteObject = ({
101101
};
102102

103103
const isVersionedDelete =
104-
versioning?.Status === "Enabled" || versioning?.Status === "Suspended";
104+
versioning?.status === "Enabled" || versioning?.status === "Suspended";
105105

106106
return (
107107
<ConfirmDialog

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const DeleteObject = ({
122122
)}
123123
? <br />
124124
<br />
125-
{isVersionedMode(versioningInfo?.Status) &&
125+
{isVersionedMode(versioningInfo?.status) &&
126126
selectedVersion === "" && (
127127
<Fragment>
128128
<FormSwitchWrapper

0 commit comments

Comments
 (0)