2019-10-19 16:38:07 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { translate } from 'react-i18next';
|
|
|
|
|
import { ButtonAddons, Button } from '@scm-manager/ui-components';
|
2018-11-26 15:20:44 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
className?: string;
|
|
|
|
|
t: (p: string) => string;
|
|
|
|
|
historyIsSelected: boolean;
|
|
|
|
|
showHistory: (p: boolean) => void;
|
2018-11-26 15:20:44 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-09 16:17:02 +02:00
|
|
|
class FileButtonAddons 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) => {
|
2019-10-19 16:38:07 +02:00
|
|
|
return selected ? 'link is-selected' : null;
|
2019-02-07 09:29:53 +01:00
|
|
|
};
|
|
|
|
|
|
2018-11-26 15:20:44 +01:00
|
|
|
render() {
|
2019-10-09 16:17:02 +02:00
|
|
|
const { className, t, historyIsSelected } = this.props;
|
2018-11-26 15:20:44 +01:00
|
|
|
|
|
|
|
|
return (
|
2019-10-09 16:17:02 +02:00
|
|
|
<ButtonAddons className={className}>
|
2019-10-19 16:38:07 +02:00
|
|
|
<div title={t('sources.content.sourcesButton')}>
|
2019-08-28 09:36:52 +02:00
|
|
|
<Button
|
|
|
|
|
action={this.showSources}
|
|
|
|
|
className="reduced"
|
|
|
|
|
color={this.color(!historyIsSelected)}
|
|
|
|
|
>
|
|
|
|
|
<span className="icon">
|
|
|
|
|
<i className="fas fa-code" />
|
|
|
|
|
</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2019-10-19 16:38:07 +02:00
|
|
|
<div title={t('sources.content.historyButton')}>
|
2019-08-28 09:36:52 +02:00
|
|
|
<Button
|
|
|
|
|
action={this.showHistory}
|
|
|
|
|
className="reduced"
|
|
|
|
|
color={this.color(historyIsSelected)}
|
|
|
|
|
>
|
|
|
|
|
<span className="icon">
|
|
|
|
|
<i className="fas fa-history" />
|
|
|
|
|
</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2019-06-20 14:57:00 +02:00
|
|
|
</ButtonAddons>
|
2018-11-26 15:20:44 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 16:38:07 +02:00
|
|
|
export default translate('repos')(FileButtonAddons);
|