Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split integrations.ts into handlers & data #40685

Merged
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/integrations_manager/common/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { PLUGIN_ID } from './constants';
export const API_ROOT = `/api/${PLUGIN_ID}`;
export const API_LIST_PATTERN = `${API_ROOT}/list`;
export const API_INFO_PATTERN = `${API_ROOT}/package/{pkgkey}`;
export const API_INSTALL_PATTERN = `${API_ROOT}/install/{pkgkey}/{feature?}`;
export const API_DELETE_PATTERN = `${API_ROOT}/delete/{pkgkey}/{feature?}`;
export const API_INSTALL_PATTERN = `${API_ROOT}/install/{pkgkey}/{asset?}`;
export const API_DELETE_PATTERN = `${API_ROOT}/delete/{pkgkey}/{asset?}`;

export function getListPath() {
return API_LIST_PATTERN;
Expand Down
16 changes: 9 additions & 7 deletions x-pack/legacy/plugins/integrations_manager/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
} from 'src/core/server/saved_objects';

type AssetReference = Pick<SavedObjectReference, 'id' | 'type'>;
export interface Installation extends SavedObjectAttributes {
export interface InstallationAttributes extends SavedObjectAttributes {
installed: AssetReference[];
}

export type InstallationSavedObject = SavedObject<Installation>;
export type Installation = SavedObject<InstallationAttributes>;

// the contract with the registry
export type RegistryList = RegistryListItem[];
Expand Down Expand Up @@ -49,15 +49,17 @@ export interface RegistryPackage {
// the public HTTP response types
export type IntegrationList = IntegrationListItem[];

export type IntegrationListItem = Installed<RegistryListItem> | NotInstalled<RegistryListItem>;
export type IntegrationListItem = Installable<RegistryListItem>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you don’t have to do the | each time. Went with Installable over Maybe*, Either*, etc.


export type IntegrationInfo = Installed<RegistryPackage> | NotInstalled<RegistryPackage>;
export type IntegrationInfo = Installable<RegistryPackage>;

type Installed<T = {}> = T & {
export type Installable<T> = Installed<T> | NotInstalled<T>;

export type Installed<T = {}> = T & {
status: 'installed';
savedObject: InstallationSavedObject;
savedObject: Installation;
};

type NotInstalled<T = {}> = T & {
export type NotInstalled<T = {}> = T & {
status: 'not_installed';
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import { IntegrationInfo } from '../../common/types';

export function Detail(props: { package: string }) {
const [info, setInfo] = useState<IntegrationInfo | null>(null);
useEffect(
() => {
getIntegrationInfoByKey(props.package).then(setInfo);
},
[props.package]
);
useEffect(() => {
getIntegrationInfoByKey(props.package).then(setInfo);
}, [props.package]);

// don't have designs for loading/empty states
if (!info) return null;
Expand Down
230 changes: 0 additions & 230 deletions x-pack/legacy/plugins/integrations_manager/server/integrations.ts

This file was deleted.

Loading