Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(ark): Add back to resource button to ARK sub resources #2335

Open
wants to merge 1 commit into
base: fix/1982-icon-display
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions cypress/e2e/phase_1/subresource_ark.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { teardown } from '../../support/authentication';
import * as datasetImportPage from '../../support/datasetImportPage';
import * as menu from '../../support/menu';

describe('Ark subresource', () => {
beforeEach(() => {
teardown();
menu.openAdvancedDrawer();
menu.goToAdminDashboard();
datasetImportPage.importDataset('dataset/subresources-ark-data.json');
datasetImportPage.importModel('model/subresources-ark-model.tar');
});

it('should display a back button when going to subresource', () => {
datasetImportPage.publish();
datasetImportPage.goToPublishedResources();

cy.findByRole('link', {
name: /Search/,
timeout: 500,
})
.should('be.visible')
.click();

cy.findByText('Publication n°1', {
timeout: 500,
})
.should('be.visible')
.click();

cy.findByText('Publication n°1', {
timeout: 500,
})
.should('be.visible')
.click();

cy.findByRole('link', {
name: 'uid:/2acebfc7a1e13123df28821e41424d80',
timeout: 500,
}).click();

cy.findByText('Canidae', {
timeout: 500,
}).should('be.visible');

cy.findByRole('button', {
name: 'Go back to resource',
timeout: 500,
})
.should('be.visible')
.click();

cy.findByRole('link', {
name: 'uid:/2acebfc7a1e13123df28821e41424d80',
timeout: 500,
}).should('be.visible');
});
});
26 changes: 26 additions & 0 deletions cypress/fixtures/dataset/subresources-ark-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"uri": "ark:/67375/WNG-J6G37RM9-Q",
"name": "Publication n°1",
"most_found_animal_species": {
"id": 90,
"name": "Canidae"
}
},
{
"uri": "ark:/67375/WNG-J6G37RM9-R",
"name": "Publication n°2",
"most_found_animal_species": {
"id": 91,
"name": "Felinae"
}
},
{
"uri": "ark:/67375/WNG-J6G37RM9-S",
"name": "Publication n°3",
"most_found_animal_species": {
"id": 90,
"name": "Canidae"
}
}
]
Binary file not shown.
39 changes: 20 additions & 19 deletions src/app/js/public/resource/Resource.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import BackIcon from '@mui/icons-material/ArrowBack';
import HomeIcon from '@mui/icons-material/Home';
import { Button, Card, CardActions, CardContent } from '@mui/material';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import compose from 'recompose/compose';
import { withRouter } from 'react-router-dom';
import translate from 'redux-polyglot/translate';
import HomeIcon from '@mui/icons-material/Home';
import BackIcon from '@mui/icons-material/ArrowBack';
import { CardContent, CardActions, Card, Button } from '@mui/material';
import { Swipeable } from 'react-swipeable';
import compose from 'recompose/compose';
import translate from 'redux-polyglot/translate';

import { fromResource, fromSearch } from '../selectors';
import { fromFields, fromCharacteristic } from '../../sharedSelectors';
import Detail from './Detail';
import RemovedDetail from './RemovedDetail';
import { polyglot as polyglotPropTypes } from '../../propTypes';
import Loading from '../../lib/components/Loading';
import { preLoadResource } from './';
import get from 'lodash/get';
import isEqual from 'lodash/isEqual';
import { getResourceUri } from '../../../../common/uris';
import { preLoadPublication } from '../../fields';
import { preLoadExporters } from '../export';
import Link from '../../lib/components/Link';
import stylesToClassname from '../../lib/stylesToClassName';
import Loading from '../../lib/components/Loading';
import NavButton, { NEXT, PREV } from '../../lib/components/NavButton';
import isEqual from 'lodash/isEqual';
import get from 'lodash/get';
import { getResourceUri } from '../../../../common/uris';
import stylesToClassname from '../../lib/stylesToClassName';
import { polyglot as polyglotPropTypes } from '../../propTypes';
import { fromCharacteristic, fromFields } from '../../sharedSelectors';
import { preLoadExporters } from '../export';
import { fromResource, fromSearch } from '../selectors';
import { preLoadResource } from './';
import Detail from './Detail';
import RemovedDetail from './RemovedDetail';

const navStyles = stylesToClassname(
{
Expand Down Expand Up @@ -96,6 +96,7 @@ export class ResourceComponent extends React.Component {
) {
this.setState({ lastResourceUri: match.params.uri });
} else if (match.params && match.params.naan && match.params.rest) {
// This does not work as state is reset when going from an ARK resource to a subresource
// Ark resources
const lastResourceUri = this._getArkResourceUrl(
match.params.naan,
Expand Down
Loading