Skip to content

Commit

Permalink
fix(web): fix storage list pagination & site available only storage r…
Browse files Browse the repository at this point in the history
…eadonly (labring#1519)

* fix(web): fix storage list pagination

* fix(web): fix s3 query & site available only readonly
  • Loading branch information
newfish-cmyk authored Sep 6, 2023
1 parent aa38e80 commit 6dfe8c5
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 138 deletions.
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

0 comments on commit 6dfe8c5

Please sign in to comment.