Skip to content

Commit

Permalink
Merge branch 'main' into CHARTS-9154
Browse files Browse the repository at this point in the history
  • Loading branch information
DaryaLari authored Dec 23, 2024
2 parents ef80603 + 28a9c0c commit b061efd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DatasetPage extends React.Component<DatasetPageProps> {
workbookIdFromPath={this.props.workbookId}
history={this.props.history}
ytPath={this.ytPath}
isCreationProcess={isCreationProcess()}
isCreationProcess={isCreationProcess(location.pathname)}
isAuto={this.isAuto}
/>
</DatasetPageProvider>
Expand Down
14 changes: 14 additions & 0 deletions src/ui/units/datasets/helpers/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {isCreationProcess} from './utils';

describe('dataset/helpers/isCreationProcess', () => {
test.each([
['', false],
['/datasets/name', false],
['/datasets/name-new', false],
['/datasets/new-name', false],
['/datasets/new', true],
])('isCreationProcess (args: %j)', (pathname, expected) => {
const result = isCreationProcess(pathname);
expect(result).toEqual(expected);
});
});
5 changes: 3 additions & 2 deletions src/ui/units/datasets/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default class DatasetUtils {
}
}

export function isCreationProcess() {
return /new$/.test(window.location.pathname);
export function isCreationProcess(pathname = '') {
const lastPathnamePart = pathname.split('/').filter(Boolean).slice(-1)[0];
return lastPathnamePart === 'new';
}
2 changes: 1 addition & 1 deletion src/ui/units/datasets/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const isDatasetTab = (value: unknown): value is DatasetTab => {
};

const getCurrentTab = (): DatasetTab => {
const defaultTab = isCreationProcess() ? TAB_SOURCES : TAB_DATASET;
const defaultTab = isCreationProcess(location.pathname) ? TAB_SOURCES : TAB_DATASET;
const queryTab = DatasetUtils.getQueryParam('tab');

if (isDatasetTab(queryTab)) {
Expand Down

0 comments on commit b061efd

Please sign in to comment.