@grafana/data#PluginMetaInfo TypeScript Examples

The following examples show how to use @grafana/data#PluginMetaInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: reducers.test.ts    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
mockPlugin = () =>
  ({
    defaultNavUrl: 'defaultNavUrl',
    enabled: true,
    hasUpdate: true,
    id: 'id',
    info: {} as PluginMetaInfo,
    latestVersion: 'latestVersion',
    name: 'name',
    pinned: true,
    type: PluginType.datasource,
    module: 'path/to/module',
  } as PluginMeta)
Example #2
Source File: PluginPage.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
renderSidebarLinks(info: PluginMetaInfo) {
    if (!info.links || !info.links.length) {
      return null;
    }

    return (
      <section className="page-sidebar-section">
        <h4>Links</h4>
        <ul className="ui-list">
          {info.links.map(link => {
            return (
              <li key={link.url}>
                <a href={link.url} className="external-link" target="_blank" rel="noopener">
                  {link.name}
                </a>
              </li>
            );
          })}
        </ul>
      </section>
    );
  }
Example #3
Source File: reducers.test.ts    From grafana-chinese with Apache License 2.0 4 votes vote down vote up
describe('pluginsReducer', () => {
  describe('when pluginsLoaded is dispatched', () => {
    it('then state should be correct', () => {
      reducerTester<PluginsState>()
        .givenReducer(pluginsReducer, { ...initialState })
        .whenActionIsDispatched(
          pluginsLoaded([
            {
              id: 'some-id',
              baseUrl: 'some-url',
              module: 'some module',
              name: 'Some Plugin',
              type: PluginType.app,
              info: {} as PluginMetaInfo,
            },
          ])
        )
        .thenStateShouldEqual({
          ...initialState,
          hasFetched: true,
          plugins: [
            {
              baseUrl: 'some-url',
              id: 'some-id',
              info: {} as PluginMetaInfo,
              module: 'some module',
              name: 'Some Plugin',
              type: PluginType.app,
            },
          ],
        });
    });
  });

  describe('when setPluginsSearchQuery is dispatched', () => {
    it('then state should be correct', () => {
      reducerTester<PluginsState>()
        .givenReducer(pluginsReducer, { ...initialState })
        .whenActionIsDispatched(setPluginsSearchQuery('A query'))
        .thenStateShouldEqual({
          ...initialState,
          searchQuery: 'A query',
        });
    });
  });

  describe('when setPluginsLayoutMode is dispatched', () => {
    it('then state should be correct', () => {
      reducerTester<PluginsState>()
        .givenReducer(pluginsReducer, { ...initialState })
        .whenActionIsDispatched(setPluginsLayoutMode(LayoutModes.List))
        .thenStateShouldEqual({
          ...initialState,
          layoutMode: LayoutModes.List,
        });
    });
  });

  describe('when pluginDashboardsLoad is dispatched', () => {
    it('then state should be correct', () => {
      reducerTester<PluginsState>()
        .givenReducer(pluginsReducer, {
          ...initialState,
          dashboards: [
            {
              dashboardId: 1,
              title: 'Some Dash',
              description: 'Some Desc',
              folderId: 2,
              imported: false,
              importedRevision: 1,
              importedUri: 'some-uri',
              importedUrl: 'some-url',
              path: 'some/path',
              pluginId: 'some-plugin-id',
              removed: false,
              revision: 22,
              slug: 'someSlug',
            },
          ],
        })
        .whenActionIsDispatched(pluginDashboardsLoad())
        .thenStateShouldEqual({
          ...initialState,
          dashboards: [],
          isLoadingPluginDashboards: true,
        });
    });
  });

  describe('when pluginDashboardsLoad is dispatched', () => {
    it('then state should be correct', () => {
      reducerTester<PluginsState>()
        .givenReducer(pluginsReducer, { ...initialState, isLoadingPluginDashboards: true })
        .whenActionIsDispatched(
          pluginDashboardsLoaded([
            {
              dashboardId: 1,
              title: 'Some Dash',
              description: 'Some Desc',
              folderId: 2,
              imported: false,
              importedRevision: 1,
              importedUri: 'some-uri',
              importedUrl: 'some-url',
              path: 'some/path',
              pluginId: 'some-plugin-id',
              removed: false,
              revision: 22,
              slug: 'someSlug',
            },
          ])
        )
        .thenStateShouldEqual({
          ...initialState,
          dashboards: [
            {
              dashboardId: 1,
              title: 'Some Dash',
              description: 'Some Desc',
              folderId: 2,
              imported: false,
              importedRevision: 1,
              importedUri: 'some-uri',
              importedUrl: 'some-url',
              path: 'some/path',
              pluginId: 'some-plugin-id',
              removed: false,
              revision: 22,
              slug: 'someSlug',
            },
          ],
          isLoadingPluginDashboards: false,
        });
    });
  });
});