Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Switched the action button url to permalink #1924

Merged
merged 3 commits into from
Aug 21, 2018
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 @@ -37,7 +37,7 @@
</sky-action-button-details>
</sky-action-button>
<sky-action-button
url="https://host.nxt.blackbaud.com/skyux2/?component=SkyIconDemoComponent">
[permalink]="permalink">
<sky-action-button-icon
iconType="link">
</sky-action-button-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { Component} from '@angular/core';
})
export class ActionButtonVisualComponent {

public permalink = {
url: 'https://developer.blackbaud.com/skyux/components'
};

public buttonIsClicked: boolean = false;

public buttonClicked() {
Expand Down
15 changes: 14 additions & 1 deletion src/demos/action-button/action-button-demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</sky-action-button>

<sky-action-button
url="https://developer.blackbaud.com/skyux/components">
[permalink]="url">
<sky-action-button-icon
iconType="link">
</sky-action-button-icon>
Expand All @@ -37,4 +37,17 @@
Open a link
</sky-action-button-details>
</sky-action-button>

<sky-action-button
[permalink]="routerlink">
<sky-action-button-icon
iconType="link">
</sky-action-button-icon>
<sky-action-button-header>
Open a router link
</sky-action-button-header>
<sky-action-button-details>
Open a router link
</sky-action-button-details>
</sky-action-button>
</sky-action-button-container>
14 changes: 14 additions & 0 deletions src/demos/action-button/action-button-demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import { Component } from '@angular/core';
templateUrl: './action-button-demo.component.html'
})
export class SkyActionButtonDemoComponent {
public url = {
url: 'https://developer.blackbaud.com/skyux/components'
};

public routerlink = {
route: {
extras: {
queryParams: {
component: 'SkyCheckboxDemoComponent'
}
}
}
};

public filterActionClick() {
alert('Filter action clicked');
}
Expand Down
19 changes: 16 additions & 3 deletions src/modules/action-button/action-button.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<a
*ngIf="url"
*ngIf="permalink && permalink.route"
class="sky-action-button sky-btn-default sky-rounded-corners"
tabindex="0"
[href]="url">
[fragment]="permalink.route?.extras?.fragment"
[queryParams]="permalink.route?.extras?.queryParams"
[queryParamsHandling]="permalink.route?.extras?.queryParamsHandling"
[routerLink]="permalink.route?.commands">
<ng-container
*ngTemplateOutlet="actionButtonContent">
</ng-container>
</a>

<a
*ngIf="permalink && !permalink.route"
class="sky-action-button sky-btn-default sky-rounded-corners"
tabindex="0"
[href]="permalink.url">
<ng-container
*ngTemplateOutlet="actionButtonContent">
</ng-container>
</a>

<div
*ngIf="!url"
*ngIf="!permalink"
class="sky-action-button sky-btn-default sky-rounded-corners"
role="button"
tabindex="0"
Expand Down
46 changes: 29 additions & 17 deletions src/modules/action-button/action-button.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import {
DebugElement
} from '@angular/core';
import {
BrowserModule,
By
} from '@angular/platform-browser';
import {
TestBed,
ComponentFixture
} from '@angular/core/testing';

import {
DebugElement
} from '@angular/core';

import { BrowserModule, By } from '@angular/platform-browser';

import {
SkyActionButtonComponent,
SkyActionButtonModule
RouterTestingModule
} from '@angular/router/testing';

} from '.';
import {
SkyMediaQueryService,
SkyMediaBreakpoints
} from '../media-queries';

import { ActionButtonTestComponent } from './fixtures/action-button.component.fixture';

import {
MockSkyMediaQueryService
} from '../testing/mocks';

import {
SkyActionButtonComponent,
SkyActionButtonModule
} from '.';
import {
ActionButtonTestComponent
} from './fixtures/action-button.component.fixture';

