Skip to content

Commit

Permalink
feat(navigation,demo)!: remove deprecated `DaffGenericNavigationTree#…
Browse files Browse the repository at this point in the history
…path` field (#2628)

BREAKING CHANGE: `DaffGenericNavigationTree#path` is removed in favor of `url`
  • Loading branch information
griest024 committed Nov 30, 2023
1 parent 556e69c commit 7211acd
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

<ng-container *ngIf="level > 0">
<daff-link-set class="demo-sidebar-list__level-{{ level }}">
<a *ngIf="level === 1" [routerLink]="getNavigationPath(tree.id)" daffLinkSetHeading daff-link-set-item>
<a *ngIf="level === 1" [routerLink]="tree.url" daffLinkSetHeading daff-link-set-item>
{{ tree.name }}
</a>
<ng-container *ngFor="let child of tree.children">
<ng-container *ngIf="child.children.length > 0">
<a [routerLink]="getNavigationPath(tree.id)" daffLinkSetSubheading
<ng-container *ngIf="child.children?.length > 0">
<a [routerLink]="child.url" daffLinkSetSubheading
daff-link-set-item>{{ child.name }}</a>
<demo-sidebar-list [tree]="child" [level]="nextLevel"></demo-sidebar-list>
</ng-container>
<a *ngIf="child.children.length === 0" [routerLink]="getNavigationPath(child.id)"
<a *ngIf="!child.children?.length" [routerLink]="child.url"
daff-link-set-item>{{ child.name }}</a>
</ng-container>
</daff-link-set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ export class SidebarListComponent {
get nextLevel() {
return this.level + 1;
}

getNavigationPath(path: DaffNavigationTree['path']) {
return '/' + path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ describe('Driver | Magento | Navigation | Transformers | DaffMagentoNavigationTr
id: '1',
url: '/1.html',
name: 'Root Category',
path: '1',
total_products: 10,
children: [
{
id: '5',
url: '/5.html',
name: 'Subcategory',
path: '5',
total_products: 10,
children: [],
children_count: 0,
Expand All @@ -102,7 +100,6 @@ describe('Driver | Magento | Navigation | Transformers | DaffMagentoNavigationTr
id: '2',
url: '/2.html',
name: 'Subcategory',
path: '2',
total_products: 10,
children: [],
children_count: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class DaffMagentoNavigationTransformerService implements DaffNavigationTr
return {
id,
url: `/${node.url_path}${node.url_suffix}`,
path: id,
name: node.name,
total_products: node.product_count,
children_count: node.children_count,
Expand Down
4 changes: 0 additions & 4 deletions libs/navigation/src/models/generic-navigation-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import { DaffNavigationBreadcrumb } from './navigation-breadcrumb';
*/
export interface DaffGenericNavigationTree<T extends DaffGenericNavigationTree<T>> extends DaffLocatable, DaffIdentifiable {
name: string;
/**
* @deprecated prefer the `url` field
*/
path: ID;
children_count?: number;
total_products?: number;
children?: T[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('Navigation | Testing | Factories | DaffNavigationTreeFactory', () => {
expect(result.id).toBeDefined();
expect(result.name).toBeDefined();
expect(result.url).toBeDefined();
expect(result.path).toBeDefined();
expect(result.children_count).toBeDefined();
expect(result.total_products).toBeDefined();
expect(result.breadcrumbs).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export class MockNavigationTree implements DaffNavigationTree {
id = faker.datatype.uuid();
name = '';
url = randomUrl();
path = faker.commerce.department().toString().toLowerCase();
total_products = faker.datatype.number({ min: 1, max: 10 });
children = [...Array(faker.datatype.number({ min:1, max:3 }))].map(() => this.fakeTree(3));
children_count = 0;
Expand All @@ -28,7 +27,6 @@ export class MockNavigationTree implements DaffNavigationTree {
id,
url: randomUrl(),
name: faker.commerce.department(),
path: faker.commerce.department().toString().toLowerCase(),
total_products: faker.datatype.number({ min: 1, max: 20 }),
children: [],
children_count: 0,
Expand All @@ -46,7 +44,6 @@ export class MockNavigationTree implements DaffNavigationTree {
id,
url: randomUrl(),
name: faker.commerce.department(),
path: faker.commerce.department().toString().toLowerCase(),
total_products: faker.datatype.number({ min: 1, max: 20 }),
children,
children_count: children.length,
Expand All @@ -64,7 +61,7 @@ export class MockNavigationTree implements DaffNavigationTree {
@Injectable({
providedIn: 'root',
})
export class DaffNavigationTreeFactory extends DaffModelFactory<DaffNavigationTree>{
export class DaffNavigationTreeFactory extends DaffModelFactory<DaffNavigationTree, typeof MockNavigationTree>{
constructor(){
super(MockNavigationTree);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/navigation/testing/src/helpers/navigation-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { DaffNavigationTree } from '@daffodil/navigation';
* @param navigation
*/
export function isNavigation(navigation: DaffNavigationTree): boolean {
return navigation.id != null && navigation.name != null && navigation.path != null;
return navigation.id != null && navigation.name != null && navigation.url != null;
}

0 comments on commit 7211acd

Please sign in to comment.