Skip to content

Commit

Permalink
fix(aa): refactor Automated Analysis Recording Setting (#1014)
Browse files Browse the repository at this point in the history
* show current config

Signed-off-by: Max Cao <macao@redhat.com>

* prevent setting empty template

Signed-off-by: Max Cao <macao@redhat.com>

* add reset

Signed-off-by: Max Cao <macao@redhat.com>

* fix some handling

Signed-off-by: Max Cao <macao@redhat.com>

* redesign

Signed-off-by: Max Cao <macao@redhat.com>

* redesign 2

Signed-off-by: Max Cao <macao@redhat.com>

* update tests and add confirmation

Signed-off-by: Max Cao <macao@redhat.com>

* re: fixes

Signed-off-by: Max Cao <macao@redhat.com>

* fix tests

Signed-off-by: Max Cao <macao@redhat.com>

* localize

Signed-off-by: Max Cao <macao@redhat.com>

---------

Signed-off-by: Max Cao <macao@redhat.com>
(cherry picked from commit 093e003)
  • Loading branch information
maxcao13 authored and mergify[bot] committed May 5, 2023
1 parent f92767b commit 46f919a
Show file tree
Hide file tree
Showing 13 changed files with 458 additions and 307 deletions.
2 changes: 1 addition & 1 deletion locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"DESCRIPTION": "Description",
"DEVELOPMENT": "DEVELOPMENT",
"DOWNLOAD": "Download",
"EDIT": "Edit",
"FILTER_NAME": "Name",
"HELP": "Help",
"HOUR": "Hour",
Expand Down Expand Up @@ -54,7 +55,6 @@
"SUBMITTING": "Submitting",
"SUGGESTED": "Suggested",
"TEMPLATE": "Template",
"TEMPLATE_HELPER_TEXT_INVALID": "Template must be selected",
"TIME": "Time",
"UPLOAD": "Upload",
"USER_SUBMITTED": "User-submitted",
Expand Down
9 changes: 8 additions & 1 deletion locales/en/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@
}
},
"AutomatedAnalysisConfigForm": {
"ERROR_TITLE": "Error displaying recording configuration settings",
"CURRENT_CONFIG": "Current Configuration",
"FORM_TITLE": "Profiling Recording Configuration",
"FORMATTED_TEMPLATE": "Name: {{template.name}}, Type: {{template.type}}",
"MAXIMUM_AGE": "Maximum age ({{unit}})",
"MAXIMUM_SIZE": "Maximum size ({{unit}})",
"SAVE_CHANGES": "Save changes",
"TEMPLATE_HELPER_TEXT": "The Event Template to be applied to Automated Analysis recordings.",
"TEMPLATE_INVALID_WARNING": "WARNING: Setting a Target Template as a default template type configuration may not apply to all Target JVMs if the JVMs do not support them."
},
Expand Down Expand Up @@ -230,6 +234,9 @@
"ERROR_MESSAGE": "Reason: {{message}}",
"RESOLVE_MESSAGE": "Reload the page and try again. If the error still persists, see the list of <issue>{{knownIssue}}</issue> or <report>{{fileReport}}</report>."
},
"ErrorView": {
"EVENT_TEMPLATES": "Error retrieving event templates"
},
"JvmDetailsCard": {
"CARD_DESCRIPTION": "Display details about the selected target JVM.",
"CARD_DESCRIPTION_FULL": "View information such as the connection URL, labels, and annotations belonging to the selected target JVM.",
Expand Down
7 changes: 6 additions & 1 deletion src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,12 @@ const AppLayout: React.FC<AppLayoutProps> = ({ children }) => {
>
{children}
</Page>
<AuthModal visible={showAuthModal} onDismiss={dismissAuthModal} onSave={authModalOnSave} />
<AuthModal
visible={showAuthModal}
onDismiss={dismissAuthModal}
onSave={authModalOnSave}
targetObs={serviceContext.target.target()}
/>
<SslErrorModal visible={showSslErrorModal} onDismiss={dismissSslErrorModal} />
</CryostatJoyride>
</GlobalQuickStartDrawer>
Expand Down
12 changes: 6 additions & 6 deletions src/app/AppLayout/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@
* SOFTWARE.
*/
import { ServiceContext } from '@app/Shared/Services/Services';
import { NO_TARGET } from '@app/Shared/Services/Target.service';
import { NO_TARGET, Target } from '@app/Shared/Services/Target.service';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { Modal, ModalVariant, Text } from '@patternfly/react-core';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { filter, first, map, mergeMap } from 'rxjs';
import { Observable, filter, first, map, mergeMap } from 'rxjs';
import { CredentialAuthForm } from './CredentialAuthForm';

export interface AuthModalProps {
visible: boolean;
onDismiss: () => void;
onSave: () => void;
targetObs: Observable<Target>;
}

export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onPropsSave, ...props }) => {
export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onPropsSave, targetObs, ...props }) => {
const context = React.useContext(ServiceContext);
const [loading, setLoading] = React.useState(false);
const addSubscription = useSubscriptions();
Expand All @@ -59,8 +60,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
(username: string, password: string) => {
setLoading(true);
addSubscription(
context.target
.target()
targetObs
.pipe(
filter((target) => target !== NO_TARGET),
first(),
Expand All @@ -75,7 +75,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({ onDismiss, onSave: onProps
})
);
},
[addSubscription, context.authCredentials, context.target, setLoading, onPropsSave]
[addSubscription, context.authCredentials, targetObs, setLoading, onPropsSave]
);

return (
Expand Down
Loading

0 comments on commit 46f919a

Please sign in to comment.