Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Prabhat Sharma committed Apr 11, 2024
2 parents cbf4a2a + 134f23f commit 9c4ee45
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion public/containers/ClearCacheModal/ClearCacheModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function ClearCacheModal(props: ClearCacheModalProps) {
const result = await services.commonService.apiCaller({
endpoint: "indices.clearCache",
data: {
index: unBlockedItems.join(","),
index: unBlockedItems.join(",") || "_all",
},
});
if (result && result.ok) {
Expand Down
13 changes: 3 additions & 10 deletions public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { PolicyOption } from "../../models/interfaces";
import { CoreServicesContext } from "../../../../components/core_services";
import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext";
import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent";
import { dataSource } from "src/plugins/data_source/server/saved_objects";

interface ChangePolicyProps extends RouteComponentProps, DataSourceProperties {
managedIndexService: ManagedIndexService;
Expand All @@ -41,7 +40,7 @@ export enum Radio {

export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState> {
static contextType = CoreServicesContext;
state: ChangePolicyState = {
static emptyState = {
selectedPolicies: [],
selectedManagedIndices: [],
selectedStateFilters: [],
Expand All @@ -51,6 +50,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
selectedPoliciesError: "",
hasSubmitted: false,
};
state: ChangePolicyState = ChangePolicy.emptyState;

async componentDidMount(): Promise<void> {
this.context.chrome.setBreadcrumbs([BREADCRUMBS.INDEX_MANAGEMENT, BREADCRUMBS.MANAGED_INDICES, BREADCRUMBS.CHANGE_POLICY]);
Expand All @@ -60,14 +60,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
if (prevProps.dataSourceId !== this.props.dataSourceId) {
// reset the state, if dataSourceId changes, i.e., clear state
this.setState({
selectedPolicies: [],
selectedManagedIndices: [],
selectedStateFilters: [],
stateRadioIdSelected: Radio.Current,
stateSelected: "",
managedIndicesError: "",
selectedPoliciesError: "",
hasSubmitted: false,
...ChangePolicy.emptyState,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe("<IndicesActions /> spec", () => {
expect(browserServicesMock.commonService.apiCaller).toHaveBeenCalledWith({
endpoint: "indices.clearCache",
data: {
index: "",
index: "_all",
},
});
expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -238,7 +238,7 @@ describe("<IndicesActions /> spec", () => {
expect(browserServicesMock.commonService.apiCaller).toHaveBeenCalledWith({
endpoint: "indices.clearCache",
data: {
index: "",
index: "_all",
},
});
expect(coreServicesMock.notifications.toasts.addError).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ export class ManagedIndices extends MDSEnabledComponent<ManagedIndicesProps, Man
try {
const { managedIndexService, history } = this.props;
const queryObject = ManagedIndices.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify(queryObject);
const queryParamsString = queryString.stringify({
...queryObject,
...(this.state.multiDataSourceEnabled ? { dataSourceLabel: this.state.dataSourceLabel } : {}),
});
history.replace({ ...this.props.location, search: queryParamsString });

const getManagedIndicesResponse = await managedIndexService.getManagedIndices({
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Policies/containers/Policies/Policies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class Policies extends MDSEnabledComponent<PoliciesProps, PoliciesState>
try {
const { policyService, history } = this.props;
const queryObject = Policies.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify(queryObject);
const queryParamsString = queryString.stringify({ ...queryObject, dataSourceLabel: this.state.dataSourceLabel });
history.replace({ ...this.props.location, search: queryParamsString });
const getPoliciesResponse = await policyService.getPolicies(queryObject);
if (getPoliciesResponse.ok) {
Expand Down

0 comments on commit 9c4ee45

Please sign in to comment.