-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2897 from bakdata/history-empty-state
History empty state
- Loading branch information
Showing
14 changed files
with
296 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,29 @@ | ||
import styled from "@emotion/styled"; | ||
import { useCallback } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { useDispatch } from "react-redux"; | ||
|
||
import type { ColumnDescription } from "../api/types"; | ||
import type { StateT } from "../app/reducers"; | ||
import { useGetAuthorizedUrl } from "../authorization/useAuthorizedUrl"; | ||
import { openHistory, useNewHistorySession } from "../entity-history/actions"; | ||
import { openHistory } from "../entity-history/actions"; | ||
|
||
import IconButton from "./IconButton"; | ||
|
||
const SxIconButton = styled(IconButton)` | ||
const Button = styled(IconButton)` | ||
white-space: nowrap; | ||
height: 35px; | ||
padding: 5px 12px; | ||
height: 30px; | ||
`; | ||
|
||
interface PropsT { | ||
columns: ColumnDescription[]; | ||
label: string; | ||
url: string; | ||
} | ||
|
||
const HistoryButton = ({ url, label, columns, ...restProps }: PropsT) => { | ||
export const HistoryButton = () => { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
const isLoading = useSelector<StateT, boolean>( | ||
(state) => state.entityHistory.isLoading, | ||
); | ||
|
||
const getAuthorizedUrl = useGetAuthorizedUrl(); | ||
const newHistorySession = useNewHistorySession(); | ||
const onClick = useCallback(() => { | ||
dispatch(openHistory()); | ||
}, [dispatch]); | ||
|
||
return ( | ||
<SxIconButton | ||
icon={isLoading ? "spinner" : "list-ul"} | ||
frame | ||
onClick={async () => { | ||
await newHistorySession(getAuthorizedUrl(url), columns, label); | ||
dispatch(openHistory()); | ||
}} | ||
{...restProps} | ||
> | ||
<Button icon="list-ul" frame onClick={onClick}> | ||
{t("history.history")} | ||
</SxIconButton> | ||
</Button> | ||
); | ||
}; | ||
|
||
export default HistoryButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import styled from "@emotion/styled"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
|
||
import type { ColumnDescription } from "../api/types"; | ||
import type { StateT } from "../app/reducers"; | ||
import { useGetAuthorizedUrl } from "../authorization/useAuthorizedUrl"; | ||
import { openHistory, useNewHistorySession } from "../entity-history/actions"; | ||
|
||
import IconButton from "./IconButton"; | ||
|
||
const SxIconButton = styled(IconButton)` | ||
white-space: nowrap; | ||
height: 35px; | ||
`; | ||
|
||
interface PropsT { | ||
columns: ColumnDescription[]; | ||
label: string; | ||
url: string; | ||
} | ||
|
||
export const QueryResultHistoryButton = ({ url, label, columns }: PropsT) => { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
const isLoading = useSelector<StateT, boolean>( | ||
(state) => state.entityHistory.isLoading, | ||
); | ||
|
||
const getAuthorizedUrl = useGetAuthorizedUrl(); | ||
const newHistorySession = useNewHistorySession(); | ||
|
||
return ( | ||
<SxIconButton | ||
icon={isLoading ? "spinner" : "list-ul"} | ||
frame | ||
onClick={async () => { | ||
await newHistorySession(getAuthorizedUrl(url), columns, label); | ||
dispatch(openHistory()); | ||
}} | ||
> | ||
{t("history.history")} | ||
</SxIconButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.