-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds page headers for updated UX (#2083)
* Adds initial commit to add header components and modifies get started and user list pages Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates auth-view page Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates user edit and create pages Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates user permissions page Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates dashboards tenancy page Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates dashboards audit logs page Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates roles and related pages Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Updates variable name and fixes indentation Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Push logic into new component Signed-off-by: Derek Ho <dxho@amazon.com> * Lint Signed-off-by: Derek Ho <dxho@amazon.com> * Migrate audit logging and tenant tabs to new page header Signed-off-by: Derek Ho <dxho@amazon.com> * Migrate all tabs to new component Signed-off-by: Derek Ho <dxho@amazon.com> * Remove prop and fix some test failures Signed-off-by: Derek Ho <dxho@amazon.com> * fix most tests Signed-off-by: Derek Ho <dxho@amazon.com> * Fix existing tests Signed-off-by: Derek Ho <dxho@amazon.com> * Push breadcrumb population into child components Signed-off-by: Derek Ho <dxho@amazon.com> * Migrate breadcrumbs into the page header component for the top level of all pages Signed-off-by: Derek Ho <dxho@amazon.com> * Lint Signed-off-by: Derek Ho <dxho@amazon.com> * Update all instances of breadcrumbs to new component and all existing tests pass Signed-off-by: Derek Ho <dxho@amazon.com> * Fixes target _blank redirects Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Fixes unit tests Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Add tests for new component and breadcrumb function Signed-off-by: Derek Ho <dxho@amazon.com> * Address PR feedback Signed-off-by: Derek Ho <dxho@amazon.com> * Update tests and snapshots Signed-off-by: Derek Ho <dxho@amazon.com> --------- Signed-off-by: Darshit Chanpura <dchanp@amazon.com> Signed-off-by: Derek Ho <dxho@amazon.com> Co-authored-by: Derek Ho <dxho@amazon.com> (cherry picked from commit dc79df3) Signed-off-by: Derek Ho <dxho@amazon.com>
- Loading branch information
1 parent
80976be
commit 23a8341
Showing
43 changed files
with
1,899 additions
and
568 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { flow } from 'lodash'; | ||
import { ControlProps, DescriptionProps, HeaderProps } from './header-props'; | ||
import { getBreadcrumbs } from '../utils/resource-utils'; | ||
|
||
export const HeaderButtonOrLink = React.memo((props: HeaderProps & ControlProps) => { | ||
const { HeaderControl } = props.navigation.ui; | ||
|
||
return ( | ||
<HeaderControl | ||
setMountPoint={props.coreStart.application.setAppRightControls} | ||
controls={props.appRightControls} | ||
/> | ||
); | ||
}); | ||
|
||
export const PageHeader = (props: HeaderProps & DescriptionProps & ControlProps) => { | ||
const { HeaderControl } = props.navigation.ui; // need to get this from SecurityPluginStartDependencies | ||
const useNewUx = props.coreStart.uiSettings.get('home:useNewHomePage'); | ||
flow(getBreadcrumbs, props.coreStart.chrome.setBreadcrumbs)( | ||
!useNewUx, | ||
props.resourceType, | ||
props.pageTitle, | ||
props.subAction, | ||
props.count | ||
); | ||
if (useNewUx) { | ||
return ( | ||
<> | ||
{props.descriptionControls ? ( | ||
<HeaderControl | ||
setMountPoint={props.coreStart.application.setAppDescriptionControls} | ||
controls={props.descriptionControls} | ||
/> | ||
) : null} | ||
{props.appRightControls ? ( | ||
<HeaderControl | ||
setMountPoint={props.coreStart.application.setAppRightControls} | ||
controls={props.appRightControls} | ||
/> | ||
) : null} | ||
</> | ||
); | ||
} else { | ||
return props.fallBackComponent; | ||
} | ||
}; |
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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public'; | ||
import { TopNavControlData } from 'src/plugins/navigation/public/top_nav_menu/top_nav_control_data'; | ||
import { ResourceType } from '../../../../common'; | ||
|
||
export interface HeaderProps { | ||
navigation: NavigationPublicPluginStart; | ||
coreStart: CoreStart; | ||
fallBackComponent: JSX.Element; | ||
resourceType?: ResourceType; | ||
pageTitle?: string; | ||
subAction?: string; | ||
count?: number; | ||
} | ||
|
||
export interface ControlProps { | ||
appRightControls?: TopNavControlData[]; | ||
} | ||
|
||
export interface DescriptionProps { | ||
descriptionControls?: TopNavControlData[]; | ||
} |
Oops, something went wrong.