Skip to content

Commit 3b512d7

Browse files
dmitriy-borzenkoDmitriy Borzenko
andauthored
Kamu UI 533 return to the previously opened page after login (#538)
* set redirect url when dataset not found * changed CHANGELOG.md * minor changes --------- Co-authored-by: Dmitriy Borzenko <[email protected]>
1 parent 28805f2 commit 3b512d7

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Added a feature for changing account email
1010
- Added `redirectUrl` parameter in the URL for login page
11+
### Fixed
12+
- Private datasets: return to the previously opened page after login
1113

1214
## [0.38.0] - 2025-01-27
1315
### Changed

src/app/app.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ export class AppComponent extends BaseComponent implements OnInit {
183183
}
184184

185185
public onLogin(): void {
186-
this.localStorageService.setRedirectAfterLoginUrl(this.router.url);
186+
if (!this.localStorageService.redirectAfterLoginUrl) {
187+
this.localStorageService.setRedirectAfterLoginUrl(this.router.url);
188+
}
187189
this.navigationService.navigateToLogin();
188190
}
189191

src/app/dataset-view/additional-components/dataset-settings-component/tabs/general/dataset-settings-general-tab.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class DatasetSettingsGeneralTabComponent extends BaseComponent implements
243243
]
244244
: [
245245
"You will decide who else has access",
246-
"It will appear in search results on for people with access",
246+
"It will appear in search results only for people with access",
247247
"You can control the level of access others have",
248248
],
249249
warningText: !this.isPrivate

src/app/dataset-view/dataset.service.spec.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import {
88
mockDatasetLineageResponse,
99
} from "../search/mock.data";
1010
import { TestBed } from "@angular/core/testing";
11-
import { Apollo, ApolloModule } from "apollo-angular";
11+
import { Apollo, APOLLO_OPTIONS } from "apollo-angular";
1212
import { DatasetApi } from "../api/dataset.api";
1313
import { ModalService } from "../components/modal/modal.service";
1414
import { DatasetService } from "./dataset.service";
1515
import { DatasetSubscriptionsService } from "./dataset.subscriptions.service";
1616
import { HttpClientTestingModule } from "@angular/common/http/testing";
17-
import { ApolloTestingModule } from "apollo-angular/testing";
1817
import {
1918
DataQueryResultErrorKind,
2019
DatasetBasicsFragment,
@@ -45,8 +44,24 @@ describe("AppDatasetService", () => {
4544

4645
beforeEach(() => {
4746
TestBed.configureTestingModule({
48-
imports: [ApolloModule, ApolloTestingModule, HttpClientTestingModule],
49-
providers: [DatasetApi, ModalService, DatasetService, DatasetSubscriptionsService, Apollo],
47+
imports: [HttpClientTestingModule],
48+
providers: [
49+
DatasetApi,
50+
ModalService,
51+
DatasetService,
52+
DatasetSubscriptionsService,
53+
Apollo,
54+
{
55+
provide: APOLLO_OPTIONS,
56+
useFactory: () => {
57+
return {
58+
cache: {
59+
evict: () => null,
60+
},
61+
};
62+
},
63+
},
64+
],
5065
});
5166
service = TestBed.inject(DatasetService);
5267
datasetApi = TestBed.inject(DatasetApi);

src/app/dataset-view/dataset.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { LocalStorageService } from "src/app/services/local-storage.service";
12
import { SqlExecutionError } from "../common/errors";
23
import {
34
BlockRef,
@@ -39,12 +40,15 @@ import { parseCurrentSchema } from "../common/app.helpers";
3940
import { APOLLO_OPTIONS } from "apollo-angular";
4041
import { resetCacheHelper } from "../apollo-cache.helper";
4142
import { parseDataRows } from "../common/data.helpers";
43+
import { Router } from "@angular/router";
4244

4345
@Injectable({ providedIn: "root" })
4446
export class DatasetService {
4547
private datasetApi = inject(DatasetApi);
4648
private datasetSubsService = inject(DatasetSubscriptionsService);
4749
private injector = inject(Injector);
50+
private router = inject(Router);
51+
private localStorageService = inject(LocalStorageService);
4852
private currentHeadBlockHash: string;
4953
private dataset$: Subject<DatasetBasicsFragment> = new Subject<DatasetBasicsFragment>();
5054

@@ -81,6 +85,12 @@ export class DatasetService {
8185
throw new SqlExecutionError(dataTail.errorMessage);
8286
}
8387
} else {
88+
this.localStorageService.setRedirectAfterLoginUrl(this.router.url);
89+
const cache = this.injector.get(APOLLO_OPTIONS).cache;
90+
cache.evict({
91+
id: "ROOT_QUERY",
92+
fieldName: "datasets",
93+
});
8494
throw new DatasetNotFoundError();
8595
}
8696
}),

0 commit comments

Comments
 (0)