Skip to content

Commit

Permalink
chore: Project menu with plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Nov 29, 2024
1 parent f000907 commit 5e6a14d
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 161 deletions.
25 changes: 24 additions & 1 deletion webapp/eePlugin/eePlugin.ee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ import { GlobalLimitPopover } from '../src/ee/billing/limitPopover/GlobalLimitPo
import { addDeveloperViewItems } from '../src/views/projects/developer/developerViewItems';
import { StorageList } from '../src/ee/developer/storage/StorageList';
import { WebhookList } from '../src/ee/developer/webhook/WebhookList';
import { addUserMenuItems } from '../src/hooks/useUserMenuItems';
import { Badge, Box, MenuItem } from '@mui/material';
import { addUserMenuItems } from '../src/component/security/UserMenu/UserMenuItems';
import { addProjectMenuItems } from '../src/views/projects/projectMenu/ProjectMenu';

export const eePlugin: EePluginType = {
ee: {
Expand Down Expand Up @@ -271,6 +272,28 @@ export const eePlugin: EePluginType = {
{ position: 'start' }
);
},
useAddProjectMenuItems: () => {
const { t } = useTranslate();

return addProjectMenuItems(
[
{
id: 'tasks',
condition: ({ satisfiesPermission }) =>
satisfiesPermission('tasks.view'),
link: LINKS.PROJECT_TASKS,
icon: ClipboardCheck,
text: t('project_menu_tasks'),
dataCy: 'project-menu-item-tasks',
matchAsPrefix: true,
},
],
{
position: 'after',
value: 'translations',
}
);
},
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslate } from '@tolgee/react';
import { Link, useLocation } from 'react-router-dom';

import { LINKS } from '../constants/links';
import { LINKS } from 'tg.constants/links';
import {
useConfig,
useIsEmailVerified,
Expand All @@ -10,7 +10,7 @@ import {
import { MenuItem } from '@mui/material';
import React, { FC } from 'react';
import { createAdder } from 'tg.fixtures/pluginAdder';
import { getEe } from '../plugin/getEe';
import { getEe } from '../../../plugin/getEe';

export const UserMenuItems: FC<{ onClose: () => void }> = ({ onClose }) => {
const location = useLocation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from 'react';
import { IconButton, Popover, styled } from '@mui/material';

import { UserMenuItems } from 'tg.hooks/useUserMenuItems';
import { UserAvatar } from 'tg.component/common/avatar/UserAvatar';

import { ThemeItem } from './ThemeItem';
import { LanguageItem } from './LanguageItem';
import { UserMenuItems } from './UserMenuItems';

const StyledIconButton = styled(IconButton)`
width: 40px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { T, useTranslate } from '@tolgee/react';
import { Link, useHistory, useLocation } from 'react-router-dom';

import { usePreferredOrganization, useUser } from 'tg.globalContext/helpers';
import { UserMenuItems } from 'tg.hooks/useUserMenuItems';
import { UserAvatar } from 'tg.component/common/avatar/UserAvatar';
import { LINKS, PARAMS } from 'tg.constants/links';
import { components } from 'tg.service/apiSchema.generated';
Expand All @@ -15,6 +14,7 @@ import { ThemeItem } from './ThemeItem';
import { LanguageItem } from './LanguageItem';
import { useGlobalActions } from 'tg.globalContext/GlobalContext';
import { getEe } from '../../../plugin/getEe';
import { UserMenuItems } from './UserMenuItems';

type OrganizationModel = components['schemas']['OrganizationModel'];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useState } from 'react';
import { IconButton, MenuItem, Popover, styled } from '@mui/material';

import { UserMenuItems } from 'tg.hooks/useUserMenuItems';
import { UserAvatar } from 'tg.component/common/avatar/UserAvatar';

import { ThemeItem } from './ThemeItem';
import { LanguageItem } from './LanguageItem';
import { T } from '@tolgee/react';
import { useGlobalActions } from 'tg.globalContext/GlobalContext';
import { UserMenuItems } from './UserMenuItems';

const StyledIconButton = styled(IconButton)`
width: 40px;
Expand Down
4 changes: 3 additions & 1 deletion webapp/src/plugin/EePluginType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { components } from 'tg.service/apiSchema.generated';
import { BatchOperationAdder } from 'tg.views/projects/translations/BatchOperations/operations';
import { addPanel } from 'tg.views/projects/translations/ToolsPanel/panelsList';
import { DeveloperViewItemsAdder } from 'tg.views/projects/developer/developerViewItems';
import { UserMenuItemsAdder } from 'tg.hooks/useUserMenuItems';
import { UserMenuItemsAdder } from 'tg.component/security/UserMenu/UserMenuItems';
import { ProjectMenuItemsAdder } from 'tg.views/projects/projectMenu/ProjectMenu';

export interface EePluginType {
ee?: {
Expand Down Expand Up @@ -40,6 +41,7 @@ export interface EePluginType {
translationPanelAdder: ReturnType<typeof addPanel>;
useAddDeveloperViewItems: () => DeveloperViewItemsAdder;
useAddUserMenuItems: () => UserMenuItemsAdder;
useAddProjectMenuItems: () => ProjectMenuItemsAdder;
};
}

Expand Down
Loading

0 comments on commit 5e6a14d

Please sign in to comment.