Skip to content

Commit

Permalink
refactor: kebab menu update
Browse files Browse the repository at this point in the history
  • Loading branch information
filipemarins committed Sep 30, 2022
1 parent 3a2b6da commit d14a62f
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 95 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/client/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tracker.autorun((c) => {
});

AccountBox.addItem({
name: 'Manage_Omnichannel',
name: 'Omnichannel',
icon: 'headset',
href: '/omnichannel/current',
sideNav: 'omnichannelFlex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AccountBoxItem, IAppAccountBoxItem, isAppAccountBoxItem } from '../../.
import AdministrationModelList from './AdministrationModelList';
import AppsModelList from './AppsModelList';
import AuditModelList from './AuditModelList';
import SettingsModelList from './SettingsModelList';

type AdministrationListProps = {
accountBoxItems: (IAppAccountBoxItem | AccountBoxItem)[];
Expand All @@ -15,15 +14,13 @@ type AdministrationListProps = {
hasAuditPermission: boolean;
hasAuditLogPermission: boolean;
hasManageApps: boolean;
hasSettingsPermission: boolean;
};

const AdministrationList: FC<AdministrationListProps> = ({
accountBoxItems,
hasAuditPermission,
hasAuditLogPermission,
hasManageApps,
hasSettingsPermission,
hasAdminPermission,
closeList,
}) => {
Expand All @@ -32,11 +29,9 @@ const AdministrationList: FC<AdministrationListProps> = ({
const showAudit = hasAuditPermission || hasAuditLogPermission;
const showManageApps = hasManageApps || !!appBoxItems.length;
const showAdmin = hasAdminPermission || !!adminBoxItems.length;
const showSettings = hasSettingsPermission;

const list = [
showAdmin && <AdministrationModelList showAdmin={showAdmin} accountBoxItems={adminBoxItems} closeList={closeList} />,
showSettings && <SettingsModelList closeList={closeList} />,
showManageApps && <AppsModelList appBoxItems={appBoxItems} closeList={closeList} showManageApps={showManageApps} />,
showAudit && <AuditModelList showAudit={hasAuditPermission} showAuditLog={hasAuditLogPermission} closeList={closeList} />,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AdministrationModelList: FC<AdministrationModelListProps> = ({ accountBoxI
)}
<ListItem
icon='cog'
text={t('Manage_workspace')}
text={t('Workspace')}
action={(): void => {
if (hasInfoPermission) {
infoRoute.push();
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions apps/meteor/client/sidebar/header/actions/Administration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const ADMIN_PERMISSIONS = [
'manage-own-incoming-integrations',
'view-engagement-dashboard',
];
const SETTINGS_PERMISSIONS = ['view-privileged-setting', 'edit-privileged-setting', 'manage-selected-settings'];
const AUDIT_PERMISSIONS = ['can-audit'];
const AUDIT_LOG_PERMISSIONS = ['can-audit-log'];
const MANAGE_APPS_PERMISSIONS = ['manage-apps'];
Expand All @@ -48,9 +47,7 @@ const Administration: VFC<Omit<HTMLAttributes<HTMLElement>, 'is'>> = (props) =>
const hasAuditLogPermission = useAtLeastOnePermission(AUDIT_LOG_PERMISSIONS) && hasAuditLicense;
const hasManageApps = useAtLeastOnePermission(MANAGE_APPS_PERMISSIONS);
const hasAdminPermission = useAtLeastOnePermission(ADMIN_PERMISSIONS);
const hasSettingsPermission = useAtLeastOnePermission(SETTINGS_PERMISSIONS);
const showMenu =
hasAuditPermission || hasAuditLogPermission || hasManageApps || hasAdminPermission || hasSettingsPermission || !!accountBoxItems.length;
const showMenu = hasAuditPermission || hasAuditLogPermission || hasManageApps || hasAdminPermission || !!accountBoxItems.length;

return (
<>
Expand All @@ -66,7 +63,6 @@ const Administration: VFC<Omit<HTMLAttributes<HTMLElement>, 'is'>> = (props) =>
hasAuditPermission={hasAuditPermission}
hasAuditLogPermission={hasAuditLogPermission}
hasManageApps={hasManageApps}
hasSettingsPermission={hasSettingsPermission}
/>
</Dropdown>,
document.body,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5306,7 +5306,7 @@
"Would_you_like_to_place_chat_on_hold": "Would you like to place this chat On-Hold?",
"Wrap_up_the_call": "Wrap-up the call",
"Wrap_Up_Notes": "Wrap-Up Notes",
"Workspace_settings": "Workspace settings",
"Workspace": "Workspace",
"Yes": "Yes",
"Yes_archive_it": "Yes, archive it!",
"Yes_clear_all": "Yes, clear all!",
Expand Down
10 changes: 2 additions & 8 deletions apps/meteor/tests/e2e/administration-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,17 @@ test.describe.serial('administration-menu', () => {
});

test('expect open info page', async ({ page }) => {
await poHomeDiscussion.sidenav.openAdministrationByLabel('Manage workspace');
await poHomeDiscussion.sidenav.openAdministrationByLabel('Workspace');

await expect(page).toHaveURL('admin/info');
});

test('expect open omnichannel page', async ({ page }) => {
await poHomeDiscussion.sidenav.openAdministrationByLabel('Manage Omnichannel');
await poHomeDiscussion.sidenav.openAdministrationByLabel('Omnichannel');

await expect(page).toHaveURL('omnichannel/current');
});

test('expect open settings page', async ({ page }) => {
await poHomeDiscussion.sidenav.openAdministrationByLabel('Workspace settings');

await expect(page).toHaveURL('admin/settings');
});

test('expect open app marketplace page', async ({ page }) => {
await poHomeDiscussion.sidenav.openAdministrationByLabel('Marketplace');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const defaultConfig = {
'./AdministrationModelList': () => <p>Administration Model List</p>,
'./AppsModelList': () => <p>Apps Model List</p>,
'./AuditModelList': () => <p>Audit Model List</p>,
'./SettingsModelList': () => <p>Settings Model List</p>,
};

describe('components/AdministrationList/AdministrationList', () => {
Expand All @@ -34,14 +33,12 @@ describe('components/AdministrationList/AdministrationList', () => {
hasAuditPermission={true}
hasAuditLogPermission={true}
hasManageApps={true}
hasSettingsPermission={true}
hasAdminPermission={true}
/>,
);

expect(screen.getByText('Administration Model List')).to.exist;
expect(screen.getByText('Apps Model List')).to.exist;
expect(screen.getByText('Settings Model List')).to.exist;
expect(screen.getByText('Audit Model List')).to.exist;
});

Expand All @@ -56,7 +53,6 @@ describe('components/AdministrationList/AdministrationList', () => {

expect(screen.queryByText('Administration Model List')).to.not.exist;
expect(screen.queryByText('Apps Model List')).to.not.exist;
expect(screen.queryByText('Settings Model List')).to.not.exist;
expect(screen.queryByText('Audit Model List')).to.not.exist;
});

Expand All @@ -71,7 +67,6 @@ describe('components/AdministrationList/AdministrationList', () => {

expect(screen.getByText('Administration Model List')).to.exist;
expect(screen.queryByText('Apps Model List')).to.not.exist;
expect(screen.queryByText('Settings Model List')).to.not.exist;
expect(screen.queryByText('Audit Model List')).to.not.exist;
});

Expand All @@ -91,7 +86,6 @@ describe('components/AdministrationList/AdministrationList', () => {

expect(screen.getByText('Apps Model List')).to.exist;
expect(screen.queryByText('Administration Model List')).to.not.exist;
expect(screen.queryByText('Settings Model List')).to.not.exist;
expect(screen.queryByText('Audit Model List')).to.not.exist;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('components/AdministrationList/AdministrationModelList', () => {
render(<AdministrationModelList closeList={() => null} accountBoxItems={[]} showAdmin={true} />);

expect(screen.getByText('Administration')).to.exist;
expect(screen.getByText('Manage_workspace')).to.exist;
expect(screen.getByText('Workspace')).to.exist;
expect(screen.getByText('Upgrade')).to.exist;
});

Expand All @@ -49,7 +49,7 @@ describe('components/AdministrationList/AdministrationModelList', () => {
render(<AdministrationModelList closeList={() => null} accountBoxItems={[]} showAdmin={false} />);

expect(screen.getByText('Administration')).to.exist;
expect(screen.queryByText('Manage_workspace')).to.not.exist;
expect(screen.queryByText('Workspace')).to.not.exist;
expect(screen.queryByText('Upgrade')).to.not.exist;
});

Expand All @@ -63,7 +63,7 @@ describe('components/AdministrationList/AdministrationModelList', () => {
<AdministrationModelList closeList={closeList} accountBoxItems={[]} showAdmin={true} />
</RouterContextMock>,
);
const button = screen.getByText('Manage_workspace');
const button = screen.getByText('Workspace');

userEvent.click(button);
await waitFor(() => expect(pushRoute).to.have.been.called.with('admin-info'));
Expand All @@ -85,7 +85,7 @@ describe('components/AdministrationList/AdministrationModelList', () => {
<AdministrationModelList closeList={closeList} accountBoxItems={[]} showAdmin={true} />
</RouterContextMock>,
);
const button = screen.getByText('Manage_workspace');
const button = screen.getByText('Workspace');

userEvent.click(button);
await waitFor(() => expect(pushRoute).to.have.been.called.with('admin-index'));
Expand Down

This file was deleted.

0 comments on commit d14a62f

Please sign in to comment.