Skip to content

Commit e2cdad2

Browse files
committed
fix: OU-1195 update dashboard-action-modal so only selectedProjectName is used and update dashboard-create-dialog to use editableProjects array to check if the project already exists
1 parent 3189b29 commit e2cdad2

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

web/src/components/dashboards/perses/dashboard-action-modals.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '@patternfly/react-core';
2020
import { TypeaheadSelect, TypeaheadSelectOption } from '@patternfly/react-templates';
2121
import { ExclamationCircleIcon } from '@patternfly/react-icons';
22-
import React, { useMemo, useState } from 'react';
22+
import React, { useMemo } from 'react';
2323
import { useTranslation } from 'react-i18next';
2424
import {
2525
useUpdateDashboardMutation,
@@ -184,7 +184,6 @@ export const DuplicateActionModal = ({ dashboard, isOpen, onClose }: ActionModal
184184

185185
const navigate = useNavigate();
186186
const { perspective } = usePerspective();
187-
const [selectedProject, setSelectedProject] = useState<string | null>(null);
188187

189188
const {
190189
editableProjects,
@@ -293,7 +292,6 @@ export const DuplicateActionModal = ({ dashboard, isOpen, onClose }: ActionModal
293292

294293
const onProjectSelect = (_event: any, selection: string) => {
295294
form.setValue('projectName', selection);
296-
setSelectedProject(selection);
297295
};
298296

299297
return (
@@ -369,14 +367,13 @@ export const DuplicateActionModal = ({ dashboard, isOpen, onClose }: ActionModal
369367
>
370368
<LabelSpacer />
371369
<TypeaheadSelect
372-
key={selectedProject || 'no-selection'}
370+
key={selectedProjectName || 'no-selection'}
373371
initialOptions={projectOptions}
374372
placeholder={t('Select namespace')}
375373
noOptionsFoundMessage={(filter) =>
376374
t('No namespace found for "{{filter}}"', { filter })
377375
}
378376
onClearSelection={() => {
379-
setSelectedProject(null);
380377
form.setValue('projectName', '');
381378
}}
382379
onSelect={onProjectSelect}

web/src/components/dashboards/perses/dashboard-create-dialog.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export const DashboardCreateDialog: React.FunctionComponent = () => {
4444
const [formErrors, setFormErrors] = useState<{ [key: string]: string }>({});
4545
const createDashboardMutation = useCreateDashboardMutation();
4646
const createProjectMutation = useCreateProjectMutation();
47-
const { persesProjects } = usePerses();
4847

4948
const disabled = permissionsLoading || !hasEditableProject;
5049

@@ -97,9 +96,7 @@ export const DashboardCreateDialog: React.FunctionComponent = () => {
9796
return;
9897
}
9998

100-
const projectExists = persesProjects.some(
101-
(project) => project.metadata?.name === selectedProject,
102-
);
99+
const projectExists = editableProjects.some((project) => project === selectedProject);
103100

104101
if (!projectExists) {
105102
try {

0 commit comments

Comments
 (0)