文件操作 - RichHistoryContainer.tsx
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/features/explore/RichHistory/RichHistoryContainer.tsx
编辑文件内容
// Libraries import React, { useState, useEffect } from 'react'; import { Resizable } from 're-resizable'; import { connect } from 'react-redux'; import { hot } from 'react-hot-loader'; import { css, cx } from 'emotion'; // Services & Utils import store from 'app/core/store'; import { stylesFactory, useTheme } from '@grafana/ui'; import { RICH_HISTORY_SETTING_KEYS } from 'app/core/utils/richHistory'; // Types import { StoreState } from 'app/types'; import { GrafanaTheme } from '@grafana/data'; import { ExploreId, RichHistoryQuery } from 'app/types/explore'; // Components, enums import { RichHistory, Tabs } from './RichHistory'; //Actions import { deleteRichHistory } from '../state/actions'; const getStyles = stylesFactory((theme: GrafanaTheme) => { const shadowColor = theme.isLight ? theme.palette.gray4 : theme.palette.black; return { container: css` position: fixed !important; bottom: 0; background: ${theme.colors.pageHeaderBg}; border-top: 1px solid ${theme.colors.formInputBorder}; margin: 0px; margin-right: -${theme.spacing.md}; margin-left: -${theme.spacing.md}; box-shadow: 0 0 4px ${shadowColor}; z-index: ${theme.zIndex.sidemenu}; `, drawerActive: css` opacity: 1; transition: transform 0.5s ease-out; `, drawerNotActive: css` opacity: 0; transform: translateY(400px); `, rzHandle: css` background: ${theme.colors.formInputBorder}; transition: 0.3s background ease-in-out; position: relative; width: 200px !important; height: 7px !important; left: calc(50% - 100px) !important; top: -4px !important; cursor: grab; border-radius: 4px; &:hover { background: ${theme.colors.formInputBorderHover}; } `, }; }); export interface Props { width: number; exploreId: ExploreId; activeDatasourceInstance: string; richHistory: RichHistoryQuery[]; firstTab: Tabs; deleteRichHistory: typeof deleteRichHistory; onClose: () => void; } export function RichHistoryContainer(props: Props) { const [visible, setVisible] = useState(false); const [height, setHeight] = useState(400); /* To create sliding animation for rich history drawer */ useEffect(() => { const timer = setTimeout(() => setVisible(true), 10); return () => clearTimeout(timer); }, []); const { richHistory, width, firstTab, activeDatasourceInstance, exploreId, deleteRichHistory, onClose } = props; const theme = useTheme(); const styles = getStyles(theme); const drawerWidth = `${width + 31.5}px`; return ( <Resizable className={cx(styles.container, visible ? styles.drawerActive : styles.drawerNotActive)} defaultSize={{ width: drawerWidth, height: '400px' }} handleClasses={{ top: styles.rzHandle }} enable={{ top: true, right: false, bottom: false, left: false, topRight: false, bottomRight: false, bottomLeft: false, topLeft: false, }} maxHeight="100vh" maxWidth={drawerWidth} minWidth={drawerWidth} onResize={(e, dir, ref) => { setHeight(Number(ref.style.height.slice(0, -2))); }} > <RichHistory richHistory={richHistory} firstTab={firstTab} activeDatasourceInstance={activeDatasourceInstance} exploreId={exploreId} deleteRichHistory={deleteRichHistory} onClose={onClose} height={height} /> </Resizable> ); } function mapStateToProps(state: StoreState, { exploreId }: { exploreId: ExploreId }) { const explore = state.explore; // @ts-ignore const item: ExploreItemState = explore[exploreId]; const { datasourceInstance } = item; const firstTab = store.getBool(RICH_HISTORY_SETTING_KEYS.starredTabAsFirstTab, false) ? Tabs.Starred : Tabs.RichHistory; const { richHistory } = explore; return { richHistory, firstTab, activeDatasourceInstance: datasourceInstance?.name, }; } const mapDispatchToProps = { deleteRichHistory, }; export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(RichHistoryContainer));
修改文件时间
将文件时间修改为当前时间的前一年
删除文件