github.com/minio/console@v1.4.1/web-app/src/screens/Console/ConsoleKBar.tsx (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  import * as React from "react";
    17  import { Fragment } from "react";
    18  import { KBarProvider } from "kbar";
    19  import Console from "./Console";
    20  import { useSelector } from "react-redux";
    21  import CommandBar from "./CommandBar";
    22  import { selFeatures } from "./consoleSlice";
    23  import TrafficMonitor from "./Common/ObjectManager/TrafficMonitor";
    24  import { AppState } from "../../store";
    25  import AnonymousAccess from "../AnonymousAccess/AnonymousAccess";
    26  
    27  const ConsoleKBar = () => {
    28    const features = useSelector(selFeatures);
    29    const anonymousMode = useSelector(
    30      (state: AppState) => state.system.anonymousMode,
    31    );
    32  
    33    // if we are hiding the menu also disable the k-bar so just return console
    34    if (features?.includes("hide-menu")) {
    35      return (
    36        <Fragment>
    37          <TrafficMonitor />
    38          <Console />
    39        </Fragment>
    40      );
    41    }
    42    // for anonymous mode, we don't load Console, only AnonymousAccess
    43    if (anonymousMode) {
    44      return (
    45        <Fragment>
    46          <TrafficMonitor />
    47          <AnonymousAccess />
    48        </Fragment>
    49      );
    50    }
    51  
    52    return (
    53      <KBarProvider
    54        options={{
    55          enableHistory: true,
    56        }}
    57      >
    58        <TrafficMonitor />
    59        <CommandBar />
    60        <Console />
    61      </KBarProvider>
    62    );
    63  };
    64  
    65  export default ConsoleKBar;