-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PMM-11231 Setup PMM UI * PMM-11231 Update working directory for node setup * PMM-11231 Adjust setup node step * PMM-11231 Add build & cleanup makefile * PMM-11231 Use correct UI directory * PMM-11231 Adjust pmm-ui build directory * PMM-11231 Add install commands * PMM-11231 Add pmm ui directory to files section * PMM-11231 Copy correct build files * PMM-11231 Handle token rotation * PMM-11231 Simplify spec file * PMM-11231 Update dependencies * PMM-11231 Allow use of eslints non flat config * PMM-11231 Align version fetch logic with previous * PMM-11231 Refactor fetching icon * PMM-11231 Update compose file * PMM-11231 Use /pmm-ui as path * PMM-11231 Allow specifying pmm server image through env variable * PMM-12930 Show update status * PMM-11231 Switch to tanstack query * PMM-12930 Fix lint * PMM-11231 Update dev configuration * PMM-11231 Use correct naming & switch to hooks * PMM-11231 Use different name for update image * PMM-12930 Improve update process * PMM-11231 Disable auth_request for pmm-ui * PMM-11231 Rework redirect to login * PMM-11231 Update api response * PMM-11231 Add link to support * PMM-11231 Fix support url redirect * PMM-11231 Fix lint * PMM-11231 Fix typings * PMM-12930 Fix version typings * PMM-11231 Add admin & auth check * PMM-12930 Make page component responsive * PMM-12930 Add Page unit tests * PMM-12930 Make page component responsive * PMM-12930 Add Page unit tests * PMM-11231 Update api endpoints * PMM-12930 Add upgrade docs link * PMM-12930 Update types & readyz url * PMM-12930 Remove temporary error handling * PMM-12930 Add footer * PMM-12930 Refactor footer * PMM-12930 Refactor user context imports * PMM-12930 Add doc comnent * PMM-12930 Update progress bar color * PMM-12930 Update progress bar * PMM-12930 Bump packages * PMM-12930 Fix updates check * PMM-12934 Add page for client updates * PMM-12934 Extend page & remove mocks * PMM-12934 Update table loading * PMM-12934 Use custom filter component * PMM-12933 Add update log modal * PMM-12934 Add next button * PMM-12930 Add unit tests * PMM-12930 Downgrade eslint version * PMM-12934 Add check for pending client update * PMM-12934 Adjust styling * PMM-12930 Fix before CR * PMM-12930 Remove empty file * PMM-12930 Simplify initial auth check * PMM-12930 Make appbar sticky * PMM-12930 Fix font loading * PMM-12930 Adjust section spacing * PMM-12930 Bump axios version * PMM-7 fix proto validation error * PMM-12930 Use table from ui-lib * PMM-12930 Update dev nginx file * PMM-12930 Use shortened links * PMM-12930 Add pmm home button, rework dialog & add test * PMM-12930 Improve clients update check * PMM-12930 Highligh only Release Notes
- Loading branch information
1 parent
6a67936
commit 8fe0d76
Showing
88 changed files
with
2,534 additions
and
966 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
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,10 @@ | ||
import { AgentUpdateSeverity, GetAgentVersionItem } from 'types/agent.types'; | ||
|
||
export const getAgentVersions = async (): Promise<GetAgentVersionItem[]> => [ | ||
{ | ||
agentId: 'pmm-server', | ||
version: '3.0.0', | ||
nodeName: 'pmm-server', | ||
severity: AgentUpdateSeverity.UP_TO_DATE, | ||
}, | ||
]; |
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,9 @@ | ||
import { GetAgentVersionsResponse } from 'types/agent.types'; | ||
import { api } from './api'; | ||
|
||
export const getAgentVersions = async () => { | ||
const res = await api.get<GetAgentVersionsResponse>( | ||
'/management/agents/versions' | ||
); | ||
return res.data.agentVersions; | ||
}; |
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,6 @@ | ||
import { api } from './api'; | ||
|
||
export const getReadiness = async () => { | ||
const res = await api.get<Record<string, never>>('/server/readyz'); | ||
return res.data; | ||
}; |
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
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,5 @@ | ||
export const Messages = { | ||
version: (version: string) => `PMM ${version}`, | ||
inProgress: 'Update in progress...', | ||
checkedOn: (date: string) => `Checked on: ${date}`, | ||
}; |
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,32 @@ | ||
import { screen, render } from '@testing-library/react'; | ||
import { Footer } from './Footer'; | ||
import { Messages } from './Footer.messages'; | ||
import { wrapWithUpdatesProvider } from 'utils/testUtils'; | ||
|
||
describe('Footer', () => { | ||
it("doesnt't show when version info is not available", () => { | ||
render( | ||
wrapWithUpdatesProvider(<Footer />, { | ||
versionInfo: undefined, | ||
}) | ||
); | ||
|
||
expect(screen.queryByTestId('pmm-footer')).toBeNull(); | ||
}); | ||
|
||
it('shows correct checked date', () => { | ||
render(wrapWithUpdatesProvider(<Footer />)); | ||
|
||
expect('Checked on: 2024/07/30'); | ||
}); | ||
|
||
it('shows in progress message', () => { | ||
render( | ||
wrapWithUpdatesProvider(<Footer />, { | ||
inProgress: true, | ||
}) | ||
); | ||
|
||
expect(screen.getByText(Messages.inProgress)); | ||
}); | ||
}); |
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,24 @@ | ||
import { Stack, Typography } from '@mui/material'; | ||
import { useUpdates } from 'contexts/updates'; | ||
import { FC } from 'react'; | ||
import { formatCheckDate } from './Footer.utils'; | ||
import { Messages } from './Footer.messages'; | ||
|
||
export const Footer: FC = () => { | ||
const { inProgress, versionInfo } = useUpdates(); | ||
|
||
if (!versionInfo) return null; | ||
|
||
return ( | ||
<Stack direction="row" gap={2} data-testid="pmm-footer"> | ||
<Typography variant="body2"> | ||
{Messages.version(versionInfo.installed.version)} | ||
</Typography> | ||
<Typography variant="body2" color="text.disabled"> | ||
{inProgress | ||
? Messages.inProgress | ||
: Messages.checkedOn(formatCheckDate(versionInfo.lastCheck))} | ||
</Typography> | ||
</Stack> | ||
); | ||
}; |
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,7 @@ | ||
/** | ||
* Formats date to YYYY/MM/DD | ||
* @param date | ||
* @returns formatted date | ||
*/ | ||
export const formatCheckDate = (date: string) => | ||
new Date(date).toISOString().slice(0, 10).replace(/-/g, '/'); |
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 @@ | ||
export * from './Footer'; |
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,66 @@ | ||
import { wrapWithUpdatesProvider } from 'utils/testUtils'; | ||
import { HomeLink } from './HomeLink'; | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { UpdateStatus } from 'types/updates.types'; | ||
import { PMM_HOME_URL } from 'constants'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
describe('HomeLink', () => { | ||
it('navigates to PMM Home if client update is not pending', () => { | ||
render( | ||
wrapWithUpdatesProvider( | ||
<MemoryRouter initialEntries={[{ pathname: '/updates/clients' }]}> | ||
<HomeLink data-testid="home-link" /> | ||
</MemoryRouter>, | ||
{ | ||
status: UpdateStatus.UpToDate, | ||
} | ||
) | ||
); | ||
|
||
expect(screen.getByTestId('home-link')).toHaveAttribute( | ||
'href', | ||
PMM_HOME_URL | ||
); | ||
}); | ||
|
||
it('shows modal if client update is pending', () => { | ||
render( | ||
wrapWithUpdatesProvider( | ||
<MemoryRouter initialEntries={[{ pathname: '/updates/clients' }]}> | ||
<HomeLink data-testid="home-link" /> | ||
</MemoryRouter>, | ||
{ | ||
status: UpdateStatus.UpdateClients, | ||
areClientsUpToDate: false, | ||
} | ||
) | ||
); | ||
const homeLink = screen.getByTestId('home-link'); | ||
|
||
expect(homeLink).not.toHaveAttribute('href', PMM_HOME_URL); | ||
|
||
fireEvent.click(homeLink); | ||
|
||
expect(screen.getByTestId('modal-clients-update-pending')).toBeDefined(); | ||
}); | ||
|
||
it("doesn't propmt on pages other than client updates", () => { | ||
render( | ||
wrapWithUpdatesProvider( | ||
<MemoryRouter initialEntries={[{ pathname: '/updates' }]}> | ||
<HomeLink data-testid="home-link" /> | ||
</MemoryRouter>, | ||
{ | ||
status: UpdateStatus.UpdateClients, | ||
areClientsUpToDate: false, | ||
} | ||
) | ||
); | ||
|
||
expect(screen.getByTestId('home-link')).toHaveAttribute( | ||
'href', | ||
PMM_HOME_URL | ||
); | ||
}); | ||
}); |
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,39 @@ | ||
import { Link, LinkProps } from '@mui/material'; | ||
import { PMM_HOME_URL } from 'constants'; | ||
import { useUpdates } from 'contexts/updates'; | ||
import { FC, useMemo, useState } from 'react'; | ||
import { UpdateStatus } from 'types/updates.types'; | ||
import { ClientsModal } from './clients-modal'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
export const HomeLink: FC<LinkProps> = ({ children, sx, ...props }) => { | ||
const { status, areClientsUpToDate } = useUpdates(); | ||
const [modalOpen, setModalOpen] = useState(false); | ||
const location = useLocation(); | ||
const isOnClientsPage = useMemo( | ||
() => location.pathname.startsWith('/updates/clients'), | ||
[location] | ||
); | ||
const homeLinkProps = | ||
(status === UpdateStatus.UpdateClients || !areClientsUpToDate) && | ||
isOnClientsPage | ||
? { | ||
onClick: () => setModalOpen(true), | ||
} | ||
: { | ||
href: PMM_HOME_URL, | ||
}; | ||
|
||
return ( | ||
<> | ||
<ClientsModal isOpen={modalOpen} onClose={() => setModalOpen(false)} /> | ||
<Link | ||
{...props} | ||
sx={[{ cursor: 'pointer ' }, ...(Array.isArray(sx) ? sx : [sx])]} | ||
{...homeLinkProps} | ||
> | ||
{children} | ||
</Link> | ||
</> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
ui/src/components/home-link/clients-modal/ClientsModal.messages.ts
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,9 @@ | ||
export const Messages = { | ||
title: 'PMM has not finished updating', | ||
description1: | ||
'One or more PMM Client instances are not updated yet and will remain in an outdated version.', | ||
description2: | ||
'If you exit now you will not take advatages of the newest fixes, improvements and features.', | ||
close: 'Close window', | ||
home: 'Go to PMM Home', | ||
}; |
Oops, something went wrong.