mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-03 14:23:03 +00:00
fix prefix navigation in browser feature
This commit is contained in:
parent
29142d0b5a
commit
a328cc26b6
@ -10,7 +10,7 @@ type IGetEntityTaskStrategy = { [K in IBrowserRouteParams['entity']]: Promise<Ar
|
|||||||
|
|
||||||
export default class BrowserViewport extends Component {
|
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}
|
* @type {IBrowserRouteParams}
|
||||||
* @memberof BrowserViewport
|
* @memberof BrowserViewport
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { IBrowserRouteParams } from 'wherehows-web/routes/browse/entity';
|
import { IBrowserRouteParams } from 'wherehows-web/routes/browse/entity';
|
||||||
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
|
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
|
* The known/supported list of dataset platforms
|
||||||
@ -36,8 +36,8 @@ const nodeToQueryParams = ({
|
|||||||
}: Pick<IBrowserRouteParams, 'platform'> & { node: string }): Partial<IReadDatasetsOptionBag> => {
|
}: Pick<IBrowserRouteParams, 'platform'> & { node: string }): Partial<IReadDatasetsOptionBag> => {
|
||||||
const queryParams = {};
|
const queryParams = {};
|
||||||
|
|
||||||
if (isDatasetPrefix(node)) {
|
if (isDatasetSegment(node)) {
|
||||||
Object.assign(queryParams, { prefix: node.replace(/\//g, '') });
|
Object.assign(queryParams, { prefix: node });
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the node is a platform, assign that value to the query params object
|
// If the node is a platform, assign that value to the query params object
|
||||||
|
@ -90,9 +90,6 @@
|
|||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/row.cell}}
|
{{/row.cell}}
|
||||||
{{#row.cell}}
|
|
||||||
{{datasets/dataset-actions actionItems=actionItems}}
|
|
||||||
{{/row.cell}}
|
|
||||||
{{/body.row}}
|
{{/body.row}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/table.body}}
|
{{/table.body}}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
|
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
|
||||||
import { ApiVersion, getApiRoot } from 'wherehows-web/utils/api/shared';
|
import { ApiVersion, getApiRoot } from 'wherehows-web/utils/api/shared';
|
||||||
|
import { encodeForwardSlash } from 'wherehows-web/utils/validators/urn';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the endpoint for datasets
|
* Defines the endpoint for datasets
|
||||||
@ -49,7 +50,7 @@ export const datasetsUrl = ({ platform, prefix }: IReadDatasetsOptionBag): strin
|
|||||||
const urlRoot = datasetsUrlRoot('v2');
|
const urlRoot = datasetsUrlRoot('v2');
|
||||||
|
|
||||||
if (platform && prefix) {
|
if (platform && prefix) {
|
||||||
return `${urlRoot}/platform/${platform}/prefix/${prefix}`;
|
return `${urlRoot}/platform/${platform}/prefix/${encodeForwardSlash(prefix)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform) {
|
if (platform) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
|
import { IReadDatasetsOptionBag } from 'wherehows-web/typings/api/datasets/dataset';
|
||||||
import { getJSON } from 'wherehows-web/utils/api/fetcher';
|
import { getJSON } from 'wherehows-web/utils/api/fetcher';
|
||||||
import { ApiVersion, getApiRoot } from 'wherehows-web/utils/api/shared';
|
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
|
* 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');
|
const urlRoot = platformsUrlRoot('v2');
|
||||||
|
|
||||||
if (platform && prefix) {
|
if (platform && prefix) {
|
||||||
return `${urlRoot}/${platform}/prefix/${prefix}`;
|
return `${urlRoot}/${platform}/prefix/${encodeForwardSlash(prefix)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform) {
|
if (platform) {
|
||||||
|
@ -13,11 +13,11 @@ const platformRegex = /\[platform=([^\]]+)]/;
|
|||||||
const isDatasetPlatform = (candidate: string): boolean => platformRegex.test(candidate);
|
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
|
* @param {string} candidate
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
const isDatasetPrefix = (candidate: string): boolean =>
|
const isDatasetSegment = (candidate: string): boolean =>
|
||||||
!isDatasetPlatform(candidate) && ['.', '/'].includes(candidate.slice(-1));
|
!isDatasetPlatform(candidate) && ['.', '/'].includes(candidate.slice(-1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,4 +50,4 @@ const sanitizePlatformNodeString = (nodeString: string): string => {
|
|||||||
return nodeString;
|
return nodeString;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { platformRegex, isDatasetPlatform, isDatasetPrefix, getPlatformFromString, sanitizePlatformNodeString };
|
export { platformRegex, isDatasetPlatform, isDatasetSegment, getPlatformFromString, sanitizePlatformNodeString };
|
||||||
|
@ -110,6 +110,7 @@ export {
|
|||||||
specialFlowUrnRegex,
|
specialFlowUrnRegex,
|
||||||
getPlatformFromUrn,
|
getPlatformFromUrn,
|
||||||
convertWhUrnToLiUrn,
|
convertWhUrnToLiUrn,
|
||||||
|
encodeForwardSlash,
|
||||||
encodeUrn,
|
encodeUrn,
|
||||||
decodeUrn
|
decodeUrn
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user