github.com/minio/console@v1.4.1/web-app/src/screens/Console/Buckets/BucketDetails/bucketDetailsSlice.ts (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2022 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 { createSlice, PayloadAction } from "@reduxjs/toolkit";
    18  import { AppState } from "../../../../store";
    19  import { Bucket } from "api/consoleApi";
    20  
    21  export interface BucketDetailsState {
    22    selectedTab: string;
    23    loadingBucket: boolean;
    24    bucketInfo: Bucket | null;
    25  }
    26  
    27  const initialState: BucketDetailsState = {
    28    selectedTab: "summary",
    29    loadingBucket: false,
    30    bucketInfo: null,
    31  };
    32  
    33  export const bucketDetailsSlice = createSlice({
    34    name: "bucketDetails",
    35    initialState,
    36    reducers: {
    37      setBucketDetailsTab: (state, action: PayloadAction<string>) => {
    38        state.selectedTab = action.payload;
    39      },
    40      setBucketDetailsLoad: (state, action: PayloadAction<boolean>) => {
    41        state.loadingBucket = action.payload;
    42      },
    43      setBucketInfo: (state, action: PayloadAction<Bucket | null>) => {
    44        state.bucketInfo = action.payload;
    45      },
    46    },
    47  });
    48  
    49  export const { setBucketDetailsTab, setBucketInfo, setBucketDetailsLoad } =
    50    bucketDetailsSlice.actions;
    51  
    52  export const selBucketDetailsLoading = (state: AppState) =>
    53    state.bucketDetails.loadingBucket;
    54  export const selBucketDetailsInfo = (state: AppState) =>
    55    state.bucketDetails.bucketInfo;
    56  
    57  export default bucketDetailsSlice.reducer;