Skip to content

Commit

Permalink
Merge pull request #1053 from nasa/develop
Browse files Browse the repository at this point in the history
merge develop branch back to master for v10.0.0
  • Loading branch information
jennyhliu authored Feb 25, 2022
2 parents 3f4888e + 589ec77 commit c8499dd
Show file tree
Hide file tree
Showing 13 changed files with 1,467 additions and 2,377 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": false,
"extends": [
"airbnb-base",
"standard",
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v10.0.0] - 2022-02-25

## Breaking Changes

This version of the dashboard requires Cumulus API v10.1.0

### Changed

- **CUMULUS-2843**
- Create provider and create rule modals now dislpay the provider [rule]
schema title directly as read from the Cumulus API.

## [v9.0.0] - 2022-02-01

## Breaking Changes
Expand Down Expand Up @@ -1226,7 +1238,8 @@ Fix for serving the dashboard through the Cumulus API.
### Added

- Versioning and changelog [CUMULUS-197] by @kkelly51
[Unreleased]: https://github.com/nasa/cumulus-dashboard/compare/v9.0.0...HEAD
[Unreleased]: https://github.com/nasa/cumulus-dashboard/compare/v10.0.0...HEAD
[v10.0.0]: https://github.com/nasa/cumulus-dashboard/compare/v9.0.0...v10.0.0
[v9.0.0]: https://github.com/nasa/cumulus-dashboard/compare/v8.0.0...v9.0.0
[v8.0.0]: https://github.com/nasa/cumulus-dashboard/compare/v7.1.0...v8.0.0
[v7.1.0]: https://github.com/nasa/cumulus-dashboard/compare/v7.0.0...v7.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Alert } from 'react-bootstrap';
import DefaultModal from '../Modal/modal';
import {
collectionName as collectionLabelForId,
} from '../../utils/format';

class DeleteCollectionModal extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -40,7 +37,7 @@ class DeleteCollectionModal extends React.Component {
<p> You have submitted a request to delete the following collection: </p>
<br />
<h1>
<strong>{collectionLabelForId(this.props.collectionLabel)}</strong>
<strong>{this.props.collectionLabel}</strong>
</h1>
<br />
<p> Are you sure you want to permanently delete this collection? </p>
Expand Down
4 changes: 2 additions & 2 deletions app/src/js/components/FormSchema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { get, set } from 'object-path';
import startCase from 'lodash/startCase';
import noop from 'lodash/noop';
import startCase from 'lodash/startCase';
import { Form, formTypes } from '../Form/Form';
import {
arrayWithLength,
Expand Down Expand Up @@ -104,7 +104,7 @@ export const createFormConfig = ({
isArray(schemaProperty.required) &&
schemaProperty.required.includes(property);

const labelText = startCase(meta.title || property);
const labelText = meta.title || startCase(property);
const label = (
<span>
<span className="label__name">{labelText}</span>
Expand Down
2 changes: 1 addition & 1 deletion app/src/js/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const deploymentConfig = require('./config');
const baseConfig = {
environment: 'development',
requireEarthdataLogin: false,
minCompatibleApiVersion: 'v10.0.0',
minCompatibleApiVersion: 'v10.1.0',
oauthMethod: 'earthdata',

graphicsPath: '/src/assets/images/',
Expand Down
79 changes: 48 additions & 31 deletions app/src/js/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,52 @@ export const truncate = (string, to = 100) => {
return `${string.slice(0, to)}...`;
};

const collectionIdSeparator = '___';
/**
* Returns the name and version of a collection based on
* the collectionId used in elasticsearch indexing
*
* @param {string} collectionId - collectionId used in elasticsearch index
* @returns {Object} name and version as object
*/
export const deconstructCollectionId = (collectionId) => {
let name;
let version;
try {
const last = collectionId.lastIndexOf(collectionIdSeparator);
name = collectionId.substring(0, last);
version = collectionId.substring(last + collectionIdSeparator.length);
if (name && version) {
return {
name,
version,
};
}
} catch (error) {
// do nothing error thrown below
}
if (collectionId && collectionId.match(' / ')) {
console.debug(`deconstructCollectionId called with previously deconstructed ID ${collectionId}`);
return collectionId;
}
throw new Error(`invalid collectionId: ${JSON.stringify(collectionId)}`);
};

// "MYD13A1___006" => "MYD13A1 / 006"
// "trailing_____1.0" => "trailing__ / 1.0"
export const collectionName = (collectionId) => {
if (!collectionId) return nullValue;
const collection = deconstructCollectionId(collectionId);
return `${collection.name} / ${collection.version}`;
};

export const collectionNameVersion = (collectionId) => {
if (!collectionId) return nullValue;
return deconstructCollectionId(collectionId);
};

export const constructCollectionId = (name, version) => `${name}${collectionIdSeparator}${version}`;

export const getFormattedCollectionId = (collection) => {
const collectionId = getCollectionId(collection);
return formatCollectionId(collectionId);
Expand All @@ -341,46 +387,17 @@ export const formatCollectionId = (collectionId) => (collectionId === undefined

export const getCollectionId = (collection) => {
if (collection && collection.name && collection.version) {
return `${collection.name}___${collection.version}`;
return constructCollectionId(collection.name, collection.version);
}
};

export const getEncodedCollectionId = (collection) => {
if (collection && collection.name && collection.version) {
return `${collection.name}___${encodeURIComponent(collection.version)}`;
return constructCollectionId(collection.name, encodeURIComponent(collection.version));
}
return nullValue;
};

// "MYD13A1___006" => "MYD13A1 / 006"
export const collectionName = (collectionId) => {
if (!collectionId) return nullValue;
return collectionId.split('___').join(' / ');
};

export const collectionNameVersion = (collectionId) => {
if (!collectionId) return nullValue;
const [name, version] = collectionId.split('___');
return { name, version };
};

export const constructCollectionNameVersion = (name, version) => `${name}___${version}`;

/**
* Returns the name and version of a collection based on
* the collectionId used in elasticsearch indexing
*
* @param {string} collectionId - collectionId used in elasticsearch index
* @returns {Object} name and version as object
*/
export const deconstructCollectionId = (collectionId) => {
const [name, version] = collectionId.split('___');
return {
name,
version,
};
};

export const collectionLink = (collectionId) => {
if (!collectionId || collectionId === nullValue) return nullValue;
return (
Expand Down
9 changes: 5 additions & 4 deletions cypress/integration/pdrs_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { shouldBeRedirectedToLogin } from '../support/assertions';
import { collectionName, collectionHrefFromId } from '../../app/src/js/utils/format';

describe('Dashboard PDRs Page', () => {
describe('When not logged in', () => {
Expand Down Expand Up @@ -159,8 +160,8 @@ describe('Dashboard PDRs Page', () => {
.should('have.attr', 'href', `/providers/provider/${pdr.provider}`);

cy.contains('Collection').next()
.contains('a', pdr.collectionId.split('___').join(' / '))
.should('have.attr', 'href', `/collections/collection/${pdr.collectionId.split('___').join('/')}`);
.contains('a', collectionName(pdr.collectionId))
.should('have.attr', 'href', collectionHrefFromId(pdr.collectionId));

cy.contains('Execution').next()
.contains('a', 'link')
Expand Down Expand Up @@ -215,8 +216,8 @@ describe('Dashboard PDRs Page', () => {
.should('have.attr', 'href')
.and('be.eq', `/granules/granule/${granule.granuleId}`);
cy.get('@columns').eq(3)
.contains('a', granule.collectionId.split('___').join(' / '))
.should('have.attr', 'href', `/collections/collection/${granule.collectionId.split('___').join('/')}`);
.contains('a', collectionName(granule.collectionId))
.should('have.attr', 'href', collectionHrefFromId(granule.collectionId));
cy.get('@columns').eq(4)
.should('have.text', `${Number(granule.duration.toFixed(2))}s`);
cy.get('@columns').eq(5).invoke('text')
Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/providers_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ describe('Dashboard Providers Page', () => {
'Host',
];
const expectedFieldsAuth = ['Port', 'Username', 'Password'];
const expectedFieldsHttp = ['Allowed Redirects', 'S 3 URI For Custom SSL Certificate'];
const expectedFieldsHttp = ['Allowed Redirects', 'S3 URI For Custom SSL Certificate'];
const expectedFieldsSftp = ['Private Key', 'AWS KMS Customer Master Key ARN Or Alias'];

it('should go to add providers page', () => {
cy.visit('/providers');
cy.contains('.heading--large', 'Provider Overview');
Expand Down
Loading

0 comments on commit c8499dd

Please sign in to comment.