This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add edit company * Add edit company * fix test
- Loading branch information
1 parent
0682076
commit 498a159
Showing
43 changed files
with
1,085 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/pages/companies/edit-company/components/page-header/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PageHeader } from "./page-header"; |
49 changes: 49 additions & 0 deletions
49
src/pages/companies/edit-company/components/page-header/page-header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from "react"; | ||
import { | ||
Stack, | ||
StackItem, | ||
Split, | ||
SplitItem, | ||
TextContent, | ||
Text, | ||
} from "@patternfly/react-core"; | ||
import { BreadCrumbPath } from "shared/components/breadcrumb-path"; | ||
import { MenuActions } from "shared/components/menu-actions"; | ||
import { HorizontalNav } from "shared/components/horizontal-nav/horizontal-nav"; | ||
|
||
export interface PageHeaderProps { | ||
title: string; | ||
breadcrumbs: { title: string; path: string }[]; | ||
menuActions: { label: string; callback: () => void }[]; | ||
navItems: { title: string; path: string }[]; | ||
} | ||
|
||
export const PageHeader: React.FC<PageHeaderProps> = ({ | ||
title, | ||
breadcrumbs, | ||
menuActions, | ||
navItems, | ||
}) => { | ||
return ( | ||
<Stack hasGutter> | ||
<StackItem> | ||
<BreadCrumbPath breadcrumbs={breadcrumbs} /> | ||
</StackItem> | ||
<StackItem> | ||
<Split> | ||
<SplitItem isFilled> | ||
<TextContent> | ||
<Text component="h1">{title}</Text> | ||
</TextContent> | ||
</SplitItem> | ||
<SplitItem> | ||
<MenuActions actions={menuActions} /> | ||
</SplitItem> | ||
</Split> | ||
</StackItem> | ||
<StackItem> | ||
<HorizontalNav navItems={navItems} /> | ||
</StackItem> | ||
</Stack> | ||
); | ||
}; |
55 changes: 55 additions & 0 deletions
55
src/pages/companies/edit-company/components/page-header/stories/page-header.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from "react"; | ||
import { HashRouter } from "react-router-dom"; | ||
import { Story, Meta } from "@storybook/react/types-6-0"; | ||
import { action } from "@storybook/addon-actions"; | ||
import { PageHeader, PageHeaderProps } from "../page-header"; | ||
|
||
export default { | ||
title: "Edit company / PageHeader", | ||
component: PageHeader, | ||
argTypes: {}, | ||
} as Meta; | ||
|
||
const Template: Story<PageHeaderProps> = (args) => ( | ||
<HashRouter> | ||
<PageHeader {...args} /> | ||
</HashRouter> | ||
); | ||
export const Basic = Template.bind({}); | ||
Basic.args = { | ||
title: "mycompany", | ||
breadcrumbs: [ | ||
{ | ||
title: "Companies", | ||
path: "/companies", | ||
}, | ||
{ | ||
title: "Company details", | ||
path: "/companies/1", | ||
}, | ||
], | ||
menuActions: [ | ||
{ | ||
label: "Edit", | ||
callback: action("Edit"), | ||
}, | ||
{ | ||
label: "Delete", | ||
callback: action("Delete"), | ||
}, | ||
], | ||
navItems: [ | ||
{ | ||
title: "Overview", | ||
path: "/companies/1/overview", | ||
}, | ||
{ | ||
title: "YAML", | ||
path: "/companies/1/yaml", | ||
}, | ||
{ | ||
title: "SUNAT", | ||
path: "/companies/1/sunat", | ||
}, | ||
], | ||
}; |
75 changes: 75 additions & 0 deletions
75
...mpanies/edit-company/components/page-header/tests/__snapshots__/page-header.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PageHeader Renders without crashing 1`] = ` | ||
<Stack | ||
hasGutter={true} | ||
> | ||
<StackItem> | ||
<BreadCrumbPath | ||
breadcrumbs={ | ||
Array [ | ||
Object { | ||
"path": "/companies", | ||
"title": "Companies", | ||
}, | ||
Object { | ||
"path": "/companies/1", | ||
"title": "Company details", | ||
}, | ||
] | ||
} | ||
/> | ||
</StackItem> | ||
<StackItem> | ||
<Split> | ||
<SplitItem | ||
isFilled={true} | ||
> | ||
<TextContent> | ||
<Text | ||
component="h1" | ||
> | ||
mycompany | ||
</Text> | ||
</TextContent> | ||
</SplitItem> | ||
<SplitItem> | ||
<MenuActions | ||
actions={ | ||
Array [ | ||
Object { | ||
"callback": [MockFunction], | ||
"label": "Edit", | ||
}, | ||
Object { | ||
"callback": [MockFunction], | ||
"label": "Delete", | ||
}, | ||
] | ||
} | ||
/> | ||
</SplitItem> | ||
</Split> | ||
</StackItem> | ||
<StackItem> | ||
<HorizontalNav | ||
navItems={ | ||
Array [ | ||
Object { | ||
"path": "/companies/1/overview", | ||
"title": "Overview", | ||
}, | ||
Object { | ||
"path": "/companies/1/yaml", | ||
"title": "YAML", | ||
}, | ||
Object { | ||
"path": "/companies/1/sunat", | ||
"title": "SUNAT", | ||
}, | ||
] | ||
} | ||
/> | ||
</StackItem> | ||
</Stack> | ||
`; |
48 changes: 48 additions & 0 deletions
48
src/pages/companies/edit-company/components/page-header/tests/page-header.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import { shallow } from "enzyme"; | ||
import { PageHeader } from "../page-header"; | ||
|
||
describe("PageHeader", () => { | ||
it("Renders without crashing", () => { | ||
const wrapper = shallow( | ||
<PageHeader | ||
title="mycompany" | ||
breadcrumbs={[ | ||
{ | ||
title: "Companies", | ||
path: "/companies", | ||
}, | ||
{ | ||
title: "Company details", | ||
path: "/companies/1", | ||
}, | ||
]} | ||
menuActions={[ | ||
{ | ||
label: "Edit", | ||
callback: jest.fn(), | ||
}, | ||
{ | ||
label: "Delete", | ||
callback: jest.fn(), | ||
}, | ||
]} | ||
navItems={[ | ||
{ | ||
title: "Overview", | ||
path: "/companies/1/overview", | ||
}, | ||
{ | ||
title: "YAML", | ||
path: "/companies/1/yaml", | ||
}, | ||
{ | ||
title: "SUNAT", | ||
path: "/companies/1/sunat", | ||
}, | ||
]} | ||
/> | ||
); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.