forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI improvements to cards and preview panel (#620)
- Loading branch information
1 parent
7f57ae2
commit 486d8d9
Showing
15 changed files
with
268 additions
and
104 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
geonode_mapstore_client/client/js/components/ALink/ALink.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function ALink({ href, readOnly, children }) { | ||
return readOnly ? children : <a href={href}>{children}</a>; | ||
} | ||
|
||
ALink.PropTypes = { | ||
href: PropTypes.string, | ||
readOnly: PropTypes.bool.isRequired, | ||
children: PropTypes.any | ||
}; | ||
|
||
ALink.defaultProps = { | ||
href: '', | ||
readOnly: false | ||
}; | ||
|
||
export default ALink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ALink'; |
32 changes: 32 additions & 0 deletions
32
geonode_mapstore_client/client/js/components/AuthorInfo/AuthorInfo.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { getUserName } from '@js/utils/SearchUtils'; | ||
import ALink from '@js/components/ALink'; | ||
|
||
function AuthorInfo({ resource, readOnly, formatHref, ...props}) { | ||
|
||
return (<p className="card-text gn-card-user" {...props}> | ||
{resource.owner?.avatar && | ||
<img src={resource.owner.avatar} alt={getUserName(resource.owner)} className="gn-card-author-image" />} | ||
<ALink readOnly={readOnly} href={formatHref({ | ||
query: { | ||
'filter{owner.username.in}': resource.owner?.username | ||
} | ||
})}>{resource.owner && getUserName(resource.owner)}</ALink> | ||
</p>); | ||
} | ||
|
||
AuthorInfo.PropTypes = { | ||
resource: PropTypes.object, | ||
readOnly: PropTypes.bool, | ||
formatHref: PropTypes.func, | ||
props: PropTypes.any | ||
}; | ||
|
||
AuthorInfo.defaultProps = { | ||
resource: {}, | ||
readOnly: false, | ||
formatHref: () => '#' | ||
}; | ||
|
||
export default AuthorInfo; |
1 change: 1 addition & 0 deletions
1
geonode_mapstore_client/client/js/components/AuthorInfo/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './AuthorInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
geonode_mapstore_client/client/js/components/__tests__/ALink-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2016, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import expect from 'expect'; | ||
import ALink from '../ALink'; | ||
|
||
describe('ALink test', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('render ALink', () => { | ||
ReactDOM.render(<ALink />, document.getElementById("container")); | ||
const aLink = document.querySelector('a'); | ||
expect(aLink).toExist(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
geonode_mapstore_client/client/js/components/__tests__/AuthorInfo-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2016, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import expect from 'expect'; | ||
import AuthorInfo from '../AuthorInfo'; | ||
|
||
describe('AuthorInfo test', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('render AuthorInfo', () => { | ||
ReactDOM.render(<AuthorInfo />, document.getElementById("container")); | ||
const authorInfo = document.querySelector('.gn-card-user'); | ||
expect(authorInfo).toExist(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.