mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 12:52:13 +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 {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -90,9 +90,6 @@
|
||||
</span>
|
||||
{{/if}}
|
||||
{{/row.cell}}
|
||||
{{#row.cell}}
|
||||
{{datasets/dataset-actions actionItems=actionItems}}
|
||||
{{/row.cell}}
|
||||
{{/body.row}}
|
||||
{{/each}}
|
||||
{{/table.body}}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 };
|
||||
|
@ -110,6 +110,7 @@ export {
|
||||
specialFlowUrnRegex,
|
||||
getPlatformFromUrn,
|
||||
convertWhUrnToLiUrn,
|
||||
encodeForwardSlash,
|
||||
encodeUrn,
|
||||
decodeUrn
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user