2018-11-26 15:20:44 +01:00
|
|
|
// @flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
|
|
|
|
import { Button } from "@scm-manager/ui-components";
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
t: string => string,
|
|
|
|
|
historyIsSelected: boolean,
|
|
|
|
|
showHistory: boolean => void
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ButtonGroup extends React.Component<Props> {
|
|
|
|
|
showHistory = () => {
|
|
|
|
|
this.props.showHistory(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
showSources = () => {
|
|
|
|
|
this.props.showHistory(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { t, historyIsSelected } = this.props;
|
|
|
|
|
|
|
|
|
|
let sourcesColor = "";
|
|
|
|
|
let historyColor = "";
|
|
|
|
|
|
|
|
|
|
if (historyIsSelected) {
|
2019-01-25 13:15:04 +01:00
|
|
|
historyColor = "link is-selected";
|
2018-11-26 15:20:44 +01:00
|
|
|
} else {
|
2019-01-25 13:15:04 +01:00
|
|
|
sourcesColor = "link is-selected";
|
2018-11-26 15:20:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sourcesLabel = (
|
|
|
|
|
<>
|
|
|
|
|
<span className="icon">
|
|
|
|
|
<i className="fas fa-code" />
|
|
|
|
|
</span>
|
|
|
|
|
<span className="is-hidden-mobile">
|
|
|
|
|
{t("sources.content.sourcesButton")}
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const historyLabel = (
|
|
|
|
|
<>
|
|
|
|
|
<span className="icon">
|
|
|
|
|
<i className="fas fa-history" />
|
|
|
|
|
</span>
|
|
|
|
|
<span className="is-hidden-mobile">
|
|
|
|
|
{t("sources.content.historyButton")}
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="buttons has-addons">
|
|
|
|
|
<Button
|
|
|
|
|
label={sourcesLabel}
|
|
|
|
|
color={sourcesColor}
|
|
|
|
|
action={this.showSources}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
label={historyLabel}
|
|
|
|
|
color={historyColor}
|
|
|
|
|
action={this.showHistory}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate("repos")(ButtonGroup);
|