2018-11-26 15:20:44 +01:00
|
|
|
// @flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
2019-02-07 09:29:53 +01:00
|
|
|
import { ButtonGroup, Button } from "@scm-manager/ui-components";
|
2018-11-26 15:20:44 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
t: string => string,
|
|
|
|
|
historyIsSelected: boolean,
|
|
|
|
|
showHistory: boolean => void
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-29 14:02:36 +01:00
|
|
|
class FileButtonGroup extends React.Component<Props> {
|
2018-11-26 15:20:44 +01:00
|
|
|
showHistory = () => {
|
|
|
|
|
this.props.showHistory(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
showSources = () => {
|
|
|
|
|
this.props.showHistory(false);
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-07 09:29:53 +01:00
|
|
|
color = (selected: boolean) => {
|
|
|
|
|
return selected ? "link is-selected" : null;
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-26 15:20:44 +01:00
|
|
|
render() {
|
|
|
|
|
const { t, historyIsSelected } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
2019-06-20 13:40:12 +02:00
|
|
|
<ButtonGroup connected={true}>
|
2019-04-18 18:07:13 +02:00
|
|
|
<Button
|
|
|
|
|
action={this.showSources}
|
|
|
|
|
className="reduced-mobile"
|
|
|
|
|
color={this.color(!historyIsSelected)}
|
|
|
|
|
>
|
2019-02-07 09:29:53 +01:00
|
|
|
<span className="icon">
|
2019-04-18 18:07:13 +02:00
|
|
|
<i className="fas fa-code" />
|
2019-02-07 09:29:53 +01:00
|
|
|
</span>
|
2019-04-18 18:07:13 +02:00
|
|
|
<span>{t("sources.content.sourcesButton")}</span>
|
2019-02-07 09:29:53 +01:00
|
|
|
</Button>
|
2019-04-18 18:07:13 +02:00
|
|
|
<Button
|
|
|
|
|
action={this.showHistory}
|
|
|
|
|
className="reduced-mobile"
|
|
|
|
|
color={this.color(historyIsSelected)}
|
|
|
|
|
>
|
2019-02-07 09:29:53 +01:00
|
|
|
<span className="icon">
|
2019-04-18 18:07:13 +02:00
|
|
|
<i className="fas fa-history" />
|
2019-02-07 09:29:53 +01:00
|
|
|
</span>
|
2019-04-18 18:07:13 +02:00
|
|
|
<span>{t("sources.content.historyButton")}</span>
|
|
|
|
|
</Button>
|
2019-02-07 09:29:53 +01:00
|
|
|
</ButtonGroup>
|
2018-11-26 15:20:44 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-29 14:02:36 +01:00
|
|
|
export default translate("repos")(FileButtonGroup);
|