Skip to content

Commit

Permalink
Merge branch 'master' into global-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell authored Jun 20, 2019
2 parents b790b48 + 2ff9b4d commit 0c98e91
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 128 deletions.
60 changes: 60 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';
const message = process.env['HUSKY_GIT_PARAMS'];
const fs = require('fs');

const types = [
'build',
"chore",
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
"release",
'revert',
'style',
'test'
];

const scopes = [
"showcase",
"packaging",
"changelog",
"schematics",
"module:*"
];

function parseMessage(message) {
const PATTERN = /^(\w+)(?:\(([^)]+)\))?\: (.+)$/;
const match = PATTERN.exec(message);
if (!match) {
return null;
}
return {
type: match[1] || null,
scope: match[2] || null,
}
}

function getScopesRule() {
const messages = fs.readFileSync(message, {encoding: 'utf-8'});
const parsed = parseMessage(messages.split('\n')[0]);
if (!parsed) {
return [2, 'always', scopes]
}
const { scope, type } = parsed;
if (scope && !scopes.includes(scope) && type !== 'release' && !/module:.+/.test(scope)) {
return [2, 'always', scopes]
} else {
return [2, 'always', []]
}
}

module.exports = {
extends: ['@commitlint/config-angular'],
rules: {
'type-enum': [2, 'always', types],
'scope-enum': getScopesRule
}
};
8 changes: 5 additions & 3 deletions components/page-header/nz-page-header.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<ng-content select="nz-breadcrumb[nz-page-header-breadcrumb]"></ng-content>

<div *ngIf="nzBackIcon !== null" (click)="onBack()" class="ant-page-header-back-icon">
<i *ngIf="isStringBackIcon" nz-icon [nzType]="nzBackIcon ? nzBackIcon : 'arrow-left'" theme="outline"></i>
<ng-container *ngIf="isTemplateRefBackIcon" [ngTemplateOutlet]="nzBackIcon"></ng-container>
<div *ngIf="nzBackIcon !== null" (click)="onBack()" class="ant-page-header-back">
<div role="button" tabindex="0" class="ant-page-header-back-button">
<i *ngIf="isStringBackIcon" nz-icon [nzType]="nzBackIcon ? nzBackIcon : 'arrow-left'" nzTheme="outline"></i>
<ng-container *ngIf="isTemplateRefBackIcon" [ngTemplateOutlet]="nzBackIcon"></ng-container>
</div>
<nz-divider nzType="vertical"></nz-divider>
</div>

Expand Down
13 changes: 12 additions & 1 deletion components/page-header/nz-page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ import { NzPageHeaderFooterDirective } from './nz-page-header-cells';
host: {
class: 'ant-page-header',
'[class.ant-page-header-has-footer]': 'nzPageHeaderFooter'
}
},
styles: [
`
.ant-page-header-back-button {
border: 0px;
background: transparent;
padding: 0px;
line-height: inherit;
display: inline-block;
}
`
]
})
export class NzPageHeaderComponent implements OnInit, OnChanges {
isTemplateRefBackIcon = false;
Expand Down
6 changes: 3 additions & 3 deletions components/page-header/nz-page-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ describe('NzPageHeaderComponent', () => {
const fixture = TestBed.createComponent(NzDemoPageHeaderBasicComponent);
const pageHeader = fixture.debugElement.query(By.directive(NzPageHeaderComponent));
fixture.detectChanges();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back-icon > i.anticon-arrow-left')).toBeTruthy();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back i.anticon-arrow-left')).toBeTruthy();
});

it('should does not have an default back icon', () => {
const fixture = TestBed.createComponent(NzDemoPageHeaderContentComponent);
const pageHeader = fixture.debugElement.query(By.directive(NzPageHeaderComponent));
fixture.detectChanges();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back-icon')).toBeFalsy();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back')).toBeFalsy();
});

it('should nzBack work', () => {
Expand All @@ -82,7 +82,7 @@ describe('NzPageHeaderComponent', () => {
spyOn(context, 'onBack');
fixture.detectChanges();
expect(context.onBack).not.toHaveBeenCalled();
const back = pageHeader.nativeElement.querySelector('.ant-page-header-back-icon');
const back = pageHeader.nativeElement.querySelector('.ant-page-header-back');
(back as HTMLElement).click();
fixture.detectChanges();
expect(context.onBack).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions components/table/nz-thead.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { merge, Subject } from 'rxjs';
import { flatMap, startWith, takeUntil } from 'rxjs/operators';
import { startWith, switchMap, takeUntil } from 'rxjs/operators';

import { InputBoolean } from 'ng-zorro-antd/core';

Expand Down Expand Up @@ -62,7 +62,7 @@ export class NzTheadComponent implements AfterContentInit, OnDestroy, AfterViewI
this.listOfNzThComponent.changes
.pipe(
startWith(true),
flatMap(() =>
switchMap(() =>
merge<{ key: string; value: string }>(...this.listOfNzThComponent.map(th => th.nzSortChangeWithKey))
),
takeUntil(this.destroy$)
Expand Down
23 changes: 23 additions & 0 deletions components/table/nz-thead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ describe('nz-thead', () => {
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);
});

// Test for #3603
it('should support dynamic headers', () => {
testComponent.singleSort = true;
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(0);
let upButtons = table.nativeElement.querySelectorAll('.ant-table-column-sorters');
upButtons[2].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(1);
upButtons[3].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);

testComponent.columns = testComponent.columns.slice(0, 1);
fixture.detectChanges();
upButtons = table.nativeElement.querySelectorAll('.ant-table-column-sorters');
expect(upButtons.length).toBe(3);
upButtons[2].click();
expect(testComponent.sortChange).toHaveBeenCalledTimes(3);
});
});
});

Expand All @@ -64,11 +85,13 @@ describe('nz-thead', () => {
<thead [nzSingleSort]="singleSort" (nzSortChange)="sortChange($event)">
<th nzShowSort nzSortKey="first"></th>
<th nzShowSort nzSortKey="second"></th>
<th nzShowSort *ngFor="let col of columns" [nzSortKey]="col"></th>
</thead>
</nz-table>
`
})
export class NzTheadTestNzTableComponent {
singleSort = false;
sortChange = jasmine.createSpy('sort change');
columns = ['third', 'fourth'];
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
"@angular/pwa": "^0.800.1",
"@angular/router": "~8.0.0",
"@angular/service-worker": "~8.0.0",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-angular": "^8.0.0",
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
"@schematics/angular": "~8.0.1",
"@stackblitz/sdk": "^1.1.1",
Expand Down Expand Up @@ -123,7 +125,7 @@
},
"husky": {
"hooks": {
"commit-msg": "node ./scripts/git/commit-msg.js -E HUSKY_GIT_PARAMS",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
Expand Down
24 changes: 0 additions & 24 deletions scripts/git/commit-message.json

This file was deleted.

21 changes: 0 additions & 21 deletions scripts/git/commit-msg.js

This file was deleted.

73 changes: 0 additions & 73 deletions scripts/git/validate-commit-message.js

This file was deleted.

0 comments on commit 0c98e91

Please sign in to comment.