Skip to content

Commit

Permalink
Merge pull request #333 from PagerDuty/release/0.10.2-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsreynolds authored Oct 19, 2023
2 parents 7389046 + c5efc4e commit 3b31516
Show file tree
Hide file tree
Showing 15 changed files with 1,061 additions and 826 deletions.
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = defineConfig({
video: false,
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 15000,
defaultCommandTimeout: 30000,
retries: 3,

e2e: {
Expand Down
11 changes: 9 additions & 2 deletions cypress/e2e/Search/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
cy.get('#global-search-input').clear().type('foobar');
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
cy.wrap($el).should('have.text', 'foobar');
// cy.wrap($el).should('have.text', 'foobar');
cy.wrap($el).find('*').should((subElements) => {
const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar'));
assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"');
});
});
});
cy.get('#global-search-input').clear();
Expand All @@ -91,7 +95,10 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
cy.get('#global-search-input').clear().type('foobaz');
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
cy.wrap($el).should('have.text', 'foobar');
cy.wrap($el).find('*').should((subElements) => {
const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar'));
assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"');
});
});
});
cy.get('#global-search-input').clear();
Expand Down
1 change: 1 addition & 0 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const checkIncidentCellContent = (incidentId, incidentHeader, content) =>

export const checkIncidentCellContentAllRows = (incidentHeader, content) => {
cy.wait(2000);
cy.get('.incident-table-fixed-list').scrollTo('top', { ensureScrollable: true });
cy.get('.incident-table-fixed-list > div').then(($tbody) => {
const visibleIncidentCount = $tbody.find('[role="row"]').length;
for (let incidentIdx = 0; incidentIdx < visibleIncidentCount; incidentIdx++) {
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
},
transform: {
'^.+\\.(js|jsx|ts|tsx|mjs)$': 'babel-jest',
'^.+\\.svg$': 'svg-jest',
'^.+\\.svg$': 'jest-transformer-svg',
},
transformIgnorePatterns: ['/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd)'],
transformIgnorePatterns: ['/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd|jsonpath-plus)'],
};
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pd-live-react",
"homepage": "https://pagerduty.github.io/pd-live-react",
"version": "0.10.1-beta.1",
"version": "0.10.2-beta.0",
"private": true,
"dependencies": {
"@chakra-ui/icons": "^2.1.0",
Expand Down Expand Up @@ -43,12 +43,12 @@
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18",
"react-i18next": "^13.1.2",
"react-i18next": "^13.2.0",
"react-icons": "^4.9.0",
"react-intersection-observer": "^9.5.2",
"react-minimal-pie-chart": "^8.4.0",
"react-redux": "^8.1.2",
"react-select": "^5.7.4",
"react-select": "^5.7.7",
"react-table": "^7.8.0",
"react-window": "^1.8.8",
"redux": "^4.2.1",
Expand Down Expand Up @@ -109,7 +109,7 @@
"@testing-library/user-event": "^14.4.3",
"@vitejs/plugin-react": "^4.0.4",
"@welldone-software/why-did-you-render": "^7.0.1",
"babel-jest": "^27.4.2",
"babel-jest": "^29.6.3",
"cypress": "^12.17.1",
"cypress-fail-fast": "^7.0.0",
"cypress-real-events": "^1.10.3",
Expand All @@ -132,19 +132,19 @@
"gh-pages": "^6.0.0",
"i18next-parser": "^8.6.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.4.3",
"jest": "^29.6.3",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-environment-jsdom": "^29.6.3",
"jest-environment-node": "^29.6.3",
"jest-location-mock": "^1.0.10",
"jest-transformer-svg": "^2.0.1",
"prettier": "^2.8.0",
"prettier-eslint": "^15.0.1",
"prettier-eslint-cli": "^7.1.0",
"redux-mock-store": "^1.5.4",
"redux-saga-test-plan": "^4.0.6",
"sass": "^1.66.1",
"string.prototype.replaceall": "^1.0.6",
"svg-jest": "^1.0.1",
"vite": "^4.4.9",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-eslint": "^1.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('IncidentActionsComponent', () => {
settings: {
darkMode: false,
},
connection: { abilities: [] },
};

const tempStoreMap = { ...baseStoreMap };
Expand Down Expand Up @@ -102,4 +103,12 @@ describe('IncidentActionsComponent', () => {

expect(screen.getByRole('button', { name: 'Merge' })).toBeEnabled();
});

it('should deactivate priority button when disable_edit_priority ability is set', () => {
tempStoreMap.connection = { abilities: ['disable_edit_priority'] };
store = mockStore(tempStoreMap);
componentWrapper(store, IncidentActionsComponent);

expect(screen.getByRole('button', { name: 'Update Priority' })).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ const PriorityMenu = () => {
} = useTranslation();
const selectedRows = useSelector((state) => state.incidentTable.selectedRows);
const priorities = useSelector((state) => state.priorities.priorities);
const abilities = useSelector((state) => state.connection.abilities);
const dispatch = useDispatch();
const updatePriority = (incidents, priorityId) => {
dispatch(updatePriorityConnected(incidents, priorityId));
};

const enabled = useMemo(() => selectedRows.length > 0, [selectedRows]);
const enabled = useMemo(() => (
selectedRows.length > 0
&& Array.isArray(abilities)
&& !abilities.includes('disable_edit_priority')
), [selectedRows]);

return (
<Menu>
Expand Down
129 changes: 129 additions & 0 deletions src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React, {
useRef,
useState,
} from 'react';

import {
useDispatch,
} from 'react-redux';

import {
Box,
Flex,
IconButton,
Popover,
PopoverTrigger,
PopoverContent,
PopoverBody,
PopoverArrow,
PopoverCloseButton,
Skeleton,
PopoverHeader,
Textarea,
useDisclosure,
} from '@chakra-ui/react';

import {
AddIcon,
CheckIcon,
} from '@chakra-ui/icons';

import i18next from 'i18next';

import Linkify from 'linkify-react';

import {
addNote as addNoteConnected,
} from 'src/redux/incident_actions/actions';

const linkifyOptions = { target: { url: '_blank' }, rel: 'noopener noreferrer' };

const LatestNoteComponent = ({
incident,
}) => {
const noteRef = useRef(null);
const [note, setNote] = useState('');
const {
isOpen,
onToggle,
onClose,
} = useDisclosure();
const dispatch = useDispatch();
const addNote = (incidents, noteContent) => dispatch(addNoteConnected(incidents, noteContent, true, false));

return (
<Box
position="relative"
width="full"
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Box
className="td-wrapper"
pr={8}
>
<Linkify options={linkifyOptions}>
{incident.notes?.length > 0 && incident.notes.slice(-1)[0].content}
{incident.notes?.length === 0 && '--'}
{incident.notes?.status === 'fetching' && <Skeleton>fetching</Skeleton>}
</Linkify>
</Box>
<Popover
isOpen={isOpen}
onClose={onClose}
initialFocusRef={noteRef}
>
<PopoverTrigger>
<IconButton
size="xs"
position="absolute"
right={0}
top="50%"
transform="translateY(-50%)"
colorScheme="blue"
icon={<AddIcon />}
onClick={() => {
onToggle();
}}
aria-label={i18next.t('Add Note')}
/>
</PopoverTrigger>
<PopoverContent>
<PopoverArrow />
<PopoverCloseButton />
<PopoverHeader>
{i18next.t('Add Note')}
</PopoverHeader>
<PopoverBody>
<Flex>
<Textarea
size="sm"
resize="none"
ref={noteRef}
value={note}
onChange={(e) => {
setNote(e.target.value);
}}
/>
<IconButton
size="sm"
ml={2}
onClick={() => {
addNote([incident], note);
setNote('');
onClose();
}}
isDisabled={!note}
colorScheme="blue"
icon={<CheckIcon />}
/>
</Flex>
</PopoverBody>
</PopoverContent>
</Popover>
</Box>
);
};

export default LatestNoteComponent;
Loading

0 comments on commit 3b31516

Please sign in to comment.