-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web.office): add licences datagrid
ref: MANAGER-16124 Signed-off-by: Guillaume Hyenne <[email protected]>
- Loading branch information
Showing
32 changed files
with
662 additions
and
98 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
4 changes: 2 additions & 2 deletions
4
packages/manager/apps/web-office/public/translations/dashboard/Messages_fr_FR.json
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"title": "Dashboard page", | ||
"error_service": "No services info", | ||
"general_informations": "Informations générales", | ||
"tab2": "Tab 2", | ||
"microsoft_office_dashboard_consumption": "Consommation", | ||
"microsoft_office_dashboard_licences": "Licences", | ||
"back_link": "Retour à la liste" | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/manager/apps/web-office/public/translations/dashboard/users/Messages_fr_FR.json
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,18 @@ | ||
{ | ||
"dashboard_users_table_firstName": "Prénom", | ||
"dashboard_users_table_lastName": " Nom", | ||
"dashboard_users_table_activationEmail": "Email d'activation", | ||
"dashboard_users_table_licences": "Licences", | ||
"dashboard_users_table_status": "Statut", | ||
"dashboard_users_download_text": "Les programmes d'installation pour PC et MAC sont disponibles sur le site de microsoft <officeLink/>.", | ||
"dashboard_users_download_info": "Pour smartphones et tablettes, rendez-vous directement dans votre App Store.", | ||
"dashboard_users_download_id": "Les identifiants de connexion et d'installation vous sont transmis par email lorsque vous ajoutez une nouvelle licence.", | ||
"dashboard_users_status_creating": "En création", | ||
"dashboard_users_status_updating": "Mise à jour", | ||
"dashboard_users_status_deleting": "En suppression", | ||
"dashboard_users_status_ok": "Créé", | ||
"dashboard_users_status_unconfigured": "Non configuré", | ||
"dashboard_users_action_user_change_password": "Changer le mot de passe", | ||
"dashboard_users_action_user_edit": "Editer le compte", | ||
"dashboard_users_action_user_delete": "Supprimer le compte" | ||
} |
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,14 @@ | ||
export enum UserStateEnum { | ||
CREATING = 'creating', | ||
DELETING = 'deleting', | ||
OK = 'ok', | ||
UNCONFIGURED = 'unconfigured', | ||
SUSPENDED = 'suspended', | ||
SUSPENDING = 'suspending', | ||
UNSUSPENDING = 'unsuspending', | ||
} | ||
|
||
export enum LicenseEnum { | ||
OFFICE_BUSINESS = 'officeBusiness', | ||
OFFICE_PRO_PLUS = 'officeProPlus', | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { getApiPath } from '../utils/apiPath'; | ||
|
||
export const getOfficeLicenseDetailsQueryKey = (serviceName: string) => [ | ||
`get/license/office/${serviceName}`, | ||
`get/${getApiPath(serviceName)}${serviceName}`, | ||
]; | ||
|
||
export const getOfficeLicenseQueryKey = () => [`get/license/office`]; | ||
export const getOfficeLicenseQueryKey = (serviceName: string) => [ | ||
`get/${getApiPath(serviceName)}`, | ||
]; |
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,21 @@ | ||
import { fetchIcebergV6 } from '@ovh-ux/manager-core-api'; | ||
import { getApiPath } from '../utils/apiPath'; | ||
import { UserNativeType } from './type'; | ||
|
||
// GET | ||
|
||
export const getOfficeUsers = async ( | ||
serviceName: string, | ||
): Promise<UserNativeType[]> => { | ||
const { data } = await fetchIcebergV6<UserNativeType>({ | ||
route: `${getApiPath(serviceName)}user`, | ||
disableCache: true, | ||
}); | ||
return data; | ||
}; | ||
|
||
// POST | ||
|
||
// PUT | ||
|
||
// DELETE |
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,3 @@ | ||
export const getOfficeUsersQueryKey = (serviceName: string) => [ | ||
`get/license/office/${serviceName}/user`, | ||
]; |
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,14 @@ | ||
import { LicenseEnum, UserStateEnum } from '../api.type'; | ||
|
||
export type UserNativeType = { | ||
activationEmail: string; | ||
deleteAtExpiration: boolean; | ||
firstName: string; | ||
isVirtual: boolean; | ||
lastName: string; | ||
licences: LicenseEnum; | ||
status: UserStateEnum; | ||
taskPendingId: number; | ||
usageLocation: string; | ||
[key: string]: string | number | boolean | { id: string; urn: string }; | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,15 @@ | ||
export const getApiPath = (serviceName: string) => | ||
`/license/office/${serviceName}/`; | ||
import { useOfficeServiceType } from '@/hooks'; | ||
|
||
export const getApiPath = (serviceName: string) => { | ||
const serviceType = useOfficeServiceType(serviceName); | ||
return `/license/${ | ||
serviceType === 'payAsYouGo' ? 'office' : 'officePrepaid' | ||
}/${serviceName}/`; | ||
}; | ||
|
||
export const getApiPathWithoutServiceName = (serviceName: string) => { | ||
const serviceType = useOfficeServiceType(serviceName); | ||
return `/license/${ | ||
serviceType === 'payAsYouGo' ? 'office' : 'officePrepaid' | ||
}/`; | ||
}; |
36 changes: 36 additions & 0 deletions
36
packages/manager/apps/web-office/src/components/BadgeStatus.tsx
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,36 @@ | ||
import React, { useMemo } from 'react'; | ||
import { OdsBadge } from '@ovhcloud/ods-components/react'; | ||
import { ODS_BADGE_COLOR } from '@ovhcloud/ods-components'; | ||
import { UserStateEnum } from '@/api/api.type'; | ||
|
||
export type BadgeStatusProps = { | ||
itemStatus: string; | ||
t: any; | ||
translationPrefixKey: string; | ||
'data-testid'?: string; | ||
}; | ||
|
||
const getStatusColor = (status: string) => { | ||
switch (status) { | ||
case UserStateEnum.OK: | ||
return ODS_BADGE_COLOR.success; | ||
case UserStateEnum.DELETING: | ||
return ODS_BADGE_COLOR.critical; | ||
default: | ||
return ODS_BADGE_COLOR.information; | ||
} | ||
}; | ||
|
||
export const BadgeStatus: React.FC<BadgeStatusProps> = (props) => { | ||
const statusColor = useMemo(() => getStatusColor(props.itemStatus), [ | ||
props.itemStatus, | ||
]); | ||
|
||
return ( | ||
<OdsBadge | ||
data-testid={props['data-testid']} | ||
color={statusColor} | ||
label={props.t(`${props.translationPrefixKey}${props.itemStatus}`)} | ||
/> | ||
); | ||
}; |
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
62 changes: 62 additions & 0 deletions
62
packages/manager/apps/web-office/src/components/layout-helpers/Dashboard/TabsPanel.tsx
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 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { NavLink, useLocation, useNavigate } from 'react-router-dom'; | ||
import { OdsTabs, OdsTab } from '@ovhcloud/ods-components/react'; | ||
|
||
export type TabItemProps = { | ||
name: string; | ||
title: string; | ||
pathMatchers?: RegExp[]; | ||
to: string; | ||
}; | ||
|
||
export type TabsProps = { | ||
tabs: TabItemProps[]; | ||
}; | ||
|
||
const TabsPanel: React.FC<TabsProps> = ({ tabs }) => { | ||
const [activePanel, setActivePanel] = useState(''); | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
if (!location.pathname) { | ||
setActivePanel(tabs[0].name); | ||
navigate(tabs[0].to); | ||
} else { | ||
const activeTab = tabs | ||
.filter( | ||
(tab) => | ||
tab.to === location.pathname || | ||
tab.pathMatchers?.some((pathMatcher) => | ||
pathMatcher.test(location.pathname), | ||
), | ||
) | ||
.pop(); | ||
if (activeTab) { | ||
setActivePanel(activeTab.name); | ||
} | ||
} | ||
}, [location.pathname]); | ||
|
||
return ( | ||
<OdsTabs> | ||
{tabs.map((tab: TabItemProps) => ( | ||
<NavLink | ||
key={`osds-tab-bar-item-${tab.name}`} | ||
to={tab.to} | ||
className="no-underline" | ||
> | ||
<OdsTab | ||
id={tab.name} | ||
role="tab" | ||
isSelected={activePanel === tab.name} | ||
> | ||
{tab.title} | ||
</OdsTab> | ||
</NavLink> | ||
))} | ||
</OdsTabs> | ||
); | ||
}; | ||
|
||
export default TabsPanel; |
Oops, something went wrong.