do not plublicly export factories directly, but through tables
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
@@ -31,8 +31,8 @@ import {
|
||||
TableColumn,
|
||||
TableProps,
|
||||
} from '@backstage/core-components';
|
||||
import * as actionFactories from './actions';
|
||||
import * as columnFactories from './columns';
|
||||
import { actionFactories } from './actions';
|
||||
import { columnFactories } from './columns';
|
||||
import { toLowerMaybe } from '../../../helpers';
|
||||
import { DocsTableRow } from './types';
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
useStarredEntities,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { DocsTable } from './DocsTable';
|
||||
import * as actionFactories from './actions';
|
||||
import * as columnFactories from './columns';
|
||||
import { actionFactories } from './actions';
|
||||
import { columnFactories } from './columns';
|
||||
import { DocsTableRow } from './types';
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,39 +23,33 @@ import {
|
||||
import { DocsTableRow } from './types';
|
||||
|
||||
/**
|
||||
* Utility function for creating a copy docs url action for {@link DocsTable}.
|
||||
* Not directly exported, but through DocsTable.actions and EntityListDocsTable.actions
|
||||
*
|
||||
* @internal
|
||||
* @public
|
||||
*/
|
||||
|
||||
export function createCopyDocsUrlAction(copyToClipboard: Function) {
|
||||
return (row: DocsTableRow) => {
|
||||
return {
|
||||
icon: () => <ShareIcon fontSize="small" />,
|
||||
tooltip: 'Click to copy documentation link to clipboard',
|
||||
onClick: () =>
|
||||
copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`),
|
||||
export const actionFactories = {
|
||||
createCopyDocsUrlAction(copyToClipboard: Function) {
|
||||
return (row: DocsTableRow) => {
|
||||
return {
|
||||
icon: () => <ShareIcon fontSize="small" />,
|
||||
tooltip: 'Click to copy documentation link to clipboard',
|
||||
onClick: () =>
|
||||
copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`),
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for creating a star entity action for {@link DocsTable}.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
export function createStarEntityAction(
|
||||
isStarredEntity: Function,
|
||||
toggleStarredEntity: Function,
|
||||
) {
|
||||
return ({ entity }: DocsTableRow) => {
|
||||
const isStarred = isStarredEntity(entity);
|
||||
return {
|
||||
cellStyle: { paddingLeft: '1em' },
|
||||
icon: () => favoriteEntityIcon(isStarred),
|
||||
tooltip: favoriteEntityTooltip(isStarred),
|
||||
onClick: () => toggleStarredEntity(entity),
|
||||
},
|
||||
createStarEntityAction(
|
||||
isStarredEntity: Function,
|
||||
toggleStarredEntity: Function,
|
||||
) {
|
||||
return ({ entity }: DocsTableRow) => {
|
||||
const isStarred = isStarredEntity(entity);
|
||||
return {
|
||||
cellStyle: { paddingLeft: '1em' },
|
||||
icon: () => favoriteEntityIcon(isStarred),
|
||||
tooltip: favoriteEntityTooltip(isStarred),
|
||||
onClick: () => toggleStarredEntity(entity),
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -25,50 +25,42 @@ function customTitle(entity: Entity): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for creating a name column for {@link DocsTable}.
|
||||
* Not directly exported, but through DocsTable.columns and EntityListDocsTable.columns
|
||||
*
|
||||
* @internal
|
||||
* @public
|
||||
*/
|
||||
export function createNameColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Document',
|
||||
field: 'entity.metadata.name',
|
||||
highlight: true,
|
||||
render: (row: DocsTableRow) => (
|
||||
<SubvalueCell
|
||||
value={<Link to={row.resolved.docsUrl}>{customTitle(row.entity)}</Link>}
|
||||
subvalue={row.entity.metadata.description}
|
||||
/>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for creating an owner column for {@link DocsTable}.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function createOwnerColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Owner',
|
||||
field: 'resolved.ownedByRelationsTitle',
|
||||
render: ({ resolved }) => (
|
||||
<EntityRefLinks
|
||||
entityRefs={resolved.ownedByRelations}
|
||||
defaultKind="group"
|
||||
/>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for creating an spec type column for {@link DocsTable}.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function createTypeColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Type',
|
||||
field: 'entity.spec.type',
|
||||
};
|
||||
}
|
||||
export const columnFactories = {
|
||||
createNameColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Document',
|
||||
field: 'entity.metadata.name',
|
||||
highlight: true,
|
||||
render: (row: DocsTableRow) => (
|
||||
<SubvalueCell
|
||||
value={
|
||||
<Link to={row.resolved.docsUrl}>{customTitle(row.entity)}</Link>
|
||||
}
|
||||
subvalue={row.entity.metadata.description}
|
||||
/>
|
||||
),
|
||||
};
|
||||
},
|
||||
createOwnerColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Owner',
|
||||
field: 'resolved.ownedByRelationsTitle',
|
||||
render: ({ resolved }) => (
|
||||
<EntityRefLinks
|
||||
entityRefs={resolved.ownedByRelations}
|
||||
defaultKind="group"
|
||||
/>
|
||||
),
|
||||
};
|
||||
},
|
||||
createTypeColumn(): TableColumn<DocsTableRow> {
|
||||
return {
|
||||
title: 'Type',
|
||||
field: 'entity.spec.type',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user