fix prefix navigation in browser feature

This commit is contained in:
Seyi Adebajo 2018-02-21 11:06:21 -08:00
parent 29142d0b5a
commit a328cc26b6
7 changed files with 12 additions and 12 deletions

View File

@ -10,7 +10,7 @@ type IGetEntityTaskStrategy = { [K in IBrowserRouteParams['entity']]: Promise<Ar
export default class BrowserViewport extends Component {
/**
* Passed in parameters containing route or queryparameters values to be used in request
* Passed in parameters containing route or query parameters values to be used in request
* @type {IBrowserRouteParams}
* @memberof BrowserViewport
*/

View File

@ -1,6 +1,6 @@
import { IBrowserRouteParams } from 'wherehows-web/routes/browse/entity';
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
import { getPlatformFromString, isDatasetPlatform, isDatasetPrefix } from 'wherehows-web/utils/validators/platform';
import { getPlatformFromString, isDatasetPlatform, isDatasetSegment } from 'wherehows-web/utils/validators/platform';
/**
* The known/supported list of dataset platforms
@ -36,8 +36,8 @@ const nodeToQueryParams = ({
}: Pick<IBrowserRouteParams, 'platform'> & { node: string }): Partial<IReadDatasetsOptionBag> => {
const queryParams = {};
if (isDatasetPrefix(node)) {
Object.assign(queryParams, { prefix: node.replace(/\//g, '') });
if (isDatasetSegment(node)) {
Object.assign(queryParams, { prefix: node });
}
// If the node is a platform, assign that value to the query params object

View File

@ -90,9 +90,6 @@
</span>
{{/if}}
{{/row.cell}}
{{#row.cell}}
{{datasets/dataset-actions actionItems=actionItems}}
{{/row.cell}}
{{/body.row}}
{{/each}}
{{/table.body}}

View File

@ -1,5 +1,6 @@
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
import { ApiVersion, getApiRoot } from 'wherehows-web/utils/api/shared';
import { encodeForwardSlash } from 'wherehows-web/utils/validators/urn';
/**
* Defines the endpoint for datasets
@ -49,7 +50,7 @@ export const datasetsUrl = ({ platform, prefix }: IReadDatasetsOptionBag): strin
const urlRoot = datasetsUrlRoot('v2');
if (platform && prefix) {
return `${urlRoot}/platform/${platform}/prefix/${prefix}`;
return `${urlRoot}/platform/${platform}/prefix/${encodeForwardSlash(prefix)}`;
}
if (platform) {

View File

@ -1,6 +1,7 @@
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
import { getJSON } from 'wherehows-web/utils/api/fetcher';
import { ApiVersion, getApiRoot } from 'wherehows-web/utils/api/shared';
import { encodeForwardSlash } from 'wherehows-web/utils/validators/urn';
/**
* Generates the base url for a platform given a specified ApiVersion
@ -18,7 +19,7 @@ const platformsUrl = ({ platform, prefix }: IReadDatasetsOptionBag): string => {
const urlRoot = platformsUrlRoot('v2');
if (platform && prefix) {
return `${urlRoot}/${platform}/prefix/${prefix}`;
return `${urlRoot}/${platform}/prefix/${encodeForwardSlash(prefix)}`;
}
if (platform) {

View File

@ -13,11 +13,11 @@ const platformRegex = /\[platform=([^\]]+)]/;
const isDatasetPlatform = (candidate: string): boolean => platformRegex.test(candidate);
/**
* Checks that a string represents a dataset prefix
* Checks that a string represents a dataset segment
* @param {string} candidate
* @returns {boolean}
*/
const isDatasetPrefix = (candidate: string): boolean =>
const isDatasetSegment = (candidate: string): boolean =>
!isDatasetPlatform(candidate) && ['.', '/'].includes(candidate.slice(-1));
/**
@ -50,4 +50,4 @@ const sanitizePlatformNodeString = (nodeString: string): string => {
return nodeString;
};
export { platformRegex, isDatasetPlatform, isDatasetPrefix, getPlatformFromString, sanitizePlatformNodeString };
export { platformRegex, isDatasetPlatform, isDatasetSegment, getPlatformFromString, sanitizePlatformNodeString };

View File

@ -110,6 +110,7 @@ export {
specialFlowUrnRegex,
getPlatformFromUrn,
convertWhUrnToLiUrn,
encodeForwardSlash,
encodeUrn,
decodeUrn
};