Skip to content

Commit

Permalink
Merge branch 'master' into b11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Oct 1, 2024
2 parents 7081869 + 66afcdf commit c45202a
Show file tree
Hide file tree
Showing 15 changed files with 517 additions and 229 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
path: ${{ env.JEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
path: ${{ env.JEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change history for ui-calendar

## In progress

* Disable 'Actions' menu on DCB Calendar. Refs UICAL-285.

## [11.0.1] (https://github.com/folio-org/ui-calendar/tree/v11.0.1) (2024-05-08)

* Address empty fourth pane on open of 'Current calendar assignment'. Refs UICAL-283
* Fix failing tests. Refs UICAL-281

## [11.0.0] (https://github.com/folio-org/ui-calendar/tree/v11.0.0) (2024-03-19)

* Add page titles. Refs UICAL-272
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/calendar",
"version": "11.0.0",
"version": "11.0.1",
"description": "Calendar settings",
"repository": "folio-org/ui-calendar",
"publishConfig": {
Expand Down Expand Up @@ -144,7 +144,7 @@
"fuzzysort": "^2.0.4",
"history": "^4.7.11",
"ky": "^0.31.1",
"memoizee": "^0.4.15",
"memoizee": "0.4.15",
"react-final-form": "^6.5.9",
"react-final-form-arrays": "^3.1.4",
"utility-types": "^3.10.0"
Expand Down
48 changes: 48 additions & 0 deletions src/components/fields/MCLRowFormatter.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { render, screen } from '@testing-library/react'
import React from 'react'
import MCLRowFormatter from './MCLRowFormatter'
import { MCLContentsType } from './ExceptionFieldTypes';
import RowType from './RowType';

describe('MCLRowFormatter', () => {
it('Renders the formatter correctly', async () => {
render(
<MCLRowFormatter<MCLContentsType>
rowClass='test-classname'
rowWidth={1}
rowIndex={1}
labelStrings={['foo']}
cells={[<h1 key='foo'>test</h1>]}
rowData={
{ rowState:
{ i: 1,
name: 'foo',
type: RowType.Open,
lastRowI: 1,
rows: [{
i: 1,
startDate: undefined,
startTime: undefined,
endDate: undefined,
endTime: undefined
}]
},
name: undefined,
status: undefined,
startDate: undefined,
startTime: undefined,
endDate: undefined,
endTime: undefined,
actions: undefined,
isConflicted: false
}
}
rowProps={{} as any}
/>
);

expect(await screen.findByRole('heading')).toBeInTheDocument();
expect((await screen.findByRole('heading')).textContent).toBe('test');
expect((await screen.findByRole('heading')).parentElement?.className).toBe('test-classname');
});
});
59 changes: 59 additions & 0 deletions src/components/fields/TimeField.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { fireEvent, render, screen } from "@testing-library/react";
import React from 'react'
import { IntlProvider } from "react-intl";
import TimeField from "./TimeField";
import userEvent from "@testing-library/user-event";

describe('TimeField', () => {
it('Renders the TimeField correctly', async () => {
render(
<IntlProvider locale="en">
<TimeField
display={true}
value={undefined}
inputRef={() => {}}
error={undefined}
onBlur={() => {}}
onChange={() => {}}
/>
</IntlProvider>
);

expect(await screen.findByRole('textbox')).toBeInTheDocument();
expect(await screen.findByRole('textbox')).toHaveValue('');
});

it('Renders nothing when display is false', async () => {
render(
<IntlProvider locale="en">
<TimeField
display={false}
value='test'
inputRef={() => {}}
error={undefined}
onBlur={() => {}}
onChange={() => {}}
/>
</IntlProvider>
);

expect(await screen.queryByRole('textbox')).toBeNull();
});

it('Formatse time correctly', async () => {
render(
<IntlProvider locale="en">
<TimeField
display={true}
value='12:30:00'
inputRef={() => {}}
error={undefined}
onBlur={() => {}}
onChange={() => {}}
/>
</IntlProvider>
);

expect(await screen.findByRole('textbox')).toHaveValue('12:30 PM');
});
});
10 changes: 10 additions & 0 deletions src/test/data/Calendars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,13 @@ export const SUMMER_SP_4_245: CalendarDTO = {
],
exceptions: []
};

export const DCB: CalendarDTO = {
id: 'f3fde29e-59f7-47a6-8109-af6cb92acde5',
name: 'DCB Calendar',
assignments: ['9d1b77e8-f02e-4b7f-b296-3f2042ddac54'],
startDate: '2000-01-01',
endDate: '2000-04-30',
normalHours: [],
exceptions: []
};
4 changes: 2 additions & 2 deletions src/views/CurrentAssignmentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const CurrentAssignmentView: FunctionComponent<
const history = useHistory();
const currentRouteId = useRouteMatch<{ servicePointId: string }>(
'/settings/calendar/active/:servicePointId'
)?.params?.servicePointId ?? '';
)?.params?.servicePointId;

if (!dataRepository.isLoaded()) {
return (
Expand Down Expand Up @@ -93,7 +93,7 @@ export const CurrentAssignmentView: FunctionComponent<
};
});

const calendarName = dataRepository.getCalendars().filter((c) => c.assignments.includes(currentRouteId))[0]?.name ?? '';
const calendarName = dataRepository.getCalendars().filter((c) => c.assignments.includes(currentRouteId ?? ''))[0]?.name ?? '';

const pageTitle = intl.formatMessage({ id: 'ui-calendar.meta.titleSettings' }) + ' - ' + intl.formatMessage({
id: 'ui-calendar.currentAssignmentView.title'
Expand Down
25 changes: 25 additions & 0 deletions src/views/panes/InfoPane.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,31 @@ describe('Calendar info pane', () => {
expect(screen.getByRole('button', { name: 'Delete' })).toBeInTheDocument();
});

it('should not render action buttons for DCB calendar', async () => {
const props = {
creationBasePath: '',
editBasePath: '',
calendar: Calendars.DCB,
onClose: jest.fn(),
dataRepository: new DataRepository(undefined, undefined, {
create: jest.fn(),
update: jest.fn(),
delete: jest.fn(),
dates: jest.fn(),
}),
};

render(
withEverything(
<Paneset>
<InfoPane {...props} />
</Paneset>,
),
);

expect(screen.queryByRole('button', { name: 'Actions' })).toBeNull();
});

it.skip('handles delete', async () => {
const props = {
creationBasePath: '',
Expand Down
18 changes: 15 additions & 3 deletions src/views/panes/InfoPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { generateExceptionalOpeningRows } from '../../utils/InfoPaneUtils';
import ifPermissionOr from '../../utils/ifPermissionOr';
import css from './InfoPane.css';

const DCB_CALENDAR = 'DCB Calendar';

export interface InfoPaneProps {
creationBasePath: string;
editBasePath: string;
Expand Down Expand Up @@ -82,14 +84,21 @@ export const InfoPane: FunctionComponent<InfoPaneProps> = (
} else {
exception.openings.sort((a, b) => {
return Math.sign(
new Date(`${a.startDate} ${a.endDate}`).getTime() -
new Date(`${b.startDate} ${b.endDate}`).getTime(),
new Date(`${a.startDate}`).getTime() -
new Date(`${b.startDate}`).getTime(),
);
});
ex.openings.push(exception);
}
});

ex.openings.sort((a, b) => {
return Math.sign(
new Date(`${a.startDate}`).getTime() -
new Date(`${b.startDate}`).getTime(),
);
});

return {
openings: generateExceptionalOpeningRows(intl, ex.openings),
closures: ex.closures.map((exception) => ({
Expand All @@ -108,11 +117,14 @@ export const InfoPane: FunctionComponent<InfoPaneProps> = (
<>
<Pane
paneTitle={calendar.name}
defaultWidth="fill"
defaultWidth="30%"
centerContent
onClose={props.onClose}
dismissible
actionMenu={({ onToggle }) => {
if (calendar.name === DCB_CALENDAR) {
return null;
}
return ifPermissionOr(
stripes,
[permissions.UPDATE, permissions.CREATE, permissions.DELETE],
Expand Down
34 changes: 17 additions & 17 deletions translations/ui-calendar/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"calendarForm.exceptions.column.endDate": "End date",
"calendarForm.exceptions.column.endTime": "End time",
"calendarForm.exceptions.column.actions": "Actions",
"calendarForm.openClosedSelect.open": "Open",
"calendarForm.openClosedSelect.closed": "Closed",
"calendarForm.openClosedSelect.open": "Ouvert",
"calendarForm.openClosedSelect.closed": "Fermé",
"calendarForm.error.dateFormat": "Please enter a date in the {localeDateFormat} format",
"calendarForm.error.dateOrder": "End date must not be before the start date",
"calendarForm.error.timeFormat": "Please enter a time in the {localeTimeFormat} format",
Expand All @@ -47,18 +47,18 @@
"currentStatus.open.exceptional.nextWeek": "Open ({exceptionName}) until {nextWeekday} at {nextTime}",
"currentStatus.open.exceptional.sameElse": "Open ({exceptionName}) until {nextDate} at {nextTime}",
"currentStatus.open.exceptional.otherWeekday": "Open ({exceptionName}) until {nextWeekday} at {nextTime}",
"currentStatus.closed.noNext": "Closed",
"currentStatus.closed.sameDay": "Closed until {nextTime}",
"currentStatus.closed.nextDay": "Closed until tomorrow at {nextTime}",
"currentStatus.closed.nextWeek": "Closed until {nextWeekday} at {nextTime}",
"currentStatus.closed.sameElse": "Closed until {nextDate} at {nextTime}",
"currentStatus.closed.otherWeekday": "Closed until {nextWeekday} at {nextTime}",
"currentStatus.closed.exceptional.noNext": "Closed ({exceptionName})",
"currentStatus.closed.exceptional.sameDay": "Closed ({exceptionName}) until {nextTime}",
"currentStatus.closed.exceptional.nextDay": "Closed ({exceptionName}) until tomorrow at {nextTime}",
"currentStatus.closed.exceptional.nextWeek": "Closed ({exceptionName}) until {nextWeekday} at {nextTime}",
"currentStatus.closed.exceptional.sameElse": "Closed ({exceptionName}) until {nextDate} at {nextTime}",
"currentStatus.closed.exceptional.otherWeekday": "Closed ({exceptionName}) until {nextWeekday} at {nextTime}",
"currentStatus.closed.noNext": "Fermé",
"currentStatus.closed.sameDay": "Fermé jusqu’à {nextTime}",
"currentStatus.closed.nextDay": "Fermé jusqu'à demain {nextTime}",
"currentStatus.closed.nextWeek": "Fermé jusqu'à {nextWeekday} à {nextTime}",
"currentStatus.closed.sameElse": "Fermé jusqu'au {nextDate} à {nextTime}",
"currentStatus.closed.otherWeekday": "Fermé jusqu'à {nextWeekday} à {nextTime}",
"currentStatus.closed.exceptional.noNext": "Fermé ({exceptionName})",
"currentStatus.closed.exceptional.sameDay": "Fermé ({exceptionName}) jusqu'à {nextTime}",
"currentStatus.closed.exceptional.nextDay": "Fermé ({exceptionName}) jusqu'à demain {nextTime}",
"currentStatus.closed.exceptional.nextWeek": "Fermé ({exceptionName}) jusqu'à {nextWeekday} à {nextTime}",
"currentStatus.closed.exceptional.sameElse": "Fermé ({exceptionName}) jusqu'au {nextDate} à {nextTime}",
"currentStatus.closed.exceptional.otherWeekday": "Fermé ({exceptionName}) jusqu'à {nextWeekday} à {nextTime}",
"purgeModal.label": "Purge old calendars",
"purgeModal.criteria.age.prompt": "Purge calendars that ended...",
"purgeModal.criteria.age.months3": "more than 3 months ago",
Expand Down Expand Up @@ -91,9 +91,9 @@
"infoPane.accordion.exceptions.end": "Close",
"infoPane.deletionModal.label": "Confirm deletion",
"infoPane.deletionModal.contents": "Are you sure you would like to delete the calendar “{name}”?",
"infoPane.display.closed": "Closed",
"infoPane.display.closed": "Fermé",
"infoPane.display.wrappedOpening": "The service point does not close on the previous night",
"infoPane.display.wrappedClosed": "The service point does not close on this night",
"infoPane.display.wrappedClosed": "Ce point de service ne ferme pas ce soir.",
"infoPane.display.closesAfterMidnight": "Closes on the next day",
"infoPane.display.closesAfterMidnightTime": "{time} *",
"allCalendarView.title": "All calendars",
Expand All @@ -115,7 +115,7 @@
"currentAssignmentView.column.currentStatus": "Current status",
"monthlyCalendarView.title": "Monthly calendar view",
"monthlyCalendarView.day.allDay": "All day",
"monthlyCalendarView.day.closed": "Closed",
"monthlyCalendarView.day.closed": "Fermé",
"monthlyCalendarView.day.timeRange": "{startTime} – {endTime}",
"permission.create": "Settings (Calendar): Can create and assign new calendars",
"permission.update": "Settings (Calendar): Can edit and reassign existing calendars",
Expand Down
Loading

0 comments on commit c45202a

Please sign in to comment.