Skip to content

Added role view dropdown #2378

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

Merged
merged 49 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
db5b5ba
Boostrapped React-based admin panel.
alzaslon Feb 9, 2023
3eaab4a
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Feb 12, 2023
0334e9d
Navigation top level
jsorohova Feb 13, 2023
cf371f0
Navigation - pages
jsorohova Feb 14, 2023
ee7cda7
Pages navigation item
jsorohova Feb 28, 2023
c1cdb69
Delete confirmation code improvement
jsorohova Feb 28, 2023
bf3c7bd
Navigation 'Navigation' item
jsorohova Mar 6, 2023
c0c1f39
Settings and Help navigation items, Top panel
jsorohova Mar 7, 2023
181e80c
Page/Layout modals
jsorohova Mar 14, 2023
b42d75a
Media modal
jsorohova Mar 29, 2023
8842df5
Media modals
jsorohova May 19, 2023
9f3d2a6
Merge conflict fixes
jsorohova May 19, 2023
ca13e11
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova May 23, 2023
9b94bde
Focused layout
jsorohova May 25, 2023
90b2aa7
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova May 28, 2023
cfa92de
Styles and Custom widgets items
jsorohova May 31, 2023
c0a2bca
Mobile styles
jsorohova Jun 3, 2023
522b60c
URLs navigation item
jsorohova Jun 10, 2023
62475bc
Toast notifications
jsorohova Jun 12, 2023
38b82fd
Site menu
jsorohova Jun 14, 2023
803daa1
Favicon upload
jsorohova Jun 14, 2023
7e4b65e
Popups item
jsorohova Jun 14, 2023
027dab9
Merged master
jsorohova Jun 19, 2023
39b0929
Onboarding modal
jsorohova Jun 27, 2023
6c6fcea
Components updates
jsorohova Jul 14, 2023
01e6114
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Jul 17, 2023
2b11227
Merged master branch
jsorohova Aug 14, 2023
6a74d90
Anchors and bug fixes
jsorohova Sep 6, 2023
85b7fb7
Content changes
jsorohova Sep 9, 2023
c1ea0c7
Merged master branch
jsorohova Sep 20, 2023
42213f2
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Sep 20, 2023
8f329d9
Validation implementation
jsorohova Sep 28, 2023
446a915
Reset content flow restyling
jsorohova Sep 28, 2023
06ec0f6
Pagination support
jsorohova Sep 28, 2023
9e21876
Loaders and content changes
jsorohova Oct 6, 2023
8b836fc
Permalink validation fixes
jsorohova Oct 6, 2023
403190d
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Oct 6, 2023
2c87b7d
Feedback link change
jsorohova Oct 10, 2023
a78d254
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Nov 15, 2023
523be48
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Nov 24, 2023
807006c
Accessibility fixes
jsorohova Nov 27, 2023
27700a3
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Dec 14, 2023
3ffe9ff
Fixed Settings modal incorrect behaviour
jsorohova Dec 14, 2023
c40c4ed
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Jan 22, 2024
79f0c82
Validation fixes
jsorohova Jan 22, 2024
73f8e33
Fixed Link media functionality
jsorohova Jan 23, 2024
01c6c78
Added role view dropdown
jsorohova Jan 26, 2024
d9c56a0
Merge branch 'master' of https://github.com/Azure/api-management-deve…
jsorohova Jan 26, 2024
cb223e1
CR fix
jsorohova Jan 26, 2024
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
59 changes: 57 additions & 2 deletions src/admin/rightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EventManager } from '@paperbits/common/events';
import { OfflineObjectStorage } from '@paperbits/common/persistence';
import { IPageService } from '@paperbits/common/pages';
import { ILayoutService } from '@paperbits/common/layouts';
import { RoleModel, RoleService } from '@paperbits/common/user';
import { Router } from '@paperbits/common/routing';
import { Resolve } from '@paperbits/react/decorators';
import { ContentWorkshop } from '../components/content';
Expand All @@ -23,7 +24,9 @@ interface RightPanelState {
canRedo: boolean,
mobileMenuIsOpened: boolean,
dropdownIconStyles: object,
pageName: string
pageName: string,
roles: RoleModel[],
rolesOptions: IDropdownOption[]
}