describe('Action button component', () => {
let fixture: ComponentFixture<ActionButtonTestComponent>;
let cmp: ActionButtonTestComponent;
Expand All @@ -41,6 +45,7 @@ describe('Action button component', () => {
],
imports: [
BrowserModule,
RouterTestingModule,
SkyActionButtonModule
]
});
Expand All @@ -65,12 +70,19 @@ describe('Action button component', () => {
fixture.detectChanges();
});

it('should see if there is a url included as an input to the element', () => {
let actionButton = '.sky-action-button';
expect(el.querySelectorAll(actionButton).item(1).tagName === 'a');
it('should see if there is a permalink url included as an input to the element', () => {
let actionButton = el.querySelectorAll('.sky-action-button').item(1);
expect(actionButton.tagName === 'a');
expect(actionButton.getAttribute('href')).toBe('https://developer.blackbaud.com/skyux/components');
});

it('should see if there is a permalink route included as an input to the element', () => {
let actionButton = el.querySelectorAll('.sky-action-button').item(2);
expect(actionButton.tagName === 'a');
expect(actionButton.getAttribute('href')).toBe('/?page=1#fragment');
});

it('should use a div element when url is not provided', () => {
it('should use a div element when permalink is not provided', () => {
let actionButton = '.sky-action-button';
expect(el.querySelectorAll(actionButton).item(0).tagName === 'div');
});
Expand Down
6 changes: 5 additions & 1 deletion src/modules/action-button/action-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import {
Output
} from '@angular/core';

import {
SkyActionButtonPermalink
} from './types';

@Component({
selector: 'sky-action-button',
styleUrls: ['./action-button.component.scss'],
templateUrl: './action-button.component.html'
})
export class SkyActionButtonComponent {
@Input()
public url: string;
public permalink: SkyActionButtonPermalink;

@Output()
public actionClick = new EventEmitter<any>();
Expand Down
2 changes: 2 additions & 0 deletions src/modules/action-button/action-button.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';

import { SkyMediaQueryModule } from '../media-queries';
Expand All @@ -20,6 +21,7 @@ import { SkyIconModule } from '../icon';
],
imports: [
CommonModule,
RouterModule,
SkyMediaQueryModule,
SkyIconModule
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</sky-action-button>

<sky-action-button
url="https://host.nxt.blackbaud.com/skyux2/?component=SkyIconDemoComponent">
[permalink]="permalink1">
<sky-action-button-icon
iconType="link">
</sky-action-button-icon>
Expand All @@ -24,4 +24,17 @@
Open a link
</sky-action-button-details>
</sky-action-button>

<sky-action-button
[permalink]="permalink2">
<sky-action-button-icon
iconType="link">
</sky-action-button-icon>
<sky-action-button-header>
Open a route link
</sky-action-button-header>
<sky-action-button-details>
Open a route link
</sky-action-button-details>
</sky-action-button>
</sky-action-button-container>
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { Component } from '@angular/core';
import { SkyActionButtonPermalink } from '../types';

@Component({
selector: 'sky-test-cmp',
templateUrl: './action-button.component.fixture.html'
})
export class ActionButtonTestComponent {

public permalink1: SkyActionButtonPermalink = {
url: 'https://developer.blackbaud.com/skyux/components'
};

public permalink2: SkyActionButtonPermalink = {
route: {
commands: [],
extras: {
fragment: 'fragment',
queryParams: {
page: 1
},
queryParamsHandling: 'merge'
}
}
};

public buttonIsClicked: boolean = false;

public buttonClicked() {
Expand Down
1 change: 1 addition & 0 deletions src/modules/action-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { SkyActionButtonHeaderComponent } from './action-button-header.component
export { SkyActionButtonDetailsComponent } from './action-button-details.component';
export { SkyActionButtonContainerComponent } from './action-button-container.component';
export { SkyActionButtonModule } from './action-button.module';
export { SkyActionButtonPermalink } from './types';
11 changes: 11 additions & 0 deletions src/modules/action-button/types/action-button-permalink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
NavigationExtras
} from '@angular/router';

export interface SkyActionButtonPermalink {
route?: {
commands: any[],
extras: NavigationExtras
};
url?: string;
}
1 change: 1 addition & 0 deletions src/modules/action-button/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './action-button-permalink';