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

Expose more apis for KubeObjectListLayout usage #1194

Merged
merged 1 commit into from
Nov 2, 2020

Conversation

jakolehm
Copy link
Contributor

@jakolehm jakolehm commented Nov 2, 2020

Usage example:

import { LensRendererExtension, Component, K8sApi } from "@k8slens/extensions";

export class PodsStore extends K8sApi.KubeObjectStore<K8sApi.Pod> {
  api = K8sApi.podsApi;
}

enum sortBy {
  name = "name"
}

export const podsStore = new PodsStore();
K8sApi.apiManager.registerStore(K8sApi.podsApi, podsStore);

export class ExamplePage extends React.Component<{ extension: LensRendererExtension }> {

  async componentDidMount() {
    await podsStore.loadAll()
  }

  render() {
    return (
      <Component.KubeObjectListLayout
        className="Pods" store={podsStore}
        sortingCallbacks={{
          [sortBy.name]: (pod: K8sApi.Pod) => pod.getName()
        }}
        searchFilters={[
          (pod: K8sApi.Pod) => pod.getSearchFields(),
          (pod: K8sApi.Pod) => pod.getStatusMessage(),
        ]}
        renderHeaderTitle="Pods"
        renderTableHeader={[
          { title: "Name", className: "name", sortBy: sortBy.name },
        ]}
        renderTableContents={(pod: K8sApi.Pod) => [
          pod.getName()
        ]}
      />
    )
  }
}

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm added bug Something isn't working area/extension Something to related to the extension api labels Nov 2, 2020
@jakolehm jakolehm added this to the 4.0.0 milestone Nov 2, 2020
@jakolehm jakolehm requested a review from a team November 2, 2020 13:48
@jakolehm jakolehm merged commit 7a6f644 into master Nov 2, 2020
@jakolehm jakolehm deleted the extensions/fix-kube-object-list-layout-usage branch November 2, 2020 17:28
@jakolehm jakolehm mentioned this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants