From b8d23bdac374e6bbe8de740d049705d89cb03e2b Mon Sep 17 00:00:00 2001 From: Priyanka Terala <priyanka_terala@epam.com> Date: Sat, 28 Sep 2024 11:56:53 +0530 Subject: [PATCH 1/5] UICAL-285 - Disable 'Actions' menu on DCB Calendar. --- CHANGELOG.md | 4 ++++ src/test/data/Calendars.ts | 10 ++++++++++ src/views/panes/InfoPane.test.tsx | 33 +++++++++++++++++++++++++++++++ src/views/panes/InfoPane.tsx | 3 +++ 4 files changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c31adb..a623c924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 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 diff --git a/src/test/data/Calendars.ts b/src/test/data/Calendars.ts index b8e94e20..aeca9e5e 100644 --- a/src/test/data/Calendars.ts +++ b/src/test/data/Calendars.ts @@ -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: [] +} \ No newline at end of file diff --git a/src/views/panes/InfoPane.test.tsx b/src/views/panes/InfoPane.test.tsx index 34a9404f..015aeae5 100644 --- a/src/views/panes/InfoPane.test.tsx +++ b/src/views/panes/InfoPane.test.tsx @@ -285,6 +285,39 @@ 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>, + ), + ); + + // await act(async () => { + // await userEvent.click(screen.getByRole('button', { name: 'Actions' })); + // }); + + // expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument(); + // expect( + // screen.getByRole('button', { name: 'Duplicate' }), + // ).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'Actions' })).toBeNull(); + }); + it.skip('handles delete', async () => { const props = { creationBasePath: '', diff --git a/src/views/panes/InfoPane.tsx b/src/views/panes/InfoPane.tsx index c7fde3ac..73a9c8cc 100644 --- a/src/views/panes/InfoPane.tsx +++ b/src/views/panes/InfoPane.tsx @@ -120,6 +120,9 @@ export const InfoPane: FunctionComponent<InfoPaneProps> = ( onClose={props.onClose} dismissible actionMenu={({ onToggle }) => { + if ( calendar.name === 'DCB Calendar') { + return null; + } return ifPermissionOr( stripes, [permissions.UPDATE, permissions.CREATE, permissions.DELETE], From b77986a01414e4fb97190706e30415ba1dad6293 Mon Sep 17 00:00:00 2001 From: Priyanka Terala <priyanka_terala@epam.com> Date: Sat, 28 Sep 2024 12:00:14 +0530 Subject: [PATCH 2/5] UICAL-285 - upgrade versions of upload-artifact actions in CI workflows --- .github/workflows/build-npm-release.yml | 4 ++-- .github/workflows/build-npm.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-npm-release.yml b/.github/workflows/build-npm-release.yml index 75d20a0a..d40064e8 100644 --- a/.github/workflows/build-npm-release.yml +++ b/.github/workflows/build-npm-release.yml @@ -151,7 +151,7 @@ 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 @@ -159,7 +159,7 @@ jobs: retention-days: 30 - name: Publish yarn.lock - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: yarn.lock diff --git a/.github/workflows/build-npm.yml b/.github/workflows/build-npm.yml index afe48470..3a64b625 100644 --- a/.github/workflows/build-npm.yml +++ b/.github/workflows/build-npm.yml @@ -90,7 +90,7 @@ 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 @@ -98,7 +98,7 @@ jobs: retention-days: 30 - name: Publish yarn.lock - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: yarn.lock From f6232dd52c06a348fe10cd0885e26ab423df3782 Mon Sep 17 00:00:00 2001 From: Priyanka Terala <priyanka_terala@epam.com> Date: Sat, 28 Sep 2024 12:18:37 +0530 Subject: [PATCH 3/5] UICAL-285 - refine --- src/views/panes/InfoPane.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/panes/InfoPane.tsx b/src/views/panes/InfoPane.tsx index 73a9c8cc..cc34ff4e 100644 --- a/src/views/panes/InfoPane.tsx +++ b/src/views/panes/InfoPane.tsx @@ -32,6 +32,7 @@ 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; @@ -120,7 +121,7 @@ export const InfoPane: FunctionComponent<InfoPaneProps> = ( onClose={props.onClose} dismissible actionMenu={({ onToggle }) => { - if ( calendar.name === 'DCB Calendar') { + if (calendar.name === DCB_CALENDAR) { return null; } return ifPermissionOr( From 2da99241568d8a899858ec5c1be1fa9bf5f777c3 Mon Sep 17 00:00:00 2001 From: Priyanka Terala <priyanka_terala@epam.com> Date: Sat, 28 Sep 2024 12:25:43 +0530 Subject: [PATCH 4/5] fix few lint issues --- src/test/data/Calendars.ts | 8 ++++---- src/views/panes/InfoPane.tsx | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/data/Calendars.ts b/src/test/data/Calendars.ts index aeca9e5e..752c903d 100644 --- a/src/test/data/Calendars.ts +++ b/src/test/data/Calendars.ts @@ -229,11 +229,11 @@ export const SUMMER_SP_4_245: CalendarDTO = { }; export const DCB: CalendarDTO = { - id: "f3fde29e-59f7-47a6-8109-af6cb92acde5", - name: "DCB Calendar", - assignments: ["9d1b77e8-f02e-4b7f-b296-3f2042ddac54"], + 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: [] -} \ No newline at end of file +}; diff --git a/src/views/panes/InfoPane.tsx b/src/views/panes/InfoPane.tsx index cc34ff4e..7b34e6c7 100644 --- a/src/views/panes/InfoPane.tsx +++ b/src/views/panes/InfoPane.tsx @@ -33,6 +33,7 @@ import ifPermissionOr from '../../utils/ifPermissionOr'; import css from './InfoPane.css'; const DCB_CALENDAR = 'DCB Calendar'; + export interface InfoPaneProps { creationBasePath: string; editBasePath: string; From 4108ca10b8097a14173fb704f18cd7bad77a21ab Mon Sep 17 00:00:00 2001 From: Priyanka Terala <priyanka_terala@epam.com> Date: Sun, 29 Sep 2024 06:49:59 +0530 Subject: [PATCH 5/5] UICAL-285 - remove commented code --- src/views/panes/InfoPane.test.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/views/panes/InfoPane.test.tsx b/src/views/panes/InfoPane.test.tsx index 015aeae5..dfd55765 100644 --- a/src/views/panes/InfoPane.test.tsx +++ b/src/views/panes/InfoPane.test.tsx @@ -307,14 +307,6 @@ describe('Calendar info pane', () => { ), ); - // await act(async () => { - // await userEvent.click(screen.getByRole('button', { name: 'Actions' })); - // }); - - // expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument(); - // expect( - // screen.getByRole('button', { name: 'Duplicate' }), - // ).toBeInTheDocument(); expect(screen.queryByRole('button', { name: 'Actions' })).toBeNull(); });