Skip to content

Commit

Permalink
Update action menu
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-blazhko committed Dec 27, 2024
1 parent 460b29a commit 1747190
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 224 deletions.
223 changes: 110 additions & 113 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
Checkbox,
filters2cql,
FormattedTime,
MenuSection,
TextLink,
DefaultMCLRowFormatter,
NoValue,
Expand Down Expand Up @@ -1460,121 +1459,120 @@ class RequestsRoute extends React.Component {

const actionMenu = ({ onToggle, renderColumnsMenu }) => (
<>
<MenuSection label={intl.formatMessage({ id: 'ui-requests.actions.label' })}>
<IfPermission perm="ui-requests.create">
<Button
buttonStyle="dropdownItem"
id="clickable-newrequest"
to={`${this.props.location.pathname}?layer=create`}
onClick={onToggle}
>
<Icon icon="plus-sign">
<FormattedMessage id="stripes-smart-components.new" />
</Icon>
</Button>
</IfPermission>
{csvReportPending ?
<IfPermission perm="ui-requests.create">
<Button
buttonStyle="dropdownItem"
id="clickable-newrequest"
to={`${this.props.location.pathname}?layer=create`}
onClick={onToggle}
>
<Icon icon="plus-sign">
<FormattedMessage id="stripes-smart-components.new" />
</Icon>
</Button>
</IfPermission>
{csvReportPending ?
<LoadingButton>
<FormattedMessage id="ui-requests.csvReportPending" />
</LoadingButton> :
<Button
buttonStyle="dropdownItem"
id="exportToCsvPaneHeaderBtn"
disabled={!requestCount}
onClick={() => {
this.context.sendCallout({ message: <FormattedMessage id="ui-requests.csvReportInProgress" /> });
onToggle();
this.exportData();
}}
>
<Icon icon="download">
<FormattedMessage id="ui-requests.exportSearchResultsCsv" />
</Icon>
</Button>
}
{
isPickSlipsArePending ?
<LoadingButton>
<FormattedMessage id="ui-requests.csvReportPending" />
<FormattedMessage id="ui-requests.pickSlipsLoading" />
</LoadingButton> :
<Button
buttonStyle="dropdownItem"
id="exportToCsvPaneHeaderBtn"
disabled={!requestCount}
onClick={() => {
this.context.sendCallout({ message: <FormattedMessage id="ui-requests.csvReportInProgress" /> });
onToggle();
this.exportData();
}}
>
<Icon icon="download">
<FormattedMessage id="ui-requests.exportSearchResultsToCsv" />
</Icon>
</Button>
}
{
isPickSlipsArePending ?
<LoadingButton>
<FormattedMessage id="ui-requests.pickSlipsLoading" />
</LoadingButton> :
<>
<Button
data-testid="exportExpiredHoldShelfToCsvButton"
buttonStyle="dropdownItem"
id="exportExpiredHoldsToCsvPaneHeaderBtn"
disabled={holdsShelfReportPending || (servicePointId && requestsEmpty)}
onClick={() => {
<>
<Button
data-testid="exportExpiredHoldShelfToCsvButton"
buttonStyle="dropdownItem"
id="exportExpiredHoldsToCsvPaneHeaderBtn"
disabled={holdsShelfReportPending || (servicePointId && requestsEmpty)}
onClick={() => {
onToggle();
this.exportExpiredHoldsToCSV();
}}
>
<Icon icon="report">
<FormattedMessage
id="ui-requests.exportExpiredHoldShelfCsv"
values={{ currentServicePoint: servicePointName }}
/>
</Icon>
</Button>
<PrintButton
buttonStyle="dropdownItem"
id="printPickSlipsBtn"
disabled={isPickSlipsEmpty}
template={pickSlipsPrintTemplate}
contentRef={this.pickSlipsPrintContentRef}
onBeforeGetContent={() => this.onBeforeGetContentForPrintButton(onToggle)}
onBeforePrint={async () => {
if (isViewPrintDetailsEnabled) {
const requestIds = extractPickSlipRequestIds(pickSlipsData);
await this.savePrintEventDetails(requestIds);
}
}}
onAfterPrint={this.onAfterPrintForPrintButton}
>
<Icon icon="print">
<FormattedMessage
id="ui-requests.printPickSlipsForSp"
values={{ sp: servicePointName }}
/>
</Icon>
</PrintButton>
<PrintButton
buttonStyle="dropdownItem"
id="printSelectedPickSlipsBtn"
disabled={isPrintingDisabled}
template={pickSlipsPrintTemplate}
contentRef={this.printSelectedContentRef}
onBeforeGetContent={
() => new Promise(resolve => {
this.context.sendCallout({ message: <FormattedMessage id="ui-requests.printInProgress" /> });
onToggle();
this.exportExpiredHoldsToCSV();
}}
>
<Icon icon="download">
<FormattedMessage
id="ui-requests.exportExpiredHoldShelfToCsv"
values={{ currentServicePoint: servicePointName }}
/>
</Icon>
</Button>
<PrintButton
buttonStyle="dropdownItem"
id="printPickSlipsBtn"
disabled={isPickSlipsEmpty}
template={pickSlipsPrintTemplate}
contentRef={this.pickSlipsPrintContentRef}
onBeforeGetContent={() => this.onBeforeGetContentForPrintButton(onToggle)}
onBeforePrint={async () => {
// without the timeout the printing process starts right away
// and the callout and onToggle above are blocked
setTimeout(() => resolve(), 1000);
multiSelectPickSlipData = getSelectedSlipDataMulti(pickSlipsData, selectedRows);
})
}
onBeforePrint={
async () => {
if (isViewPrintDetailsEnabled) {
const requestIds = extractPickSlipRequestIds(pickSlipsData);
await this.savePrintEventDetails(requestIds);
}
}}
onAfterPrint={this.onAfterPrintForPrintButton}
>
<Icon icon="print">
<FormattedMessage
id="ui-requests.printPickSlips"
values={{ sp: servicePointName }}
/>
</Icon>
</PrintButton>
<PrintButton
buttonStyle="dropdownItem"
id="printSelectedPickSlipsBtn"
disabled={isPrintingDisabled}
template={pickSlipsPrintTemplate}
contentRef={this.printSelectedContentRef}
onBeforeGetContent={
() => new Promise(resolve => {
this.context.sendCallout({ message: <FormattedMessage id="ui-requests.printInProgress" /> });
onToggle();
// without the timeout the printing process starts right away
// and the callout and onToggle above are blocked
setTimeout(() => resolve(), 1000);
multiSelectPickSlipData = getSelectedSlipDataMulti(pickSlipsData, selectedRows);
})
}
onBeforePrint={
async () => {
if (isViewPrintDetailsEnabled) {
const selectedPickSlips = getSelectedSlipDataMulti(pickSlipsData, selectedRows);
const selectedRequestIds = extractPickSlipRequestIds(selectedPickSlips);
await this.savePrintEventDetails(selectedRequestIds);
}
const selectedPickSlips = getSelectedSlipDataMulti(pickSlipsData, selectedRows);
const selectedRequestIds = extractPickSlipRequestIds(selectedPickSlips);
await this.savePrintEventDetails(selectedRequestIds);
}
}
onAfterPrint={this.onAfterPrintForPrintButton}
>
<Icon icon="print">
<FormattedMessage
id="ui-requests.printPickSlipsSelected"
values={{ sp: servicePointName }}
/>
</Icon>
</PrintButton>
</>
}
{
isPrintHoldRequestsEnabled &&
}
onAfterPrint={this.onAfterPrintForPrintButton}
>
<Icon icon="print">
<FormattedMessage
id="ui-requests.printSelectedPickSlipsForSp"
values={{ sp: servicePointName }}
/>
</Icon>
</PrintButton>
</>
}
{
isPrintHoldRequestsEnabled &&
<>
{
isSearchSlipsArePending ?
Expand All @@ -1591,15 +1589,14 @@ class RequestsRoute extends React.Component {
>
<Icon icon="print">
<FormattedMessage
id="ui-requests.printSearchSlips"
id="ui-requests.printSearchSlipsForSp"
values={{ sp: servicePointName }}
/>
</Icon>
</PrintButton>
}
</>
}
</MenuSection>
}
{renderColumnsMenu}
</>
);
Expand Down
8 changes: 4 additions & 4 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ const request = {
const labelIds = {
closedCancelledRequest: requestStatusesTranslations[requestStatuses.CANCELLED],
requestType: requestTypesTranslations[requestTypesMap.RECALL],
printPickSlips: 'ui-requests.printPickSlips',
printSearchSlips: 'ui-requests.printSearchSlips',
printPickSlips: 'ui-requests.printPickSlipsForSp',
printSearchSlips: 'ui-requests.printSearchSlipsForSp',
titleWithSearch: 'ui-requests.documentTitle.search',
defaultTitle: 'ui-requests.meta.title',
recordsSelected: 'ui-requests.rows.recordsSelected',
Expand Down Expand Up @@ -611,7 +611,7 @@ describe('RequestsRoute', () => {
});

it('should trigger "exportCsv"', async () => {
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsToCsv' }));
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
Expand Down Expand Up @@ -820,7 +820,7 @@ describe('RequestsRoute', () => {

it('should trigger "exportCsv"', async () => {
renderComponent(getPropsWithSortInQuery());
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsToCsv' }));
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
Expand Down
Loading

0 comments on commit 1747190

Please sign in to comment.