Skip to content

Commit

Permalink
Merge branch 'main' of github.com:percona/grafana into PMM-12476-clus…
Browse files Browse the repository at this point in the history
…ter-view-search
  • Loading branch information
matejkubinec committed Nov 27, 2023
2 parents 75d98c9 + 34b70c3 commit e376f1e
Show file tree
Hide file tree
Showing 30 changed files with 1,591 additions and 16 deletions.
127 changes: 119 additions & 8 deletions .betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -5742,6 +5742,124 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"]
],
"public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/app/percona/backup/components/BackupInventory/RestoreBackupModal/RestoreBackupModal.service.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/check/components/AllChecksTab/ChangeCheckIntervalModal/ChangeCheckIntervalModal.constants.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/check/components/AllChecksTab/CheckActions/CheckActions.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/percona/dbaas/components/DBCluster/DBCluster.service.utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/percona/dbaas/components/DBCluster/DBClusterLogsModal/DBClusterLogsModal.utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/hooks/useEditDBClusterFormSubmit.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/percona/dbaas/components/DBCluster/ResourcesBar/ResourcesBar.utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/dbaas/components/Kubernetes/ColumnRenderers/ColumnRenderers.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/dbaas/components/Kubernetes/ManageComponentsVersionsModal/ManageComponentsVersions.utils.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/percona/inventory/Tabs/Services/ClusterItem.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/inventory/Tabs/Services/Clusters.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/inventory/Tabs/Services/Clusters.utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/pmm-dump/PMMDump.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/percona/pmm-dump/SendToSupportModal.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/settings/components/Advanced/Advanced.utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/percona/settings/components/Communication/Email/Email.utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/percona/shared/components/Elements/ExpandableCell/ExpandableCell.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/percona/shared/components/Form/FieldAdapters/Field.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/percona/shared/components/Form/FieldAdapters/FieldAdapters.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/shared/components/Form/FormElement/FormElement.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/shared/components/Form/MultiCheckbox/MultiCheckboxField.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/shared/core/reducers/dbaas/addDBCluster/addDBCluster.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/shared/helpers/cron/cron.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/percona/shared/helpers/promises.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/percona/shared/helpers/promises.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/percona/shared/helpers/testUtils.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/percona/shared/helpers/validator.types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/percona/shared/helpers/validators.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/alertmanager/DataSource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
Expand Down Expand Up @@ -6767,11 +6885,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/mssql/response_parser.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/mysql/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
Expand Down Expand Up @@ -7026,9 +7139,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
],
"public/app/plugins/datasource/postgres/module.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Attaching artifacts
if: ${{ always() }}
uses: percona-platform/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ui-tests-output
path: ./pmm-ui-tests/tests/output
1 change: 1 addition & 0 deletions packages/grafana-data/src/types/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const availableIconsIndex = {
github: true,
gitlab: true,
okta: true,
brain: true,
anchor: true,
'angle-double-down': true,
'angle-double-right': true,
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-ui/src/components/Icon/cached.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"unicons/book",
"unicons/book-open",
"unicons/brackets-curly",
"unicons/brain",
"unicons/bug",
"unicons/building",
"unicons/calculator-alt",
Expand Down
7 changes: 7 additions & 0 deletions public/app/core/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export interface FooterLink {

export let getFooterLinks = (): FooterLink[] => {
return [
{
id: 'pmm-dump',
text: 'PMM Dump',
icon: 'brain',
url: '/graph/pmm-dump',
target: '_self',
},
{
id: 'pmm-logs',
text: 'PMM Logs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
const validators = [platformCoreValidators.containsNumber, ...platformCoreValidators.int32];

const getAutoDiscoveryLimitValue = (type: AutoDiscoveryOptionsInterface) =>
type === AutoDiscoveryOptionsInterface.enabled ? 0 : type === AutoDiscoveryOptionsInterface.disabled ? -1 : 10;
type === AutoDiscoveryOptionsInterface.disabled ? -1 : 10;

useEffect(() => {
setSelectedValue(selectedOption);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useCallback, useEffect, useState } from 'react';
import React, { FC, useCallback, useEffect, useState, useRef } from 'react';

import { ClipboardButton, useStyles } from '@grafana/ui';
import { useCancelToken } from 'app/percona/shared/components/hooks/cancelToken.hook';
Expand All @@ -19,6 +19,10 @@ export const ChunkedLogsViewer: FC<ChunkedLogsViewerProps> = ({ getLogChunks })
const [triggerTimeout, , stopTimeout] = useRecurringCall();
const [generateToken] = useCancelToken();
const styles = useStyles(getStyles);
const logsRef = useRef(logs);
logsRef.current = logs;
const lastLogRef = useRef(lastLog);
lastLogRef.current = lastLog;

const formatLogs = useCallback(
() => logs.map((log) => log.data).reduce((acc, message) => `${acc}${acc.length ? '\n' : ''}${message}`, ''),
Expand All @@ -27,13 +31,15 @@ export const ChunkedLogsViewer: FC<ChunkedLogsViewerProps> = ({ getLogChunks })

const refreshCurrentLogs = async () => {
try {
const { logs: newLogs = [], end } = await getLogChunks(logs[0]?.id || 0, LIMIT, generateToken(LOGS_CANCEL_TOKEN));

if (end && !lastLog) {
const { logs: newLogs = [], end } = await getLogChunks(
logsRef.current[logsRef.current.length - 1]?.id || 0,
LIMIT,
generateToken(LOGS_CANCEL_TOKEN)
);
if (end && lastLogRef.current) {
stopTimeout();
}

setLogs(newLogs);
setLogs([...logsRef.current, ...newLogs]);
setLastLog(!!end);
} catch (e) {
if (isApiCancelError(e)) {
Expand All @@ -48,6 +54,11 @@ export const ChunkedLogsViewer: FC<ChunkedLogsViewerProps> = ({ getLogChunks })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
return stopTimeout();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [lastLog]);

return (
<>
<ClipboardButton variant="secondary" getText={formatLogs} className={styles.copyBtnHolder}>
Expand Down
37 changes: 37 additions & 0 deletions public/app/percona/pmm-dump/PMMDump.messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const Messages = {
dumps: {
columns: {
id: 'Id',
status: 'Status',
created: 'Created',
startDate: 'Start Date',
endDate: 'End Date',
timeRange: 'Time Range',
startTime: 'Start Time',
endTime: 'End Time',
serviceNames: 'Service Names',
},
actions: {
download: 'Download',
sendToSupport: 'Send to Support',
delete: 'Delete',
viewLogs: 'View logs',
deleteDumpMessage: 'Are you sure you want to delete this PMM dump?',
deleteMultipleDumpsMessage: 'Are you sure you want to delete these PMM dumps?',
selectServices: 'Select multiple datasets to bulk edit them.',
addressRequired: 'Address is required.',
nameRequired: 'Name is required.',
passwordRequired: 'Password is required.',
directoryRequired: 'Directory is required.',
addressPlaceholder: 'sftp.percona.com',
savingButton: 'Saving...',
sendButton: 'Send',
cancelButton: 'Cancel',
},
emptyTable: 'No dumps available',
createDataset: 'Create dataset',
},
dumpLogs: {
getLogsTitle: (name: string) => `Logs for ${name}`,
},
};
71 changes: 71 additions & 0 deletions public/app/percona/pmm-dump/PMMDump.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { CancelToken } from 'axios';

import { PmmDump, ExportDatasetProps } from 'app/percona/shared/core/reducers/pmmDump/pmmDump.types';
import { api } from 'app/percona/shared/helpers/api';

import {
DumpLogs,
DumpLogResponse,
SendToSupportRequestBody,
DeleteDump,
PmmDumpResponse,
ExportResponse,
} from './PmmDump.types';

const BASE_URL = '/v1/management/dump/Dumps';
const link = document.createElement('a');

const delay = (ms: number): Promise<void> => {
return new Promise((resolve) => setTimeout(resolve, ms));
};

export const PMMDumpService = {
async getLogs(artifactId: string, offset: number, limit: number, token?: CancelToken): Promise<DumpLogs> {
const { logs = [], end } = await api.post<DumpLogResponse, Object>(
`${BASE_URL}/GetLogs`,
{
dump_id: artifactId,
offset,
limit,
},
false,
token
);
return {
logs: logs.map(({ chunk_id = 0, data, time }) => ({ id: chunk_id, data, time })),
end,
};
},
async list(): Promise<PmmDump[]> {
const response = await api.post<PmmDumpResponse, void>(`${BASE_URL}/List`, undefined);
return response.dumps || [];
},
async delete(dumpIds: string[]) {
await api.post<void, DeleteDump>(`${BASE_URL}/Delete`, { dump_ids: dumpIds });
},
async downloadAll(dumpIds: string[], index = 0): Promise<void> {
for (let i = index; i < dumpIds.length; i++) {
await this.download(dumpIds, i);
}
},
async download(dumpIds: string[], index: number): Promise<void> {
return new Promise<void>(async (resolve) => {
const dumpId = dumpIds[index];

link.setAttribute('href', `${window.location.origin}/dump/${dumpId}.tar.gz`);
link.setAttribute('download', `${dumpId}.tar.gz`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
await delay(900);
resolve();
});
},
async sendToSupport(body: SendToSupportRequestBody) {
await api.post<void, DeleteDump>(`${BASE_URL}/Upload`, body, true);
},
async trigger(body: ExportDatasetProps, token?: CancelToken): Promise<string> {
const res = await api.post<ExportResponse, ExportDatasetProps>(`${BASE_URL}/Start`, body, false, token);
return res.dump_id;
},
};
Loading

0 comments on commit e376f1e

Please sign in to comment.