Skip to content

Commit

Permalink
feat(dashboard): Add thumbnails to dashboard edit draggable chart list (
Browse files Browse the repository at this point in the history
#20528)

* Add chart thumbnails to dashboard edit draggable charts.

* Reorganize hierarchy and add tests.

* Incorporate review suggestions.

* Update design and add tooltips.

* Fix missing thumbnails.

* Fix tests.

* Fix moving viz type label.

* Convert AddSliceCard to TS, update hierarchy.
  • Loading branch information
codyml authored Jul 28, 2022
1 parent fe91974 commit d50784d
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 149 deletions.
2 changes: 2 additions & 0 deletions superset-frontend/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function fetchSlices(
'id',
'params',
'slice_name',
'thumbnail_url',
'url',
'viz_type',
],
Expand Down Expand Up @@ -114,6 +115,7 @@ export function fetchSlices(
viz_type: slice.viz_type,
modified: slice.changed_on_delta_humanized,
changed_on_humanized: slice.changed_on_delta_humanized,
thumbnail_url: slice.thumbnail_url,
};
});

Expand Down
148 changes: 0 additions & 148 deletions superset-frontend/src/dashboard/components/AddSliceCard.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { FeatureFlag } from '@superset-ui/core';
import { act, render, screen } from 'spec/helpers/testing-library';
import AddSliceCard from '.';

jest.mock('src/components/DynamicPlugins', () => ({
usePluginContext: () => ({
mountedPluginMetadata: { table: { name: 'Table' } },
}),
}));

const mockedProps = {
visType: 'table',
sliceName: '-',
};

declare const global: {
featureFlags: Record<string, boolean>;
};

test('do not render thumbnail if feature flag is not set', async () => {
global.featureFlags = {
[FeatureFlag.THUMBNAILS]: false,
};

await act(async () => {
render(<AddSliceCard {...mockedProps} />);
});

expect(screen.queryByTestId('thumbnail')).not.toBeInTheDocument();
});

test('render thumbnail if feature flag is set', async () => {
global.featureFlags = {
[FeatureFlag.THUMBNAILS]: true,
};

await act(async () => {
render(<AddSliceCard {...mockedProps} />);
});

expect(screen.queryByTestId('thumbnail')).toBeInTheDocument();
});
Loading

0 comments on commit d50784d

Please sign in to comment.