-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Dashboard widgets for 2.10 ER1 (#2194)
* Skip cuke redirect to upgrade for multiple_services * adds products and backend_apis index * integrates rails with new dashboard widgets * add widget to first page * adds missing field for last updated date * * adds boilerplate for backends and products index pages* adds missing fields * lots more updates * adds missing paths to prop "links" * removes TODO comments * updates to api page * adds missing field system_name * 🚧 more efficient * add backend table * adds missing system_name * more updates to backend * ✅ test for services index * Update test/integration/api/services_controller_test.rb Co-authored-by: Marta <Martouta@users.noreply.github.com> * adds missing fields * adds missing system_name * rebase * ✏️ fixes typo * extracts data-list componet * fix merge conflict * work on pagination * fix pagination * adds itemCount prop for backends and products * jose suggested changes * reorganizes imports * removes console logs * typo * reduces verbosity * fixes indentation * fixes close with click outside effect * ✅ fixes test due to new PF version * 🚨 makes Flow happy * 🚧 search * Sphinx search Service * Sphinx search BackendAPI * fixes products widget's icon * fixes widgets' links * adds missing link for Edit page * fixes console error intruduced by isPlainButtonAction * ✅ 🥒 * ✅ fixes controller test * 💩 we need to fix this test * Fixing provider_side.feature * Cuke Fix '/p/signup/...' not found for missing the host * fixes * Add JS to follow 'API' Co-authored-by: Marta Noya <mnoyabon@redhat.com> Co-authored-by: Christie Molloy <cmolloy@redhat.com> Co-authored-by: Marta <Martouta@users.noreply.github.com> Co-authored-by: Damian Peralta <damianperaltam@gmail.com>
- Loading branch information
1 parent
76be205
commit 5e45439
Showing
54 changed files
with
1,020 additions
and
172 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
ThinkingSphinx::Index.define(:backend_api, with: :real_time) do | ||
indexes :name, as: :name | ||
end |
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
ThinkingSphinx::Index.define(:service, with: :real_time) do | ||
indexes :name, as: :name | ||
end |
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 @@ | ||
import 'patternflyStyles/dashboard' |
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,15 @@ | ||
import { BackendsIndexPageWrapper } from 'BackendApis/components/IndexPage' | ||
import { safeFromJsonString } from 'utilities/json-utils' | ||
|
||
const containerId = 'backend-apis' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const container = document.getElementById(containerId) | ||
|
||
const { backends, backendsCount } = container.dataset | ||
|
||
BackendsIndexPageWrapper({ | ||
backends: safeFromJsonString(backends), | ||
backendsCount: safeFromJsonString(backendsCount) | ||
}, containerId) | ||
}) |
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,16 @@ | ||
import { BackendsWidgetWrapper } from 'Dashboard/components/BackendsWidget' | ||
import { safeFromJsonString } from 'utilities/json-utils' | ||
|
||
const containerId = 'backends-widget' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const container = document.getElementById(containerId) | ||
|
||
const { newBackendPath, backendsPath, backends } = safeFromJsonString(container.dataset.backendsWidget) | ||
|
||
BackendsWidgetWrapper({ | ||
newBackendPath, | ||
backendsPath, | ||
backends: safeFromJsonString(backends) | ||
}, containerId) | ||
}) |
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,16 @@ | ||
import { ProductsWidgetWrapper } from 'Dashboard/components/ProductsWidget' | ||
import { safeFromJsonString } from 'utilities/json-utils' | ||
|
||
const containerId = 'products-widget' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const container = document.getElementById(containerId) | ||
|
||
const { newProductPath, productsPath, products } = safeFromJsonString(container.dataset.productsWidget) | ||
|
||
ProductsWidgetWrapper({ | ||
newProductPath, | ||
productsPath, | ||
products: safeFromJsonString(products) | ||
}, containerId) | ||
}) |
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,15 @@ | ||
import { ProductsIndexPageWrapper } from 'Products/components/IndexPage' | ||
import { safeFromJsonString } from 'utilities/json-utils' | ||
|
||
const containerId = 'products' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const container = document.getElementById(containerId) | ||
|
||
const { products, productsCount } = container.dataset | ||
|
||
ProductsIndexPageWrapper({ | ||
products: safeFromJsonString(products), | ||
productsCount: safeFromJsonString(productsCount) | ||
}, containerId) | ||
}) |
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,162 @@ | ||
// @flow | ||
|
||
import React from 'react' | ||
import { | ||
Form, | ||
Level, | ||
LevelItem, | ||
InputGroup, | ||
TextInput, | ||
Button, | ||
ButtonVariant, | ||
PageSection, | ||
Pagination as PFPagination, | ||
PaginationVariant, | ||
PageSectionVariants, | ||
Title, | ||
Divider, | ||
Toolbar, | ||
ToolbarItem | ||
} from '@patternfly/react-core' | ||
import { | ||
Table, | ||
TableHeader, | ||
TableBody | ||
} from '@patternfly/react-table' | ||
import SearchIcon from '@patternfly/react-icons/dist/js/icons/search-icon' | ||
import { createReactWrapper } from 'utilities/createReactWrapper' | ||
|
||
import 'BackendApis/styles/backends.scss' | ||
|
||
type Props = { | ||
backendsCount: number, | ||
backends: Array<{ | ||
id: number, | ||
system_name: string, | ||
private_endpoint: string, | ||
link: string, | ||
links: Array<{ | ||
name: string, | ||
path: string | ||
}>, | ||
name: string, | ||
products_count: number, | ||
type: string, | ||
updated_at: string, | ||
}> | ||
} | ||
|
||
const BackendsIndexPage = ({ backendsCount, backends }: Props) => { | ||
const tableColumns = [ | ||
'Name', | ||
'System name', | ||
'Last updated', | ||
'Private base URL', | ||
'Linked products' | ||
] | ||
|
||
const tableRows = backends.map((tableRow) => ({ | ||
cells: [ | ||
{ title: <Button href={tableRow.links[1].path} component="a" variant="link" isInline>{tableRow.name}</Button> }, | ||
tableRow.system_name, | ||
<span className="api-table-timestamp">{tableRow.updated_at}</span>, | ||
tableRow.private_endpoint, | ||
tableRow.products_count | ||
] | ||
})) | ||
|
||
const linkToPage = (rowId, actionNumber) => { | ||
const { path } = backends[rowId].links[actionNumber] | ||
window.location.href = path | ||
} | ||
|
||
const tableActions = ['Edit', 'Overview', 'Analytics', 'Methods and Metrics', 'Mapping Rules'].map((title, i) => ({ | ||
title, | ||
onClick: (_event, rowId) => linkToPage(rowId, i) | ||
})) | ||
|
||
const url = new URL(window.location.href) | ||
|
||
const selectPerPage = (_event, selectedPerPage) => { | ||
url.searchParams.set('per_page', selectedPerPage) | ||
url.searchParams.delete('page') | ||
window.location.href = url.toString() | ||
} | ||
|
||
const goToPage = (page) => { | ||
url.searchParams.set('page', page) | ||
window.location.href = url.toString() | ||
} | ||
|
||
const Pagination = ({ variant }: { variant?: string }) => { | ||
const perPage = url.searchParams.get('per_page') | ||
const page = url.searchParams.get('page') | ||
return ( | ||
<PFPagination | ||
widgetId="pagination-options-menu-top" | ||
itemCount={backendsCount} | ||
perPage={Number(perPage) || 20} | ||
page={Number(page)} | ||
onPerPageSelect={selectPerPage} | ||
onNextClick={(_ev, page) => goToPage(page)} | ||
onPreviousClick={(_ev, page) => goToPage(page)} | ||
onFirstClick={(_ev, page) => goToPage(page)} | ||
onLastClick={(_ev, page) => goToPage(page)} | ||
perPageOptions={[ { title: '10', value: 10 }, { title: '20', value: 20 } ]} | ||
variant={variant} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<PageSection className="api-table-page-section" variant={PageSectionVariants.light}> | ||
<Level> | ||
<LevelItem> | ||
<Title headingLevel="h1" size="2xl">Backends</Title> | ||
</LevelItem> | ||
<LevelItem> | ||
<Button variant="primary" component="a" href="/p/admin/backend_apis/new"> | ||
Create Backend | ||
</Button> | ||
</LevelItem> | ||
</Level> | ||
<p className="api-table-description"> | ||
Explore and manage all your internal APIs. | ||
</p> | ||
<Divider/> | ||
<Toolbar id="top-toolbar" className="pf-c-toolbar"> | ||
<div className="pf-c-toolbar__content"> | ||
<ToolbarItem> | ||
<Form id="new_search" action="/p/admin/backend_apis" acceptCharset="UTF-8" method="get"> | ||
<InputGroup className="api-table-search"> | ||
<input name="utf8" type="hidden" value="✓" /> | ||
<TextInput placeholder="Find a Backend" name="search[query]" id="findBackend" type="search" aria-label="Find a backend" /> | ||
<Button variant={ButtonVariant.control} aria-label="search button for search input" type="submit"> | ||
<SearchIcon /> | ||
</Button> | ||
</InputGroup> | ||
</Form> | ||
</ToolbarItem> | ||
<ToolbarItem className="api-toolbar-pagination" align={{ default: 'alignRight' }}> | ||
<Pagination /> | ||
</ToolbarItem> | ||
</div> | ||
</Toolbar> | ||
<Table aria-label="Actions Table" actions={tableActions} cells={tableColumns} rows={tableRows}> | ||
<TableHeader /> | ||
<TableBody /> | ||
</Table> | ||
<Toolbar id="bottom-toolbar" className="pf-c-toolbar"> | ||
<div className="pf-c-toolbar__content"> | ||
<ToolbarItem className="api-toolbar-pagination" align={{ default: 'alignRight' }}> | ||
<Pagination variant={PaginationVariant.bottom} /> | ||
</ToolbarItem> | ||
</div> | ||
</Toolbar> | ||
</PageSection> | ||
) | ||
} | ||
|
||
const BackendsIndexPageWrapper = (props: Props, containerId: string) => createReactWrapper(<BackendsIndexPage {...props} />, containerId) | ||
|
||
export { BackendsIndexPageWrapper } |
Oops, something went wrong.