You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by am...@apache.org on 2019/01/30 16:04:07 UTC
[couchdb-fauxton] branch master updated: Show icons to identify
global vs partitioned mango indexes (#1177)
This is an automated email from the ASF dual-hosted git repository.
amaranhao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push:
new 14d1b7a Show icons to identify global vs partitioned mango indexes (#1177)
14d1b7a is described below
commit 14d1b7a6f3cd50aae46135a94320b9365eddbac7
Author: Antonio Maranhao <30...@users.noreply.github.com>
AuthorDate: Wed Jan 30 13:04:01 2019 -0300
Show icons to identify global vs partitioned mango indexes (#1177)
* Show icons to identify global vs partitioned mango indexes
---
app/addons/components/__tests__/doc.test.js | 36 ++++++++++++++++++++++
app/addons/components/components/document.js | 15 ++++++++-
.../components/results/ResultsScreen.js | 5 +--
3 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/app/addons/components/__tests__/doc.test.js b/app/addons/components/__tests__/doc.test.js
index 2f6fb11..6107ca1 100644
--- a/app/addons/components/__tests__/doc.test.js
+++ b/app/addons/components/__tests__/doc.test.js
@@ -142,4 +142,40 @@ describe('Document', () => {
expect(el.find('.doc-content-truncated').length).toBe(0);
});
+ it('shows icon only for docs with type MangoIndex', () => {
+ const index = {
+ type: "json",
+ def: { fields: [{ foo: "asc" }] }
+ };
+ const content = JSON.stringify(index, null, ' ');
+ const elMangoIndex = mount(
+ <ReactComponents.Document docChecked={noop} header="foo" isDeletable={true}
+ checked={false} docIdentifier="foo" docContent={content}
+ truncate={false} docType="MangoIndex"/>
+ );
+ expect(elMangoIndex.find('i.fonticon-document').exists()).toBe(true);
+
+ const elRegularDoc = mount(
+ <ReactComponents.Document docChecked={noop} header="foo" isDeletable={true}
+ checked={false} docIdentifier="foo" docContent={content}
+ truncate={false} docType="view"/>
+ );
+ expect(elRegularDoc.find('i.fonticon-documents').exists()).toBe(false);
+ });
+
+ it('shows icon for partitioned mango index', () => {
+ const index = {
+ type: "json",
+ partitioned: true,
+ def: { fields: [{ foo: "asc" }] }
+ };
+ const content = JSON.stringify(index, null, ' ');
+ const elMangoIndex = mount(
+ <ReactComponents.Document docChecked={noop} header="foo" isDeletable={true}
+ checked={false} docIdentifier="foo" docContent={content}
+ truncate={false} docType="MangoIndex"/>
+ );
+ expect(elMangoIndex.find('i.fonticon-documents').exists()).toBe(true);
+ });
+
});
diff --git a/app/addons/components/components/document.js b/app/addons/components/components/document.js
index c664ee2..abb6a68 100644
--- a/app/addons/components/components/document.js
+++ b/app/addons/components/components/document.js
@@ -20,6 +20,7 @@ import Helpers from '../../documents/helpers';
export class Document extends React.Component {
static propTypes = {
docIdentifier: PropTypes.string.isRequired,
+ docType: PropTypes.string,
docChecked: PropTypes.func.isRequired,
truncate: PropTypes.bool,
maxRows: PropTypes.number,
@@ -31,7 +32,8 @@ export class Document extends React.Component {
maxRows: 500,
resultsStyle: {
fontSize: Constants.INDEX_RESULTS_STYLE.FONT_SIZE_MEDIUM
- }
+ },
+ docType: Constants.INDEX_RESULTS_DOC_TYPE.VIEW
};
onChange = (e) => {
@@ -58,6 +60,16 @@ export class Document extends React.Component {
});
};
+ getDocumentTypeIcon = () => {
+ if (this.props.docType === Constants.INDEX_RESULTS_DOC_TYPE.MANGO_INDEX) {
+ if (this.props.docContent.includes(`"partitioned": true`)) {
+ return <i className="fonticon-documents" title="Partitioned index"></i>;
+ }
+ return <i className="fonticon-document" title="Global index"></i>;
+ }
+ return null;
+ };
+
getCheckbox = () => {
if (!this.props.isDeletable) {
return <div className="checkbox-dummy"></div>;
@@ -118,6 +130,7 @@ export class Document extends React.Component {
<div className="doc-item">
<header onClick={this.onClick}>
<span className="header-keylabel">
+ {this.getDocumentTypeIcon()}
{this.props.keylabel}
</span>
<span className="header-doc-id">
diff --git a/app/addons/documents/index-results/components/results/ResultsScreen.js b/app/addons/documents/index-results/components/results/ResultsScreen.js
index 016f77c..072b8cb 100644
--- a/app/addons/documents/index-results/components/results/ResultsScreen.js
+++ b/app/addons/documents/index-results/components/results/ResultsScreen.js
@@ -51,8 +51,8 @@ export default class ResultsScreen extends React.Component {
}
getDocumentList () {
- let noop = () => {};
- let data = this.props.results.results;
+ const noop = () => {};
+ const data = this.props.results.results;
return _.map(data, (doc, i) => {
return (
<Document
@@ -61,6 +61,7 @@ export default class ResultsScreen extends React.Component {
onClick={this.props.isEditable ? this.onClick : noop}
keylabel={doc.keylabel}
docContent={doc.content}
+ docType={this.props.docType}
checked={this.props.isSelected(doc.id)}
header={doc.header}
docChecked={this.props.docChecked}