2022-07-16 23:28:13 +05:30
|
|
|
import { apolloProvider } from '~/editor/components/source_editor_toolbar_graphql';
|
|
|
|
import getToolbarItemsQuery from '~/editor/graphql/get_items.query.graphql';
|
2022-06-21 17:19:12 +05:30
|
|
|
|
|
|
|
export const buildButton = (id = 'foo-bar-btn', options = {}) => {
|
|
|
|
return {
|
|
|
|
__typename: 'Item',
|
|
|
|
id,
|
|
|
|
label: options.label || 'Foo Bar Button',
|
2022-07-16 23:28:13 +05:30
|
|
|
icon: options.icon || 'check',
|
2022-06-21 17:19:12 +05:30
|
|
|
selected: options.selected || false,
|
2023-05-27 22:25:52 +05:30
|
|
|
group: options.group,
|
2022-07-16 23:28:13 +05:30
|
|
|
onClick: options.onClick || (() => {}),
|
|
|
|
category: options.category || 'primary',
|
|
|
|
selectedLabel: options.selectedLabel || 'smth',
|
2022-06-21 17:19:12 +05:30
|
|
|
};
|
|
|
|
};
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
export const warmUpCacheWithItems = (items = []) => {
|
|
|
|
apolloProvider.defaultClient.cache.writeQuery({
|
|
|
|
query: getToolbarItemsQuery,
|
|
|
|
data: {
|
|
|
|
items: {
|
|
|
|
nodes: items,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|