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

feat(stark-ui): action-bar Component #495

Merged

Conversation

catlabs
Copy link
Contributor

@catlabs catlabs commented Jul 10, 2018

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #481

What is the new behavior?

Action Bar - implement component/module
New stark-action-bar component integrated in stark-ui package.

@coveralls
Copy link

coveralls commented Jul 10, 2018

Coverage Status

Coverage decreased (-0.05%) to 94.648% when pulling d1dd733 on catlabs:feature/action-bar into 34af0ae on NationalBankBelgium:master.

describe("ActionBarComponent", () => {
let fixture: ComponentFixture<StarkActionBarComponent>;
let component: StarkActionBarComponent;
const buttonToogleSelector: string = ".extend-action-bar";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small typo buttonToogleSelector -> buttonToggleSelector 😏

public isExtended: boolean = false;

/**
* toogle the extended action in full mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same typo toogle => toggle 😉

@@ -121,8 +121,8 @@
"@angular/platform-browser-dynamic": "6.0.7",
"@angular/platform-server": "6.0.7",
"@angular/router": "6.0.7",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-6796ad0.tgz",
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.3-6796ad0.tgz",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-00a78ab.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't include the package.json files in the commit if only the build number of a stark package has changed.

router.plugin(Visualizer);
//Uncomment if needed
/*router.trace.enable(Category.TRANSITION);
router.plugin(Visualizer);*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to put these kind of changes in a separate PR.
Now it is hidden inside this PR and harder to find in the future.

@@ -10,7 +10,7 @@ import { STARK_LOGGING_SERVICE, StarkErrorImpl, StarkLoggingService } from "@nat
providers: [FileService]
})
export class ExampleViewerComponent implements OnInit {
@Input() public extensions: string[] = ["HTML", "TS", "CSS"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the CSS removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For every component, we have now 2 SCSS files, one for the colors (them) and one for the rest of the styles. It is up to the end user if he wants to include those files or not, so they have more flexibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm I think that this has nothing to do with the fact that there are 2 SCSS files for each component. This remark is about the CSS tab of the example viewer. Aren't we supposed to demo all what is needed to use a certain component? That means the TS code, HTML and CSS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well for the action bar component for instance, I don't need any specific CSS

Copy link
Collaborator

@christophercr christophercr Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but this is the example-viewer component so technically by default a demoed component should have HTML and CSS. In your case, the usage you do for the Action Bar demo you don't need it but that is just a specific use case so you just give a different value in the "extensions" input.

@@ -124,8 +124,8 @@
"@angular/platform-browser-dynamic": "6.0.7",
"@angular/platform-server": "6.0.7",
"@angular/router": "6.0.7",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-6796ad0.tgz",
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.3-6796ad0.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark:
Don't include the package.json files in the commit if only the build number of a stark package has changed.

@catlabs catlabs force-pushed the feature/action-bar branch from a61084c to ceff69e Compare July 11, 2018 08:22
Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the remarks below, I think the translation support is missing. Could you please add it?

You can have a look in the old Stark how this is implemented.

@@ -0,0 +1,8 @@
$tablet-query: "(min-width: 600px)";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file called "old-media-queries"? Are we going to create new media queries? If not, then I think we should simply call it "media-queries"

{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
{ provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService }
],
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please specify in the comment which elements we don't want to include?

label: "Validate",
icon: "check",
actionCall: ($event: Event, data: any): void => {
console.log($event);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid adding console.log in the tests otherwise they are cluttered with lots of logs that makes it hard to read the test logs. You can use an spy or a noop.

Moreover, if you use Spies then in your tests you can remove the spyOn(...) calls since they will already be spies ;)

label: "Save",
icon: "content-save",
actionCall: ($event: Event, data: any): void => {
console.log($event);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark... let's avoid console.log

@@ -0,0 +1,98 @@
"use strict";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use strict directive is not needed anymore, this is added automatically by TSC when compiling the code.

component.mode = 'full';
fixture.detectChanges();
const buttonToggleExtend: HTMLElement = fixture.nativeElement.querySelector(buttonToggleSelector);
expect(buttonToggleExtend).toBeTruthy();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the matcher .toBeDefined() is more suitable and accurate in this case

component.mode = 'compact';
fixture.detectChanges();
const buttonToggleExtend: HTMLElement = fixture.nativeElement.querySelector(buttonToggleSelector);
expect(buttonToggleExtend).toBeFalsy();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the matcher .toBeUndefined() is more accurate in this case

describe("@Input() actionBarId", () => {
it("should have set the id of the action bar", () => {
const actionBar: HTMLElement = fixture.nativeElement.querySelector("#"+component.actionBarId);
component.actionBarId = "action-bar-id";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 lines are a bit weird and confusing. The first line sets already the id (which is unknown by the way at this point) and then the second line sets the id. Finally in the last line of this test the id is checked.

You can improve this test by one of these 2 options:

  • changing the order of these 2 lines and get the HTML element just after calling fixture.detectChanges()
  • add an expectation just after the first line to expect the HTMLElement to be undefined (because the querySelector will not find the element) and then add another expectation before the last line to expect the HTMLElement to be defined.

});

describe("@Input() actionBarConfig", () => {
it("should call the defined action when disabled", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should NOT call the defined action when disabled" ;)


it("should display", () => {
const actionBar: HTMLElement = fixture.nativeElement.querySelector(".open-alt-actions");
expect(actionBar).toBeTruthy();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the matcher .toBeDefined() is more suitable and accurate in this case

@catlabs catlabs force-pushed the feature/action-bar branch from ceff69e to bb9d6ba Compare July 11, 2018 10:58
@catlabs
Copy link
Contributor Author

catlabs commented Jul 11, 2018

I added a ticket about translation:
#497

@catlabs catlabs force-pushed the feature/action-bar branch 3 times, most recently from c84a611 to ce3fb85 Compare July 12, 2018 10:01
@@ -12,6 +12,21 @@ export const translationsEn: object = {
SORTING: {
ASC: "Ascending",
DESC: "Descending"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to think about the best place to put those translations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created: #511

export class StarkActionBarComponent {
@Input() public actionBarId: string = "";
@Input() public actionBarConfig: StarkActionBarConfig;
@Input() public actionBarScope: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please JSDoc documentation for those bindings ?

@catlabs catlabs force-pushed the feature/action-bar branch 2 times, most recently from 5fc32cd to 97375e3 Compare July 13, 2018 13:13
@catlabs catlabs force-pushed the feature/action-bar branch from 97375e3 to d1dd733 Compare July 13, 2018 13:20
@christophercr christophercr changed the title feat(stark-ui): action Bar Component feat(stark-ui): action-bar Component Jul 13, 2018
@christophercr christophercr merged commit 90c53fe into NationalBankBelgium:master Jul 13, 2018
@catlabs catlabs deleted the feature/action-bar branch July 17, 2018 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants