Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions models/bucket_versioning_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions portal-ui/e2e/lifecycle.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 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 <http://www.gnu.org/licenses/>.

import { expect } from "@playwright/test";
import { test } from "./fixtures/baseFixture";
import { minioadminFile } from "./consts";

test.use({ storageState: minioadminFile });

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5005/buckets");
});

test("Test if Object Version selector is present in Lifecycle rule modal", async ({
page,
}) => {
await page.locator("#create-bucket").click();
await page.getByLabel("Bucket Name*").click();
await page.getByLabel("Bucket Name*").fill("versioned-bucket");
await page.locator("#versioned").check();
await page.getByRole("button", { name: "Create Bucket" }).click();
await page.locator("#manageBucket-versioned-bucket").click();
await page.getByRole("tab", { name: "Lifecycle" }).click();
await page.getByRole("button", { name: "Add Lifecycle Rule" }).click();
await expect(await page.locator("#object_version")).toBeTruthy();
});

test("Test if Object Version selector is not present when bucket is not versioned", async ({
page,
}) => {
await page.locator("#create-bucket").click();
await page.getByLabel("Bucket Name*").click();
await page.getByLabel("Bucket Name*").fill("non-versioned-bucket");
await page.getByRole("button", { name: "Create Bucket" }).click();
await page.locator("#manageBucket-non-versioned-bucket").click();
await page.getByRole("tab", { name: "Lifecycle" }).click();
await page.getByRole("button", { name: "Add Lifecycle Rule" }).click();
await expect(await page.locator("#object_version").count()).toEqual(0);
});
8 changes: 4 additions & 4 deletions portal-ui/src/api/consoleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,12 +791,12 @@ export interface ListRemoteBucketsResponse {
}

export interface BucketVersioningResponse {
Status?: string;
status?: string;
MFADelete?: string;
ExcludedPrefixes?: {
Prefix?: string;
excludedPrefixes?: {
prefix?: string;
}[];
ExcludeFolders?: boolean;
excludeFolders?: boolean;
}

export interface SetBucketVersioning {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import {
spacingUtils,
} from "../../Common/FormComponents/common/styleLibrary";
import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMenu";
import { BucketVersioning } from "../types";
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
import { selDistSet, setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";
import { BucketVersioningInfo, ITiersDropDown } from "../types";

interface IReplicationModal {
open: boolean;
Expand All @@ -61,11 +61,6 @@ interface IReplicationModal {
bucketName: string;
}

export interface ITiersDropDown {
label: string;
value: string;
}

const styles = (theme: Theme) =>
createStyles({
formFieldRowFilter: {
Expand All @@ -88,7 +83,8 @@ const AddLifecycleModal = ({
const [loadingTiers, setLoadingTiers] = useState<boolean>(true);
const [tiersList, setTiersList] = useState<ITiersDropDown[]>([]);
const [addLoading, setAddLoading] = useState(false);
const [isVersioned, setIsVersioned] = useState<boolean>(false);
const [versioningInfo, setVersioningInfo] =
useState<BucketVersioningInfo | null>(null);
const [prefix, setPrefix] = useState("");
const [tags, setTags] = useState<string>("");
const [storageClass, setStorageClass] = useState("");
Expand Down Expand Up @@ -146,8 +142,8 @@ const AddLifecycleModal = ({
if (loadingVersioning && distributedSetup) {
api
.invoke("GET", `/api/v1/buckets/${bucketName}/versioning`)
.then((res: BucketVersioning) => {
setIsVersioned(res.is_versioned);
.then((res: BucketVersioningInfo) => {
setVersioningInfo(res);
setLoadingVersioning(false);
})
.catch((err: ErrorResponseHandler) => {
Expand Down Expand Up @@ -258,7 +254,7 @@ const AddLifecycleModal = ({
]}
/>
</Grid>
{isVersioned && (
{versioningInfo?.status === "Enabled" && (
<Grid item xs={12}>
<SelectWrapper
value={targetVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const BucketSummary = ({ classes }: IBucketSummaryProps) => {
}
};

let versioningStatus = versioningInfo?.Status;
let versioningStatus = versioningInfo?.status;
let versioningText = "Unversioned (Default)";
if (versioningStatus === "Enabled") {
versioningText = "Versioned";
Expand Down Expand Up @@ -604,7 +604,7 @@ const BucketSummary = ({ classes }: IBucketSummaryProps) => {
isLoading={loadingVersioning}
/>

{versioningInfo?.Status === "Enabled" ? (
{versioningInfo?.status === "Enabled" ? (
<VersioningInfo versioningState={versioningInfo} />
) : null}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ import {
spacingUtils,
} from "../../Common/FormComponents/common/styleLibrary";

import { LifeCycleItem } from "../types";
import { ITiersDropDown, LifeCycleItem } from "../types";
import { ErrorResponseHandler } from "../../../../common/types";
import { ITiersDropDown } from "./AddLifecycleModal";
import {
ITierElement,
ITierResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const EnableVersioningModal = ({
selectedBucket,
versioningInfo = {},
}: IVersioningEventProps) => {
const isVersioningEnabled = versioningInfo.Status === "Enabled";
const isVersioningEnabled = versioningInfo.status === "Enabled";

const dispatch = useAppDispatch();
const [versioningLoading, setVersioningLoading] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapp
import RadioGroupSelector from "../../Common/FormComponents/RadioGroupSelector/RadioGroupSelector";
import { ErrorResponseHandler } from "../../../../common/types";
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
import { ITiersDropDown } from "../BucketDetails/AddLifecycleModal";
import {
ITierElement,
ITierResponse,
} from "../../Configurations/TiersConfiguration/types";
import { MultiBucketResult } from "../types";
import { ITiersDropDown, MultiBucketResult } from "../types";
import { setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const DeleteObject = ({
};

const isVersionedDelete =
versioning?.Status === "Enabled" || versioning?.Status === "Suspended";
versioning?.status === "Enabled" || versioning?.status === "Suspended";

return (
<ConfirmDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const DeleteObject = ({
)}
? <br />
<br />
{isVersionedMode(versioningInfo?.Status) &&
{isVersionedMode(versioningInfo?.status) &&
selectedVersion === "" && (
<Fragment>
<FormSwitchWrapper
Expand Down
8 changes: 4 additions & 4 deletions portal-ui/src/screens/Console/Buckets/VersioningInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const VersioningInfo = ({
}}
>
<Box sx={{ fontWeight: "medium", display: "flex", gap: 2 }}>
{versioningState.ExcludeFolders ? (
{versioningState.excludeFolders ? (
<LabelWithIcon
icon={
versioningState.ExcludeFolders ? (
versioningState.excludeFolders ? (
<EnabledIcon style={{ color: "green" }} />
) : (
<DisabledIcon />
Expand All @@ -35,7 +35,7 @@ const VersioningInfo = ({
/>
) : null}
</Box>
{versioningState.ExcludedPrefixes?.length ? (
{versioningState.excludedPrefixes?.length ? (
<Box
sx={{
fontWeight: "medium",
Expand All @@ -57,7 +57,7 @@ const VersioningInfo = ({
display: "flex",
}}
>
{versioningState.ExcludedPrefixes?.map((it) => (
{versioningState.excludedPrefixes?.map((it) => (
<div>
<strong>{it.Prefix}</strong>
</div>
Expand Down
15 changes: 8 additions & 7 deletions portal-ui/src/screens/Console/Buckets/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ export interface ArnList {
arns: string[];
}

export interface BucketVersioning {
is_versioned: boolean;
}

export interface BucketVersioningInfo {
ExcludeFolders?: boolean;
ExcludedPrefixes?: Record<"Prefix", string>[];
excludeFolders?: boolean;
excludedPrefixes?: Record<"Prefix", string>[];
MFADelete?: string;
Status?: "Enabled" | "Suspended" | "";
status?: "Enabled" | "Suspended" | "";
}

export interface BucketObjectLocking {
Expand Down Expand Up @@ -147,3 +143,8 @@ export interface MultiBucketResult {
export interface MultiBucketResult {
results: MultiBucketResult[];
}

export interface ITiersDropDown {
label: string;
value: string;
}
28 changes: 14 additions & 14 deletions restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4944,18 +4944,18 @@ definitions:
bucketVersioningResponse:
type: object
properties:
Status:
status:
type: string
MFADelete:
type: string
ExcludedPrefixes:
excludedPrefixes:
type: array
items:
type: object
properties:
Prefix:
prefix:
type: string
ExcludeFolders:
excludeFolders:
type: boolean

setBucketVersioning:
Expand Down