Chore: Remove previews crawler UI (and feature flag) (#62906)

This commit is contained in:
Ryan McKinley
2023-02-03 13:45:10 -08:00
committed by GitHub
parent 0efb84617e
commit 39116b9c11
10 changed files with 0 additions and 279 deletions

View File

@@ -2,7 +2,6 @@ import React, { useState } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { TimeZone } from '@grafana/data';
import { config } from '@grafana/runtime';
import { CollapsableSection, Field, Input, RadioButtonGroup, TagsInput } from '@grafana/ui';
import { Page } from 'app/core/components/PageNew/Page';
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
@@ -10,7 +9,6 @@ import { updateTimeZoneDashboard, updateWeekStartDashboard } from 'app/features/
import { DeleteDashboardButton } from '../DeleteDashboard/DeleteDashboardButton';
import { PreviewSettings } from './PreviewSettings';
import { TimePickerSettings } from './TimePickerSettings';
import { SettingsPageProps } from './types';
@@ -125,10 +123,6 @@ export function GeneralSettingsUnconnected({
</Field>
</div>
{config.featureToggles.dashboardPreviews && config.featureToggles.dashboardPreviewsAdmin && (
<PreviewSettings uid={dashboard.uid} />
)}
<TimePickerSettings
onTimeZoneChange={onTimeZoneChange}
onWeekStartChange={onWeekStartChange}

View File

@@ -1,102 +0,0 @@
import React, { PureComponent } from 'react';
import { Button, CollapsableSection, FileUpload } from '@grafana/ui';
import { getBackendSrv } from 'app/core/services/backend_srv';
import { getThumbnailURL } from 'app/features/search/components/SearchCard';
interface Props {
uid: string;
}
interface State {}
export class PreviewSettings extends PureComponent<Props, State> {
state: State = {};
doUpload = (evt: EventTarget & HTMLInputElement, isLight?: boolean) => {
const file = evt?.files && evt.files[0];
if (!file) {
console.log('NOPE!', evt);
return;
}
const url = getThumbnailURL(this.props.uid, isLight);
const formData = new FormData();
formData.append('file', file);
fetch(url, {
method: 'POST',
body: formData,
})
.then((response) => response.json())
.then((result) => {
console.log('Success:', result);
location.reload(); //HACK
})
.catch((error) => {
console.error('Error:', error);
});
};
markAsStale = (isLight: boolean) => async () => {
return getBackendSrv().put(getThumbnailURL(this.props.uid, isLight), { state: 'stale' });
};
render() {
const { uid } = this.props;
const imgstyle = { maxWidth: 300, maxHeight: 300 };
return (
<CollapsableSection label="Preview settings" isOpen={true}>
<div>DUMMY UI just so we have an upload button!</div>
<table cellSpacing="4">
<thead>
<tr>
<td>[DARK]</td>
<td>[LIGHT]</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<Button type="button" variant="primary" onClick={this.markAsStale(false)} fill="outline">
Mark as stale
</Button>
</td>
<td>
<Button type="button" variant="primary" onClick={this.markAsStale(true)} fill="outline">
Mark as stale
</Button>
</td>
</tr>
<tr>
<td>
<img src={getThumbnailURL(uid, false)} alt="Preview of dashboard in dark theme" style={imgstyle} />
</td>
<td>
<img src={getThumbnailURL(uid, true)} alt="Preview of dashboard in light theme" style={imgstyle} />
</td>
</tr>
<tr>
<td>
<FileUpload
accept="image/png, image/webp"
onFileUpload={({ currentTarget }) => this.doUpload(currentTarget, false)}
>
Upload dark
</FileUpload>
</td>
<td>
<FileUpload
accept="image/png, image/webp"
onFileUpload={({ currentTarget }) => this.doUpload(currentTarget, true)}
>
Upload light
</FileUpload>
</td>
</tr>
</tbody>
</table>
</CollapsableSection>
);
}
}