2018-12-22 03:10:49 +03:00
|
|
|
import React from 'react';
|
|
|
|
import RightSlider from './RightSlider';
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
const getActiveButtons = (hasSkippedActions) =>
|
|
|
|
[hasSkippedActions && 'Sweep', 'Commit'].filter((a) => a);
|
2018-12-22 03:10:49 +03:00
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
const ActionListHeader = ({
|
|
|
|
styling,
|
|
|
|
onSearch,
|
|
|
|
hasSkippedActions,
|
|
|
|
hasStagedActions,
|
|
|
|
onCommit,
|
|
|
|
onSweep,
|
2020-08-08 23:26:39 +03:00
|
|
|
hideMainButtons,
|
2019-01-10 21:51:14 +03:00
|
|
|
}) => (
|
|
|
|
<div {...styling('actionListHeader')}>
|
|
|
|
<input
|
|
|
|
{...styling('actionListHeaderSearch')}
|
2020-08-08 23:26:39 +03:00
|
|
|
onChange={(e) => onSearch(e.target.value)}
|
2019-01-10 21:51:14 +03:00
|
|
|
placeholder="filter..."
|
|
|
|
/>
|
|
|
|
{!hideMainButtons && (
|
|
|
|
<div {...styling('actionListHeaderWrapper')}>
|
|
|
|
<RightSlider shown={hasStagedActions} styling={styling}>
|
|
|
|
<div {...styling('actionListHeaderSelector')}>
|
2020-08-08 23:26:39 +03:00
|
|
|
{getActiveButtons(hasSkippedActions).map((btn) => (
|
2019-01-10 21:51:14 +03:00
|
|
|
<div
|
|
|
|
key={btn}
|
|
|
|
onClick={() =>
|
|
|
|
({
|
|
|
|
Commit: onCommit,
|
2020-08-08 23:26:39 +03:00
|
|
|
Sweep: onSweep,
|
2019-01-10 21:51:14 +03:00
|
|
|
}[btn]())
|
|
|
|
}
|
|
|
|
{...styling(
|
|
|
|
['selectorButton', 'selectorButtonSmall'],
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{btn}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</RightSlider>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
export default ActionListHeader;
|