github.com/minio/console@v1.4.1/web-app/src/screens/Console/Dashboard/Prometheus/ZoomWidget.tsx (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2021 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 React, { Fragment } from "react";
    18  
    19  import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
    20  import { IDashboardPanel } from "./types";
    21  import { componentToUse } from "./widgetUtils";
    22  import { closeZoomPage } from "../dashboardSlice";
    23  import { useAppDispatch } from "../../../../store";
    24  
    25  interface IZoomWidget {
    26    widgetRender: number;
    27    value: IDashboardPanel | null;
    28    modalOpen: boolean;
    29    timeStart: any;
    30    timeEnd: any;
    31    apiPrefix: string;
    32  }
    33  
    34  const ZoomWidget = ({
    35    value,
    36    modalOpen,
    37    timeStart,
    38    timeEnd,
    39    apiPrefix,
    40  }: IZoomWidget) => {
    41    const dispatch = useAppDispatch();
    42    if (!value) {
    43      return null;
    44    }
    45  
    46    return (
    47      <ModalWrapper
    48        title={value.title}
    49        onClose={() => {
    50          dispatch(closeZoomPage());
    51        }}
    52        modalOpen={modalOpen}
    53        wideLimit={false}
    54        sx={{
    55          padding: 0,
    56        }}
    57      >
    58        <Fragment>
    59          {componentToUse(value, timeStart, timeEnd, true, apiPrefix, true)}
    60        </Fragment>
    61      </ModalWrapper>
    62    );
    63  };
    64  
    65  export default ZoomWidget;