Skip to content

Commit

Permalink
Include additional columns in catsrc list view
Browse files Browse the repository at this point in the history
and change Kebab action menu

Signed-off-by: Harish <hgovinda@redhat.com>
  • Loading branch information
harishsurf committed Nov 18, 2020
1 parent 50ad4f6 commit 4d2aefe
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ const DefaultSourceKebab: React.FC<DefaultSourceKebabProps> = ({
operatorHub,
sourceName,
sourceDisabled,
source,
}) => {
const options = sourceDisabled
? [enableSource(kind, operatorHub, sourceName)]
: [disableSourceModal(kind, operatorHub, sourceName)];
: [
disableSourceModal(kind, operatorHub, sourceName),
...(source ? [Kebab.factory.Edit(CatalogSourceModel, source)] : []),
];
return <Kebab options={options} />;
};

Expand Down Expand Up @@ -249,10 +253,12 @@ export const CreateSubscriptionYAML: React.FC<CreateSubscriptionYAMLProps> = (pr

const tableColumnClasses = [
classNames('col-lg-3', 'col-md-3', 'col-sm-4', 'col-xs-6'),
classNames('col-lg-2', 'col-md-3', 'col-sm-4', 'col-xs-6'),
classNames('col-lg-2', 'col-md-3', 'col-sm-4', 'hidden-xs'),
classNames('col-lg-1', 'col-md-2', 'col-sm-2', 'hidden-xs'),
classNames('col-lg-1', 'col-md-2', 'col-sm-3', 'col-xs-6'),
classNames('col-lg-1', 'col-md-2', 'col-sm-3', 'hidden-xs'),
classNames('col-lg-3', 'col-md-3', 'hidden-sm', 'hidden-xs'),
classNames('col-lg-2', 'hidden-md', 'hidden-sm', 'hidden-xs'),
classNames('col-lg-1', 'hidden-md', 'hidden-sm', 'hidden-xs'),
Kebab.columnClass,
];

Expand Down Expand Up @@ -290,6 +296,8 @@ const CatalogSourceTableRow: RowFunction<CatalogSourceTableRowObj> = ({
operatorCount = 0,
operatorHub,
publisher = '-',
registryPollInterval = '-',
status = '',
source,
},
index,
Expand All @@ -315,21 +323,29 @@ const CatalogSourceTableRow: RowFunction<CatalogSourceTableRowObj> = ({
name
)}
</TableData>
<TableData className={tableColumnClasses[1]}>{publisher}</TableData>
<TableData className={tableColumnClasses[2]}>{availability}</TableData>
<TableData className={tableColumnClasses[3]}>{endpoint}</TableData>
<TableData className={tableColumnClasses[4]}>{operatorCount || '-'}</TableData>
<TableData className={tableColumnClasses[5]}>
<TableData className={tableColumnClasses[1]}>{status}</TableData>
<TableData className={tableColumnClasses[2]}>{publisher}</TableData>
<TableData className={tableColumnClasses[3]}>{availability}</TableData>
<TableData className={tableColumnClasses[4]}>{endpoint}</TableData>
<TableData className={tableColumnClasses[5]}>{registryPollInterval}</TableData>
<TableData className={tableColumnClasses[6]}>{operatorCount || '-'}</TableData>
<TableData className={tableColumnClasses[7]}>
{isDefault ? (
<DefaultSourceKebab
kind={OperatorHubModel}
operatorHub={operatorHub}
sourceName={name}
sourceDisabled={disabled}
source={source}
/>
) : (
<ResourceKebab
actions={[Kebab.factory.Edit, deleteModal]}
actions={[
Kebab.factory.ModifyLabels,
Kebab.factory.ModifyAnnotations,
Kebab.factory.Edit,
deleteModal,
]}
kind={catalogSourceModelReference}
resource={source}
/>
Expand All @@ -348,33 +364,45 @@ const CatalogSourceList: React.FC<TableProps> = (props) => {
transforms: [sortable],
props: { className: tableColumnClasses[0] },
},
{
title: t('catalog-source~Status'),
sortField: 'status',
transforms: [sortable],
props: { className: tableColumnClasses[1] },
},
{
title: t('catalog-source~Publisher'),
sortField: 'publisher',
transforms: [sortable],
props: { className: tableColumnClasses[1] },
props: { className: tableColumnClasses[2] },
},
{
title: t('catalog-source~Availability'),
sortField: 'availabilitySort',
transforms: [sortable],
props: { className: tableColumnClasses[2] },
props: { className: tableColumnClasses[3] },
},
{
title: t('catalog-source~Endpoint'),
sortField: 'endpoint',
transforms: [sortable],
props: { className: tableColumnClasses[3] },
props: { className: tableColumnClasses[4] },
},
{
title: t('catalog-source~Registry Poll Interval'),
sortField: 'registryPollInterval',
transforms: [sortable],
props: { className: tableColumnClasses[5] },
},
{
title: t('catalog-source~# of Operators'),
sortField: 'operatorCount',
transforms: [sortable],
props: { className: tableColumnClasses[4] },
props: { className: tableColumnClasses[6] },
},
{
title: '',
props: { className: tableColumnClasses[5] },
props: { className: tableColumnClasses[7] },
},
];
};
Expand Down Expand Up @@ -420,6 +448,12 @@ const DisabledPopover: React.FC<DisabledPopoverProps> = ({ operatorHub, sourceNa
);
};

const getRegistryPollInterval = (catalogSource: CatalogSourceKind): string => {
return catalogSource.spec?.updateStrategy
? catalogSource.spec.updateStrategy.registryPoll.interval
: undefined;
};

const flatten = ({
catalogSources,
operatorHub,
Expand Down Expand Up @@ -450,6 +484,8 @@ const flatten = ({
endpoint: getEndpoint(catalogSource),
operatorCount: getOperatorCount(catalogSource, packageManifests.data),
publisher: catalogSource.spec.publisher,
registryPollInterval: getRegistryPollInterval(catalogSource),
status: catalogSource.status.connectionState.lastObservedState,
}),
};
},
Expand All @@ -466,6 +502,8 @@ const flatten = ({
operatorCount: getOperatorCount(source, packageManifests.data),
operatorHub,
publisher: source.spec.publisher,
registryPollInterval: getRegistryPollInterval(source),
status: source.status.connectionState.lastObservedState,
source,
}));

Expand Down Expand Up @@ -514,9 +552,11 @@ type CatalogSourceTableRowObj = {
isDefault?: boolean;
name: string;
namespace: string;
publisher?: string;
operatorCount?: number;
operatorHub: OperatorHubKind;
publisher?: string;
registryPollInterval?: string;
status?: string;
source?: CatalogSourceKind;
};

Expand All @@ -525,6 +565,7 @@ type DefaultSourceKebabProps = {
operatorHub: OperatorHubKind;
sourceName: string;
sourceDisabled: boolean;
source?: CatalogSourceKind;
};

type DisabledPopoverProps = {
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/operator-lifecycle-manager/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export type CatalogSourceKind = {
description?: string;
publisher?: string;
icon?: { mediatype: string; data: string };
updateStrategy?: { registryPoll: { interval: string } };
};
} & K8sResourceKind;

Expand Down

0 comments on commit 4d2aefe

Please sign in to comment.