Skip to content

question: best practice for generating LazyActionMenu list actions #12244

@mikaello

Description

@mikaello

I have a CRD that currently only have a details page, from where I can open an actions menu with edit and delete actions. Example:

image

I have created a dynamic plugin to be able to list all of my CRDs in a project, and where I want to have the action menu for each row. It seems to me that the LazyActionMenu component is perfect fit for this, and is simple to add:

+ import LazyActionMenu from "@openshift-console/dynamic-plugin-sdk-internal";

+ const modelToRef = (model: ExtensionK8sModel) => `${model.group}~${model.version}~${model.kind}`;

  const columns: TableColumn<ApplicationK8sResource>[] = [
    { title: "Name", transforms: [sortable], sort: "metadata.name", id: "name", },
    { title: "Status", id: "status", },
+   { title: "", id: "menuActions", },
  ];

  const ApplicationRow: React.FC<RowProps<ApplicationK8sResource>> = ({ obj, activeColumnIDs, }) => {
    return (
      <>
        <TableData ...>...</TableData>
        <TableData ...>...</TableData>
+       <TableData id={columns[2].id} activeColumnIDs={activeColumnIDs}>
+         <LazyActionMenu
+           context={{ [modelToRef(applicationGvk)]: obj }}
+         />
+       </TableData>
      </>
    );
  };

This results only in an empty action menu (i.e., it found no actions):

image

That is because I need to add a console.action/resource-provider. The documentation for this is sparse, and there are no examples in the dynamic-demo-plugin. And when browsing resource providers and action creators in console/frontend/packages/console-app, I notice that some building blocks (components and helper functions) are not exposed trough your published NPM packages. For example, the modals (e.g., the delete-modal).

I then wonder if you got some examples or tip on best practices for developing (or reusing) functionality for resource-providers?

And it would be very helpful if you could publish more of the functionality/components that you use internally, e.g., the modals and reusable actions (like common-factory.ts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions