Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): fix storage list pagination & site available only storage readonly #1519

Merged
merged 2 commits into from
Sep 6, 2023
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
6 changes: 3 additions & 3 deletions web/src/hooks/useAwsS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function useAwsS3() {
signatureVersion: "v4",
});

const getList = async (bucketName: string | undefined, { marker, prefix }: any) => {
const getList = async (bucketName: string | undefined, { marker, maxKeys, prefix }: any) => {
if (!bucketName || bucketName === "") return [];

const res = await s3
.listObjects({
Bucket: bucketName,
MaxKeys: 100,
MaxKeys: maxKeys,
Marker: marker,
Prefix: prefix,
Delimiter: "/",
Expand All @@ -29,7 +29,7 @@ function useAwsS3() {
const files = res.Contents || [];
const dirs = res.CommonPrefixes || [];
// console.log(files, dirs)
return [...files, ...dirs];
return { data: [...files, ...dirs], marker: res.NextMarker };
};

const getFileUrl = (bucket: string, key: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import useStorageStore from "../../store";

export default function Status() {
const { currentStorage } = useStorageStore();
const isPrivate = currentStorage?.policy === BUCKET_POLICY_TYPE.private;
const isReadOnly = currentStorage?.policy === BUCKET_POLICY_TYPE.readonly;
return (
<DotBadge
type={isPrivate ? "warning" : "success"}
type={!isReadOnly ? "warning" : "success"}
text={
<>
{isPrivate ? (
<Tooltip placement="bottom-end" label={isPrivate ? t("Bucket.StatusTip") : ""}>
{!isReadOnly ? (
<Tooltip placement="bottom-end" label={!isReadOnly ? t("Bucket.StatusTip") : ""}>
{t("StoragePanel.Inaccessible")}
</Tooltip>
) : (
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/app/storages/mods/CreateWebsiteModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function CreateWebsiteModal() {
style={{ borderRadius: "1rem" }}
disabled={currentStorage === undefined}
onClick={() => {
if (currentStorage?.policy === BUCKET_POLICY_TYPE.private) {
if (!(currentStorage?.policy === BUCKET_POLICY_TYPE.readonly)) {
toast({
status: "warning",
position: "top",
Expand All @@ -137,7 +137,7 @@ function CreateWebsiteModal() {

<ModalBody pb={6}>
<VStack spacing={6} align="flex-start">
{currentStorage?.policy === BUCKET_POLICY_TYPE.private ? (
{!(currentStorage?.policy === BUCKET_POLICY_TYPE.readonly) ? (
<p className="font-semibold text-error-500">{t("StoragePanel.editHostTip")}</p>
) : null}
<FormControl>
Expand Down
Loading