Skip to content

Commit

Permalink
Interface change for MDS and deprecating dataSourceLabel from the URL (
Browse files Browse the repository at this point in the history
…#1031) (#1036)

Signed-off-by: Ramakrishna Chilaka <[email protected]>
(cherry picked from commit ed98e4a)
  • Loading branch information
RamakrishnaChilaka authored Apr 15, 2024
1 parent 927c05d commit be61e6a
Show file tree
Hide file tree
Showing 13 changed files with 498 additions and 521 deletions.
12 changes: 3 additions & 9 deletions public/components/MDSEnabledComponent/MDSEnabledComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default class MDSEnabledComponent<
super(props);
this.state = {
dataSourceId: props.dataSourceId,
dataSourceLabel: props.dataSourceLabel,
multiDataSourceEnabled: props.multiDataSourceEnabled,
} as State;
}
Expand All @@ -21,13 +20,9 @@ export default class MDSEnabledComponent<
prevState: State
) {
// static members cannot reference class type parameters
if (
nextProps.multiDataSourceEnabled &&
(nextProps.dataSourceId !== prevState.dataSourceId || nextProps.dataSourceLabel !== prevState.dataSourceLabel)
) {
if (nextProps.multiDataSourceEnabled && nextProps.dataSourceId !== prevState.dataSourceId) {
return {
dataSourceId: nextProps.dataSourceId,
dataSourceLabel: nextProps.dataSourceLabel,
};
}
return null;
Expand All @@ -36,7 +31,7 @@ export default class MDSEnabledComponent<

export function useUpdateUrlWithDataSourceProperties() {
const dataSourceMenuProps = useContext(DataSourceMenuContext);
const { dataSourceId, dataSourceLabel, multiDataSourceEnabled } = dataSourceMenuProps;
const { dataSourceId, multiDataSourceEnabled } = dataSourceMenuProps;
const history = useHistory();
const currentSearch = history.location.search;
const currentQuery = queryString.parse(currentSearch);
Expand All @@ -46,9 +41,8 @@ export function useUpdateUrlWithDataSourceProperties() {
search: queryString.stringify({
...currentQuery,
dataSourceId,
dataSourceLabel,
}),
});
}
}, [dataSourceId, dataSourceLabel, multiDataSourceEnabled]);
}, [dataSourceId, multiDataSourceEnabled]);
}
1 change: 0 additions & 1 deletion public/pages/Aliases/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export const DEFAULT_QUERY_PARAMS = {
sortDirection: SortDirection.DESC,
status: "",
dataSourceId: "",
dataSourceLabel: "",
};
1 change: 0 additions & 1 deletion public/pages/ComposableTemplates/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ export const DEFAULT_QUERY_PARAMS = {
sortField: "name" as keyof ICatComposableTemplate,
sortDirection: SortDirection.DESC,
dataSourceId: "",
dataSourceLabel: "",
};
1 change: 0 additions & 1 deletion public/pages/DataStreams/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const DEFAULT_QUERY_PARAMS = {
sortField: "name" as keyof DataStream,
sortDirection: SortDirection.DESC,
dataSourceId: "",
dataSourceLabel: "",
};

export const HEALTH_TO_COLOR: {
Expand Down
3 changes: 0 additions & 3 deletions public/pages/Indices/containers/Indices/Indices.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function renderWithRouter(
Component: React.ComponentType<any>,
data: DataSourceMenuProperties = {
dataSourceId: "",
dataSourceLabel: "",
multiDataSourceEnabled: false,
},
renderFn = render
Expand Down Expand Up @@ -264,7 +263,6 @@ describe("re-render on data-source-id prop change", () => {

const { getByText, queryByText, rerender } = renderWithRouter(Indices, {
dataSourceId: "test_data_source_id",
dataSourceLabel: "test_data_source_label",
multiDataSourceEnabled: true,
});

Expand All @@ -276,7 +274,6 @@ describe("re-render on data-source-id prop change", () => {
Indices,
{
dataSourceId: "test_data_source_id_2",
dataSourceLabel: "test_data_source_label_2",
multiDataSourceEnabled: true,
},
rerender
Expand Down
1 change: 0 additions & 1 deletion public/pages/Indices/containers/Indices/Indices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class Indices extends MDSEnabledComponent<IndicesProps, IndicesState> {
const queryObject = this.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify({
...queryObject,
...(this.state.multiDataSourceEnabled ? { dataSourceLabel: this.state.dataSourceLabel } : {}),
});
history.replace({ ...this.props.location, search: queryParamsString });

Expand Down
981 changes: 490 additions & 491 deletions public/pages/Main/Main.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ export class ManagedIndices extends MDSEnabledComponent<ManagedIndicesProps, Man
try {
const { managedIndexService, history } = this.props;
const queryObject = ManagedIndices.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify({
...queryObject,
...(this.state.multiDataSourceEnabled ? { dataSourceLabel: this.state.dataSourceLabel } : {}),
});
const queryParamsString = queryString.stringify(queryObject);
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 @@ -142,7 +142,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, dataSourceLabel: this.state.dataSourceLabel });
const queryParamsString = queryString.stringify(queryObject);
history.replace({ ...this.props.location, search: queryParamsString });
const getPoliciesResponse = await policyService.getPolicies(queryObject);
if (getPoliciesResponse.ok) {
Expand Down
4 changes: 2 additions & 2 deletions public/pages/Rollups/containers/Rollups/Rollups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export class Rollups extends MDSEnabledComponent<RollupsProps, RollupsState> {
try {
const { rollupService, history } = this.props;
const queryObject = Rollups.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify({ ...queryObject, dataSourceLabel: this.state.dataSourceLabel });
const queryParamsString = queryString.stringify(queryObject);
history.replace({ ...this.props.location, search: queryParamsString });
const rollupJobsResponse = await rollupService.getRollups(queryObject); // Add type assertion
const rollupJobsResponse = await rollupService.getRollups(queryObject);
if (rollupJobsResponse.ok) {
const { rollups, totalRollups, metadata } = rollupJobsResponse.response;
this.setState({ rollups, totalRollups, rollupExplain: metadata });
Expand Down
1 change: 0 additions & 1 deletion public/pages/Templates/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ export const DEFAULT_QUERY_PARAMS = {
sortField: "name" as keyof ITemplate,
sortDirection: SortDirection.DESC,
dataSourceId: "",
dataSourceLabel: "",
};
5 changes: 1 addition & 4 deletions public/pages/Transforms/containers/Transforms/Transforms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,7 @@ export class Transforms extends MDSEnabledComponent<TransformProps, TransformSta
try {
const { transformService, history } = this.props;
const queryObject = Transforms.getQueryObjectFromState(this.state);
const queryParamsString = queryString.stringify({
...Transforms.getQueryObjectFromState(this.state),
dataSourceLabel: this.state.dataSourceLabel,
});
const queryParamsString = queryString.stringify(Transforms.getQueryObjectFromState(this.state));
history.replace({ ...this.props.location, search: queryParamsString });
const response = await transformService.getTransforms(queryObject);
if (response.ok) {
Expand Down
2 changes: 0 additions & 2 deletions public/services/DataSourceMenuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createContext } from "react";

export interface DataSourceMenuProperties {
dataSourceId: string;
dataSourceLabel: string;
multiDataSourceEnabled: boolean;
}

Expand All @@ -14,7 +13,6 @@ export interface DataSourceMenuReadOnlyProperties {

const DataSourceMenuContext = createContext<DataSourceMenuProperties>({
dataSourceId: "",
dataSourceLabel: "",
multiDataSourceEnabled: false,
});

Expand Down

0 comments on commit be61e6a

Please sign in to comment.