mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
remove table list view storybook (#163052)
## Summary Closes https://github.com/elastic/kibana/issues/154139 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
bad10cf640
commit
509f151f02
4 changed files with 0 additions and 158 deletions
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
const defaultConfig = require('@kbn/storybook').defaultConfig;
|
||||
|
||||
module.exports = {
|
||||
...defaultConfig,
|
||||
stories: ['../**/*.stories.tsx'],
|
||||
reactOptions: {
|
||||
strictMode: true,
|
||||
},
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
const { addons } = require('@storybook/addons');
|
||||
const { create } = require('@storybook/theming');
|
||||
const { PANEL_ID } = require('@storybook/addon-actions');
|
||||
|
||||
addons.setConfig({
|
||||
theme: create({
|
||||
base: 'light',
|
||||
brandTitle: 'Content Management Storybook',
|
||||
}),
|
||||
showPanel: () => true,
|
||||
selectedPanel: PANEL_ID,
|
||||
});
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Chance from 'chance';
|
||||
import moment from 'moment';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
import {
|
||||
TableListViewProvider,
|
||||
UserContentCommonSchema,
|
||||
} from '@kbn/content-management-table-list-view-table';
|
||||
import {
|
||||
Params,
|
||||
getStoryArgTypes,
|
||||
getStoryServices,
|
||||
} from '@kbn/content-management-table-list-view-table/src/mocks';
|
||||
import { TableListView as Component } from './table_list_view';
|
||||
|
||||
import mdx from '../README.mdx';
|
||||
|
||||
const chance = new Chance();
|
||||
|
||||
export default {
|
||||
title: 'Table list view',
|
||||
description: 'A table list to display user content saved objects',
|
||||
parameters: {
|
||||
docs: {
|
||||
page: mdx,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const createMockItems = (total: number): UserContentCommonSchema[] => {
|
||||
return [...Array(total)].map((_, i) => {
|
||||
const type = itemTypes[Math.floor(Math.random() * 4)];
|
||||
|
||||
return {
|
||||
id: i.toString(),
|
||||
type,
|
||||
references: [],
|
||||
updatedAt: moment().subtract(i, 'day').format('YYYY-MM-DDTHH:mm:ss'),
|
||||
attributes: {
|
||||
title: chance.sentence({ words: 5 }),
|
||||
description: `Description of item ${i}`,
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const argTypes = getStoryArgTypes();
|
||||
const itemTypes = ['foo', 'bar', 'baz', 'elastic'];
|
||||
const mockItems: UserContentCommonSchema[] = createMockItems(500);
|
||||
|
||||
export const ConnectedComponent = (params: Params) => {
|
||||
const findItems = (searchQuery: string) => {
|
||||
const hits = mockItems
|
||||
.filter((_, i) => i < params.numberOfItemsToRender)
|
||||
.filter((item) => {
|
||||
return (
|
||||
item.attributes.title.includes(searchQuery) ||
|
||||
item.attributes.description?.includes(searchQuery)
|
||||
);
|
||||
});
|
||||
|
||||
return Promise.resolve({
|
||||
total: hits.length,
|
||||
hits,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<TableListViewProvider {...getStoryServices(params, action)}>
|
||||
<Component
|
||||
// Added key to force a refresh of the component state
|
||||
key={`${params.initialFilter}-${params.initialPageSize}`}
|
||||
findItems={findItems}
|
||||
getDetailViewLink={() => 'http://elastic.co'}
|
||||
createItem={
|
||||
params.canCreateItem
|
||||
? () => {
|
||||
action('Create item')();
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
editItem={
|
||||
params.canEditItem
|
||||
? ({ attributes: { title } }) => {
|
||||
action('Edit item')(title);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
deleteItems={
|
||||
params.canDeleteItem
|
||||
? async (items) => {
|
||||
action('Delete item(s)')(
|
||||
items.map(({ attributes: { title } }) => title).join(', ')
|
||||
);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
customTableColumn={
|
||||
params.showCustomColumn
|
||||
? {
|
||||
field: 'attributes.type',
|
||||
name: 'Type',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
{...params}
|
||||
/>
|
||||
</TableListViewProvider>
|
||||
);
|
||||
};
|
||||
|
||||
ConnectedComponent.argTypes = argTypes;
|
|
@ -20,7 +20,6 @@ export const storybookAliases = {
|
|||
coloring: 'packages/kbn-coloring/.storybook',
|
||||
language_documentation_popover: 'packages/kbn-language-documentation-popover/.storybook',
|
||||
chart_icons: 'packages/kbn-chart-icons/.storybook',
|
||||
content_management: 'packages/content-management/.storybook',
|
||||
content_management_examples: 'examples/content_management_examples/.storybook',
|
||||
controls: 'src/plugins/controls/storybook',
|
||||
custom_integrations: 'src/plugins/custom_integrations/storybook',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue