Skip to content

Commit

Permalink
refactoring types
Browse files Browse the repository at this point in the history
Signed-off-by: Ramakrishna Chilaka <[email protected]>
  • Loading branch information
RamakrishnaChilaka committed Mar 24, 2024
1 parent 2c37acf commit 2f5b4a7
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion public/pages/Aliases/containers/Aliases/Aliases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const defaultFilter = {

class Aliases extends MDSEnabledComponent<AliasesProps, AliasesState> {
static contextType = CoreServicesContext;

constructor(props: AliasesProps) {
super(props);
const {
Expand Down Expand Up @@ -482,7 +483,7 @@ class Aliases extends MDSEnabledComponent<AliasesProps, AliasesState> {
}
}

export default function AliasContainer(props: Omit<AliasesProps, "commonService">) {
export default function AliasContainer(props: Omit<AliasesProps, "commonService" | keyof DataSourceMenuProperties>) {
const context = useContext(ServicesContext);
const dataSourceMenuProps = useContext(DataSourceMenuContext);
return <Aliases {...props} commonService={context?.commonService as CommonService} {...dataSourceMenuProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class ComposableTemplates extends MDSEnabledComponent<ComposableTemplatesProps,
}

export default function ComposableTemplatesContainer(
props: Omit<ComposableTemplatesProps, "commonService" | "loading" | "componentMapTemplate">
props: Omit<ComposableTemplatesProps, "commonService" | "loading" | "componentMapTemplate" | keyof DataSourceMenuProperties>
) {
const context = useContext(ServicesContext);
const dataSourceMenuProps = useContext(DataSourceMenuContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CreateComposableTemplate extends Component<CreateComposableTemplateProps>
}
}

export default function (props: CreateComposableTemplateProps) {
export default function (props: Omit<CreateComposableTemplateProps, keyof DataSourceMenuProperties>) {
const dataSourceMenuProps = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <CreateComposableTemplate {...props} {...dataSourceMenuProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CreateDataStream extends Component<CreateDataStreamProps> {
}
}

export default function (props: CreateDataStreamProps) {
export default function (props: Omit<CreateDataStreamProps, keyof DataSourceMenuProperties>) {
const dataSourceMenuProps = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <CreateDataStream {...props} {...dataSourceMenuProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { RouteComponentProps } from "react-router-dom";
import IndexForm from "../IndexForm";
import { BREADCRUMBS, IndicesUpdateMode, ROUTES } from "../../../../utils/constants";
import { CoreServicesContext } from "../../../../components/core_services";
import { CommonService } from "../../../../services/index";
import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext";
import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent";

interface CreateIndexProps extends RouteComponentProps<{ index?: string; mode?: IndicesUpdateMode }>, DataSourceMenuProperties {
interface CreateIndexPropsBase extends RouteComponentProps<{ index?: string; mode?: IndicesUpdateMode }> {
isEdit?: boolean;
commonService: CommonService;
}

interface CreateIndexProps extends CreateIndexPropsBase, DataSourceMenuProperties {}

export class CreateIndex extends Component<CreateIndexProps> {
static contextType = CoreServicesContext;

Expand Down Expand Up @@ -63,7 +63,7 @@ export class CreateIndex extends Component<CreateIndexProps> {
}
}

export default function (props: CreateIndexProps) {
export default function (props: CreateIndexPropsBase) {
const dataSourceMenuProperties = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <CreateIndex {...props} {...dataSourceMenuProperties} />;
Expand Down
4 changes: 3 additions & 1 deletion public/pages/CreateIndex/containers/IndexForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const getAliasActionsByDiffArray = (
}, [] as IAliasAction[]);
};

export interface IndexFormProps extends Pick<IndexDetailProps, "readonly" | "sourceIndices">, DataSourceMenuProperties {
export interface IndexFormProps
extends Pick<IndexDetailProps, "readonly" | "sourceIndices">,
Pick<DataSourceMenuProperties, "dataSourceId"> {
index?: string;
value?: Partial<IndexItemRemote>;
mode?: IndicesUpdateMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { CoreServicesContext } from "../../../../components/core_services";
import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext";
import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent";

interface CreateIndexTemplateProps extends RouteComponentProps<{ template?: string; mode?: string }>, DataSourceMenuProperties {}
interface CreateIndexTemplateProps
extends RouteComponentProps<{
template?: string;
mode?: string;
}>,
DataSourceMenuProperties {}

class CreateIndexTemplate extends Component<CreateIndexTemplateProps> {
static contextType = CoreServicesContext;
Expand Down Expand Up @@ -74,7 +79,7 @@ class CreateIndexTemplate extends Component<CreateIndexTemplateProps> {
}
}

export default function (props: CreateIndexTemplateProps) {
export default function (props: Omit<CreateIndexTemplateProps, keyof DataSourceMenuProperties>) {
const dataSourceMenuProps = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <CreateIndexTemplate {...props} {...dataSourceMenuProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class DataStreams extends MDSEnabledComponent<DataStreamsProps, DataStreamsState
}
}

export default function DataStreamsContainer(props: Omit<DataStreamsProps, "commonService">) {
export default function DataStreamsContainer(props: Omit<DataStreamsProps, "commonService" | keyof DataSourceMenuProperties>) {
const context = useContext(ServicesContext);
const dataSourceMenuProperties = useContext(DataSourceMenuContext);
return <DataStreams {...props} commonService={context?.commonService as CommonService} {...dataSourceMenuProperties} />;
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Indices/containers/Indices/Indices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class Indices extends MDSEnabledComponent<IndicesProps, IndicesState> {
}
}

export default function (props: IndicesProps) {
export default function (props: Omit<IndicesProps, keyof DataSourceMenuProperties>) {
const dataSourceMenuProps = useContext(DataSourceMenuContext);
return <Indices {...props} {...dataSourceMenuProps} />;
}
4 changes: 2 additions & 2 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export default class Main extends Component<MainProps, MainState> {
path={`${ROUTES.CREATE_INDEX}/:index/:mode`}
render={(props: RouteComponentProps) => (
<div style={ROUTE_STYLE}>
<CreateIndex {...props} commonService={services.commonService} />
<CreateIndex {...props} />
</div>
)}
/>
Expand All @@ -642,7 +642,7 @@ export default class Main extends Component<MainProps, MainState> {
path={ROUTES.CREATE_INDEX}
render={(props: RouteComponentProps) => (
<div style={ROUTE_STYLE}>
<CreateIndex {...props} commonService={services.commonService} />
<CreateIndex {...props} />
</div>
)}
/>
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Templates/containers/Templates/Templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class Templates extends MDSEnabledComponent<TemplatesProps, TemplatesState> {
}
}

export default function TemplatesContainer(props: Omit<TemplatesProps, "commonService">) {
export default function TemplatesContainer(props: Omit<TemplatesProps, "commonService" | keyof DataSourceMenuProperties>) {
const context = useContext(ServicesContext);
const dataSourceMenuProps = useContext(DataSourceMenuContext);
return <Templates {...props} commonService={context?.commonService as CommonService} {...dataSourceMenuProps} />;
Expand Down

0 comments on commit 2f5b4a7

Please sign in to comment.