Skip to content

Commit

Permalink
chore(mbeans): adjust MBeanMetrics GraphQL query for updated schema (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Mar 1, 2024
1 parent 947a706 commit a2a8815
Show file tree
Hide file tree
Showing 62 changed files with 541 additions and 321 deletions.
10 changes: 10 additions & 0 deletions src/app/Archives/AllTargetsArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export const AllTargetsArchivedRecordingsTable: React.FC<AllTargetsArchivedRecor
const target: Target = {
connectUrl: node.target.serviceUri,
alias: node.target.alias,
labels: [],
annotations: {
cryostat: [],
platform: [],
},
};
return {
target,
Expand Down Expand Up @@ -215,6 +220,11 @@ export const AllTargetsArchivedRecordingsTable: React.FC<AllTargetsArchivedRecor
const target: Target = {
connectUrl: evt.serviceRef.connectUrl,
alias: evt.serviceRef.alias,
labels: [],
annotations: {
cryostat: [],
platform: [],
},
};
if (evt.kind === 'FOUND') {
getCountForNewTarget(target);
Expand Down
6 changes: 3 additions & 3 deletions src/app/Archives/ArchiveUploadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/
import { RecordingLabelFields } from '@app/RecordingMetadata/RecordingLabelFields';
import { RecordingLabel } from '@app/RecordingMetadata/types';
import { FUpload, MultiFileUpload, UploadCallbacks } from '@app/Shared/Components/FileUploads';
import { LoadingProps } from '@app/Shared/Components/types';
import { KeyValue } from '@app/Shared/Services/api.types';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { portalRoot } from '@app/utils/utils';
Expand Down Expand Up @@ -51,7 +51,7 @@ export const ArchiveUploadModal: React.FC<ArchiveUploadModalProps> = ({ onClose,
const [uploading, setUploading] = React.useState(false);
const [numOfFiles, setNumOfFiles] = React.useState(0);
const [allOks, setAllOks] = React.useState(false);
const [labels, setLabels] = React.useState([] as RecordingLabel[]);
const [labels, setLabels] = React.useState([] as KeyValue[]);
const [valid, setValid] = React.useState(ValidatedOptions.success);

const getFormattedLabels = React.useCallback(() => {
Expand All @@ -66,7 +66,7 @@ export const ArchiveUploadModal: React.FC<ArchiveUploadModalProps> = ({ onClose,

const reset = React.useCallback(() => {
setUploading(false);
setLabels([] as RecordingLabel[]);
setLabels([] as KeyValue[]);
setValid(ValidatedOptions.success);
setNumOfFiles(0);
}, [setUploading, setLabels, setValid, setNumOfFiles]);
Expand Down
5 changes: 5 additions & 0 deletions src/app/Archives/Archives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import { AllTargetsArchivedRecordingsTable } from './AllTargetsArchivedRecording
export const uploadAsTarget: Target = {
connectUrl: UPLOADS_SUBDIRECTORY,
alias: '',
labels: [],
annotations: {
cryostat: [],
platform: [],
},
};

enum ArchiveTab {
Expand Down
5 changes: 5 additions & 0 deletions src/app/Archives/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ export const getTargetFromDirectory = (dir: RecordingDirectory): Target => {
return {
connectUrl: dir.connectUrl,
alias: dir.jvmId,
labels: [],
annotations: {
cryostat: [],
platform: [],
},
};
};
27 changes: 10 additions & 17 deletions src/app/CreateRecording/CustomRecordingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ import { DurationPicker } from '@app/DurationPicker/DurationPicker';
import { ErrorView } from '@app/ErrorView/ErrorView';
import { authFailMessage, isAuthFail } from '@app/ErrorView/types';
import { RecordingLabelFields } from '@app/RecordingMetadata/RecordingLabelFields';
import { RecordingLabel } from '@app/RecordingMetadata/types';
import { SelectTemplateSelectorForm } from '@app/Shared/Components/SelectTemplateSelectorForm';
import { LoadingProps } from '@app/Shared/Components/types';
import { EventTemplate, RecordingAttributes, AdvancedRecordingOptions, Target } from '@app/Shared/Services/api.types';
import {
EventTemplate,
RecordingAttributes,
AdvancedRecordingOptions,
Target,
KeyValue,
} from '@app/Shared/Services/api.types';
import { isTargetAgentHttp } from '@app/Shared/Services/api.utils';
import { NotificationsContext } from '@app/Shared/Services/Notifications.service';
import { ServiceContext } from '@app/Shared/Services/Services';
Expand Down Expand Up @@ -150,18 +155,6 @@ export const CustomRecordingForm: React.FC = () => {
return str;
}, [formData]);

const getFormattedLabels = React.useCallback(() => {
const obj = {};

formData.labels.forEach((l) => {
if (l.key && l.value) {
obj[l.key] = l.value;
}
});

return obj;
}, [formData]);

const handleRecordingNameChange = React.useCallback(
(name: string) =>
setFormData((old) => ({
Expand Down Expand Up @@ -198,7 +191,7 @@ export const CustomRecordingForm: React.FC = () => {
);

const handleLabelsChange = React.useCallback(
(labels: RecordingLabel[]) => {
(labels: KeyValue[]) => {
setFormData((old) => ({ ...old, labels }));
},
[setFormData],
Expand Down Expand Up @@ -266,10 +259,10 @@ export const CustomRecordingForm: React.FC = () => {
maxAge: toDisk ? (continuous ? maxAge * maxAgeUnit : undefined) : undefined,
maxSize: toDisk ? maxSize * maxSizeUnit : undefined,
},
metadata: { labels: getFormattedLabels() },
metadata: { labels: formData.labels },
};
handleCreateRecording(recordingAttributes);
}, [eventSpecifierString, getFormattedLabels, formData, notifications, handleCreateRecording]);
}, [eventSpecifierString, formData, notifications, handleCreateRecording]);

const refreshFormOptions = React.useCallback(
(target: Target) => {
Expand Down
5 changes: 2 additions & 3 deletions src/app/CreateRecording/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RecordingLabel } from '@app/RecordingMetadata/types';
import { EventTemplate } from '@app/Shared/Services/api.types';
import { EventTemplate, KeyValue } from '@app/Shared/Services/api.types';
import { ValidatedOptions } from '@patternfly/react-core';

export type EventTemplateIdentifier = Pick<EventTemplate, 'name' | 'type'>;

interface _FormBaseData {
name: string;
template?: EventTemplateIdentifier;
labels: RecordingLabel[];
labels: KeyValue[];
continuous: boolean;
archiveOnStop: boolean;
restart: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export class MBeanMetricsChartController {
l += '}';
q.push(l);
});
if (q.length === 0) {
return of({});
}
return this._api.getTargetMBeanMetrics(target, q);
}
}
2 changes: 1 addition & 1 deletion src/app/Dashboard/JvmDetails/JvmDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const JvmDetailsCard: DashboardCardFC<JvmDetailsCardProps> = (props) => {
name: target.alias,
target,
nodeType: NodeType.JVM,
labels: {},
labels: [],
}),
};
}, [target]);
Expand Down
16 changes: 8 additions & 8 deletions src/app/RecordingMetadata/BulkEditLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
UPLOADS_SUBDIRECTORY,
NotificationCategory,
Target,
KeyValue,
} from '@app/Shared/Services/api.types';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
Expand All @@ -33,8 +34,7 @@ import { HelpIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { combineLatest, concatMap, filter, first, forkJoin, map, Observable, of } from 'rxjs';
import { RecordingLabelFields } from './RecordingLabelFields';
import { RecordingLabel } from './types';
import { includesLabel, parseLabels } from './utils';
import { includesLabel } from './utils';

export interface BulkEditLabelsProps {
isTargetRecording: boolean;
Expand All @@ -54,8 +54,8 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
const context = React.useContext(ServiceContext);
const [recordings, setRecordings] = React.useState([] as Recording[]);
const [editing, setEditing] = React.useState(false);
const [commonLabels, setCommonLabels] = React.useState([] as RecordingLabel[]);
const [savedCommonLabels, setSavedCommonLabels] = React.useState([] as RecordingLabel[]);
const [commonLabels, setCommonLabels] = React.useState([] as KeyValue[]);
const [savedCommonLabels, setSavedCommonLabels] = React.useState([] as KeyValue[]);
const [valid, setValid] = React.useState(ValidatedOptions.default);
const [loading, setLoading] = React.useState(false);
const addSubscription = useSubscriptions();
Expand All @@ -78,7 +78,7 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
recordings.forEach((r: Recording) => {
const idx = getIdxFromRecording(r);
if (checkedIndices.includes(idx)) {
let updatedLabels = [...parseLabels(r.metadata.labels), ...commonLabels];
let updatedLabels = [...r.metadata.labels, ...commonLabels];
updatedLabels = updatedLabels.filter((label) => {
return !includesLabel(toDelete, label);
});
Expand Down Expand Up @@ -124,13 +124,13 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
}, [setEditing, setCommonLabels, savedCommonLabels]);

const updateCommonLabels = React.useCallback(
(setLabels: (l: RecordingLabel[]) => void) => {
const allRecordingLabels = [] as RecordingLabel[][];
(setLabels: (l: KeyValue[]) => void) => {
const allRecordingLabels = [] as KeyValue[][];

recordings.forEach((r: Recording) => {
const idx = getIdxFromRecording(r);
if (checkedIndices.includes(idx)) {
allRecordingLabels.push(parseLabels(r.metadata.labels));
allRecordingLabels.push(r.metadata.labels);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/app/RecordingMetadata/ClickableLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

import { KeyValue } from '@app/Shared/Services/api.types';
import { Label } from '@patternfly/react-core';
import * as React from 'react';
import { RecordingLabel } from './types';

export interface ClickableLabelCellProps {
label: RecordingLabel;
label: KeyValue;
isSelected: boolean;
onLabelClick: (label: RecordingLabel) => void;
onLabelClick: (label: KeyValue) => void;
}

export const ClickableLabel: React.FC<ClickableLabelCellProps> = ({ label, isSelected, onLabelClick }) => {
Expand Down
10 changes: 5 additions & 5 deletions src/app/RecordingMetadata/LabelCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*/

import { UpdateFilterOptions } from '@app/Shared/Redux/Filters/Common';
import { KeyValue } from '@app/Shared/Services/api.types';
import { Label, Text } from '@patternfly/react-core';
import * as React from 'react';
import { ClickableLabel } from './ClickableLabel';
import { RecordingLabel } from './types';
import { getLabelDisplay } from './utils';

export interface LabelCellProps {
target: string;
labels: RecordingLabel[];
labels: KeyValue[];
// If undefined, labels are not clickable (i.e. display only) and only displayed in grey.
clickableOptions?: {
labelFilters: string[];
Expand All @@ -33,7 +33,7 @@ export interface LabelCellProps {

export const LabelCell: React.FC<LabelCellProps> = ({ target, labels, clickableOptions }) => {
const isLabelSelected = React.useCallback(
(label: RecordingLabel) => {
(label: KeyValue) => {
if (clickableOptions) {
const labelFilterSet = new Set(clickableOptions.labelFilters);
return labelFilterSet.has(getLabelDisplay(label));
Expand All @@ -44,11 +44,11 @@ export const LabelCell: React.FC<LabelCellProps> = ({ target, labels, clickableO
);

const getLabelColor = React.useCallback(
(label: RecordingLabel) => (isLabelSelected(label) ? 'blue' : 'grey'),
(label: KeyValue) => (isLabelSelected(label) ? 'blue' : 'grey'),
[isLabelSelected],
);
const onLabelSelectToggle = React.useCallback(
(clickedLabel: RecordingLabel) => {
(clickedLabel: KeyValue) => {
if (clickableOptions) {
clickableOptions.updateFilters(target, {
filterKey: 'Label',
Expand Down
14 changes: 7 additions & 7 deletions src/app/RecordingMetadata/RecordingLabelFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import { LoadingView } from '@app/Shared/Components/LoadingView';
import { KeyValue } from '@app/Shared/Services/api.types';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { portalRoot } from '@app/utils/utils';
import {
Expand All @@ -34,12 +35,11 @@ import { CloseIcon, ExclamationCircleIcon, FileIcon, PlusCircleIcon, UploadIcon
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { catchError, Observable, of, zip } from 'rxjs';
import { RecordingLabel } from './types';
import { matchesLabelSyntax, getValidatedOption, LabelPattern, parseLabelsFromFile } from './utils';

export interface RecordingLabelFieldsProps {
labels: RecordingLabel[];
setLabels: (labels: RecordingLabel[]) => void;
labels: KeyValue[];
setLabels: (labels: KeyValue[]) => void;
setValid: (isValid: ValidatedOptions) => void;
isUploadable?: boolean;
isDisabled?: boolean;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const RecordingLabelFields: React.FC<RecordingLabelFieldsProps> = ({
);

const handleAddLabelButtonClick = React.useCallback(() => {
setLabels([...labels, { key: '', value: '' } as RecordingLabel]);
setLabels([...labels, { key: '', value: '' } as KeyValue]);
}, [labels, setLabels]);

const handleDeleteLabelButtonClick = React.useCallback(
Expand All @@ -91,7 +91,7 @@ export const RecordingLabelFields: React.FC<RecordingLabelFieldsProps> = ({
);

const isDuplicateKey = React.useCallback(
(key: string, labels: RecordingLabel[]) => labels.filter((label) => label.key === key).length > 1,
(key: string, labels: KeyValue[]) => labels.filter((label) => label.key === key).length > 1,
[],
);

Expand Down Expand Up @@ -127,7 +127,7 @@ export const RecordingLabelFields: React.FC<RecordingLabelFieldsProps> = ({
(e: React.ChangeEvent<HTMLInputElement>) => {
const files = e.target.files;
if (files && files.length) {
const tasks: Observable<RecordingLabel[]>[] = [];
const tasks: Observable<KeyValue[]>[] = [];
setLoading(true);
for (const labelFile of Array.from(files)) {
tasks.push(
Expand All @@ -140,7 +140,7 @@ export const RecordingLabelFields: React.FC<RecordingLabelFieldsProps> = ({
);
}
addSubscription(
zip(tasks).subscribe((labelArrays: RecordingLabel[][]) => {
zip(tasks).subscribe((labelArrays: KeyValue[][]) => {
setLoading(false);
const newLabels = labelArrays.reduce((acc, next) => acc.concat(next), []);
setLabels([...labels, ...newLabels]);
Expand Down
20 changes: 0 additions & 20 deletions src/app/RecordingMetadata/types.tsx

This file was deleted.

Loading

0 comments on commit a2a8815

Please sign in to comment.