Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening of dataset entries with "new" in the end of name #1968

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
korvin89 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading