Skip to content

Commit

Permalink
change workspace prop to currentWorkspace in SavedObjectsDuplicateModal
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Sep 14, 2023
1 parent feb091c commit 40f1d39
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ export const getNavActions = (
});
};

const currentWorkspace = workspaces.currentWorkspace$.value;
const dashboardSavedObject = (savedDashboard || {}) as SavedObjectWithMetadata;
dashboardSavedObject.meta = { title: savedDashboard.title };

const duplicateModal = (
<SavedObjectsDuplicateModal
duplicateMode={DuplicateMode.Selected}
selectedSavedObjects={[dashboardSavedObject]}
workspaces={workspaces}
currentWorkspace={currentWorkspace}
getDuplicateWorkspaces={getDuplicateWorkspaces}
onDuplicate={onDuplicate}
onClose={() => {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
EuiCallOut,
EuiText,
} from '@elastic/eui';
import { WorkspaceAttribute, WorkspaceStart } from 'opensearch-dashboards/public';
import { WorkspaceAttribute } from 'opensearch-dashboards/public';
import { i18n } from '@osd/i18n';
import { SavedObjectWithMetadata } from '../../../types';
import { getSavedObjectLabel } from '../../../lib';
Expand All @@ -41,16 +41,16 @@ import { SAVED_OBJECT_TYPE_WORKSPACE } from '../../../constants';
type WorkspaceOption = EuiComboBoxOptionOption<WorkspaceAttribute>;

interface Props {
workspaces: WorkspaceStart;
onDuplicate: (
savedObjects: SavedObjectWithMetadata[],
includeReferencesDeep: boolean,
targetWorkspace: string
) => Promise<void>;
onClose: () => void;
duplicateMode: DuplicateMode;
getDuplicateWorkspaces: () => Promise<WorkspaceAttribute[]>;
currentWorkspace: WorkspaceAttribute | null;
selectedSavedObjects: SavedObjectWithMetadata[];
getDuplicateWorkspaces: () => Promise<WorkspaceAttribute[]>;
}

interface State {
Expand Down Expand Up @@ -101,9 +101,8 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
};

async componentDidMount() {
const { workspaces, getDuplicateWorkspaces } = this.props;
const { currentWorkspace, getDuplicateWorkspaces } = this.props;
const workspaceList = await getDuplicateWorkspaces();
const currentWorkspace = workspaces.currentWorkspace$.value;
const currentWorkspaceName = currentWorkspace?.name;

// current workspace is the first option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb

renderDuplicateModal() {
const { workspaces } = this.props;
const currentWorkspace = workspaces.currentWorkspace$.value;
const { isShowingDuplicateModal, duplicateSelectedSavedObjects, duplicateMode } = this.state;

if (!isShowingDuplicateModal) {
Expand All @@ -783,7 +784,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
return (
<SavedObjectsDuplicateModal
selectedSavedObjects={duplicateSelectedSavedObjects}
workspaces={workspaces}
currentWorkspace={currentWorkspace}
getDuplicateWorkspaces={this.getDuplicateWorkspaces}
duplicateMode={duplicateMode}
onDuplicate={this.onDuplicate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,15 @@ export const getTopNavConfig = (
});
};

const currentWorkspace = workspaces.currentWorkspace$.value;
const visualizationSavedObject = (savedVis || {}) as SavedObjectWithMetadata;
visualizationSavedObject.meta = { title: savedVis?.title }; // meta is missing in savedVis

const duplicateModal = (
<SavedObjectsDuplicateModal
duplicateMode={DuplicateMode.Selected}
selectedSavedObjects={[visualizationSavedObject]}
workspaces={workspaces}
currentWorkspace={currentWorkspace}
getDuplicateWorkspaces={getDuplicateWorkspaces}
onDuplicate={onDuplicate}
onClose={() => {}}
Expand Down

0 comments on commit 40f1d39

Please sign in to comment.