const enum HostNames {
Expand All @@ -46,6 +49,9 @@ const undoIcon: IIconProps = { iconName: 'Undo', styles: iconStyles };
const redoIcon: IIconProps = { iconName: 'Redo', styles: iconStyles };
const sidePanelToggleIcon: IIconProps = { iconName: 'GlobalNavButton', styles: { root: { color: lightTheme.palette.themePrimary } } };

const anonymousKey: string = 'anonymous';
const anonymousName: string = 'Anonymous';

export class RightPanel extends React.Component<{}, RightPanelState> {
@Resolve('viewManager')
public viewManager: ViewManager;
Expand All @@ -68,6 +74,9 @@ export class RightPanel extends React.Component<{}, RightPanelState> {
@Resolve('layoutService')
public layoutService: ILayoutService;

@Resolve('roleService')
public roleService: RoleService;

constructor(props: any) {
super(props);

Expand All @@ -80,14 +89,17 @@ export class RightPanel extends React.Component<{}, RightPanelState> {
canRedo: false,
mobileMenuIsOpened: false,
dropdownIconStyles: { marginRight: '8px', color: lightTheme.palette.themePrimary },
pageName: ''
pageName: '',
roles: [{ key: anonymousKey, name: anonymousName }],
rolesOptions: [{ key: anonymousKey, text: anonymousName }]
};
}

componentDidMount(): void {
this.eventManager.addEventListener('onDataChange', this.onDataChange.bind(this));
window.addEventListener('resize', this.checkScreenSize.bind(this));
this.checkScreenSize();
this.getRoles();
}

componentDidUpdate(prevProps: Readonly<{}>, prevState: Readonly<RightPanelState>, snapshot?: any): void {
Expand All @@ -108,6 +120,22 @@ export class RightPanel extends React.Component<{}, RightPanelState> {
window.removeEventListener('resize', this.checkScreenSize.bind(this));
}

getRoles = async (): Promise<void> => {
const roles = await this.roleService.getRoles();

if (!roles) return;

const dropdownItems = [];
roles.forEach(page => {
dropdownItems.push({
key: page.key,
text: page.name
});
});

this.setState({ roles, rolesOptions: dropdownItems });
}

getPageName = async (): Promise<void> => {
const page = await this.pageService.getPageByPermalink(this.router.getPath());
if (page) this.setState({ pageName: 'Page: ' + page.title });
Expand Down Expand Up @@ -181,14 +209,41 @@ export class RightPanel extends React.Component<{}, RightPanelState> {
</Stack>
)

renderRoleDropdownOption = (option: IDropdownOption): JSX.Element => (
<Stack horizontal verticalAlign="center">
<Icon
style={this.state.dropdownIconStyles}
iconName="People"
title="People"
/>
<span>View as: {option.text}</span>
</Stack>
)

renderTitle = (options: IDropdownOption[]): JSX.Element => {
const option = options[0];

return this.renderDropdownOption(option);
}

renderRoleTitle = (options: IDropdownOption[]): JSX.Element => {
const option = options[0];

return this.renderRoleDropdownOption(option);
}

renderDropdowns = (): JSX.Element => (
<Stack horizontal>
<Dropdown
defaultSelectedKey={anonymousKey}
ariaLabel="Role view selector"
onRenderTitle={this.renderRoleTitle}
options={this.state.rolesOptions}
onChange={(event, option) => this.viewManager.setViewRoles([this.state.roles.find(role => role.key === option.key)])}
styles={dropdownStyles}
className="top-panel-dropdown"
dropdownWidth={170}
/>
<Dropdown
defaultSelectedKey="xl"
ariaLabel="Screen size selector"
Expand Down