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

Kamu UI 425 replace mock initiator for flows tab for aсcount #426

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Replaced mock initiator for flows tab for account

## [0.26.3] - 2024-09-13
### Fixed
- Hid the `force-update` link
Expand Down
4 changes: 2 additions & 2 deletions src/app/account/account.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="custom-container" *ngIf="activeTab$ | async as activeTab">
<div class="container-sidebar">
<div class="d-flex mb-3 justify-content-center align-items-center">
<a *ngIf="isLoggedUser; else notLoggedUserLink" routerLink="/v/settings/profile">
<a *ngIf="isLoggedUser; else notLoggedUserLink">
<img
alt="avatar"
width="260"
Expand Down Expand Up @@ -164,7 +164,7 @@ <h3 class="text-start pt-3 px-3 organization">Organizations</h3>
></app-datasets-tab>
</ng-container>
<ng-container *ngIf="activeTab === AccountTabs.FLOWS">
<app-account-flows-tab [accountName]="user.accountName"></app-account-flows-tab>
<app-account-flows-tab [loggedUser]="user"></app-account-flows-tab>
</ng-container>
<ng-container *ngIf="activeTab === AccountTabs.ORGANIZATIONS">
<div>Organizations</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { mockDatasets } from "src/app/common/components/flows-table/flows-table.
import { FlowsTableFiltersOptions } from "src/app/common/components/flows-table/flows-table.types";
import { NgbPaginationModule } from "@ng-bootstrap/ng-bootstrap";
import { AngularMultiSelectModule } from "angular2-multiselect-dropdown";
import { mockAccountDetails } from "src/app/api/mock/auth.mock";

describe("AccountFlowsTabComponent", () => {
let component: AccountFlowsTabComponent;
Expand Down Expand Up @@ -63,7 +64,7 @@ describe("AccountFlowsTabComponent", () => {
navigationService = TestBed.inject(NavigationService);
datasetFlowsService = TestBed.inject(DatasetFlowsService);
component = fixture.componentInstance;
component.accountName = "mockAccountName";
component.loggedUser = mockAccountDetails;
});

it("should create", () => {
Expand All @@ -73,13 +74,13 @@ describe("AccountFlowsTabComponent", () => {
it("should check navigate to owner view with page=1 ", () => {
const navigateToOwnerViewSpy = spyOn(navigationService, "navigateToOwnerView");
component.onPageChange(1);
expect(navigateToOwnerViewSpy).toHaveBeenCalledOnceWith(component.accountName, AccountTabs.FLOWS);
expect(navigateToOwnerViewSpy).toHaveBeenCalledOnceWith(component.loggedUser.accountName, AccountTabs.FLOWS);
});

it("should check navigate to owner view with page>1 ", () => {
const navigateToOwnerViewSpy = spyOn(navigationService, "navigateToOwnerView");
component.onPageChange(2);
expect(navigateToOwnerViewSpy).toHaveBeenCalledOnceWith(component.accountName, AccountTabs.FLOWS, 2);
expect(navigateToOwnerViewSpy).toHaveBeenCalledOnceWith(component.loggedUser.accountName, AccountTabs.FLOWS, 2);
});

it("should check cancel flow button", fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, inject, Input, OnInit } from "@angu
import { combineLatest, map, of, switchMap, timer } from "rxjs";
import { MaybeNull } from "src/app/common/app.types";
import {
AccountType,
AccountFragment,
DatasetListFlowsDataFragment,
FlowStatus,
FlowSummaryDataFragment,
Expand All @@ -11,7 +11,6 @@ import {
import { AccountService } from "src/app/services/account.service";
import { AccountTabs } from "../../account.constants";
import { environment } from "src/environments/environment";
import { TEST_ACCOUNT_ID } from "src/app/search/mock.data";
import { FlowsTableProcessingBaseComponent } from "src/app/common/components/flows-table/flows-table-processing-base.component";
import { FlowsTableFiltersOptions } from "src/app/common/components/flows-table/flows-table.types";

Expand All @@ -22,7 +21,7 @@ import { FlowsTableFiltersOptions } from "src/app/common/components/flows-table/
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountFlowsTabComponent extends FlowsTableProcessingBaseComponent implements OnInit {
@Input({ required: true }) accountName: string;
@Input({ required: true }) loggedUser: AccountFragment;
public nodes: FlowSummaryDataFragment[] = [];
public searchByDataset: DatasetListFlowsDataFragment[] = [];
public readonly DISPLAY_COLUMNS = ["description", "information", "creator", "dataset", "options"];
Expand All @@ -44,7 +43,7 @@ export class AccountFlowsTabComponent extends FlowsTableProcessingBaseComponent
switchMap(() =>
combineLatest([
this.accountService.getAccountListFlows({
accountName: this.accountName,
accountName: this.loggedUser.accountName,
page: page - 1,
perPageTable: this.TABLE_FLOW_RUNS_PER_PAGE,
perPageTiles: this.WIDGET_FLOW_RUNS_PER_PAGE,
Expand All @@ -55,17 +54,8 @@ export class AccountFlowsTabComponent extends FlowsTableProcessingBaseComponent
byDatasetIds: datasetsIds ?? [],
},
}),
this.accountService.accountAllFlowsPaused(this.accountName),
// TODO: Implemented all accounts with flows from API
of([
{
accountName: "kamu",
accountType: AccountType.User,
id: TEST_ACCOUNT_ID,
displayName: "kamu",
isAdmin: true,
},
]),
this.accountService.accountAllFlowsPaused(this.loggedUser.accountName),
of([this.loggedUser]),
]),
),
map(([flowsData, allFlowsPaused, flowInitiators]) => {
Expand All @@ -76,18 +66,18 @@ export class AccountFlowsTabComponent extends FlowsTableProcessingBaseComponent

public onPageChange(page: number): void {
if (page === 1) {
this.navigationService.navigateToOwnerView(this.accountName, AccountTabs.FLOWS);
this.navigationService.navigateToOwnerView(this.loggedUser.accountName, AccountTabs.FLOWS);
} else {
this.navigationService.navigateToOwnerView(this.accountName, AccountTabs.FLOWS, page);
this.navigationService.navigateToOwnerView(this.loggedUser.accountName, AccountTabs.FLOWS, page);
}
this.fetchTableData(page);
}

public toggleStateAccountFlowConfigs(paused: boolean): void {
if (!paused) {
this.accountService.accountPauseFlows(this.accountName).subscribe();
this.accountService.accountPauseFlows(this.loggedUser.accountName).subscribe();
} else {
this.accountService.accountResumeFlows(this.accountName).subscribe();
this.accountService.accountResumeFlows(this.loggedUser.accountName).subscribe();
}
setTimeout(() => {
this.refreshFlow();
Expand Down
Loading