Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
Disable/Hide related UI to leave only CSV report (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongnansu authored Oct 27, 2020
1 parent 9efd53a commit e304841
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function locationHashChanged() {
return;
}
const menuItem = document.createElement('div');
menuItem.innerHTML = getMenuItem('Reporting');
menuItem.innerHTML = getMenuItem('Reporting', !isDiscover());
navMenu[0].appendChild(menuItem.children[0]);
} catch (e) {
console.log(e);
Expand Down
41 changes: 22 additions & 19 deletions kibana-reports/public/components/context_menu/context_menu_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@
* permissions and limitations under the License.
*/

export const getMenuItem = (name) => {
export const getMenuItem = (name, isHidden) => {
const hidden = isHidden ? `style="display: none"` : '';
return `
<div class="euiFlexItem euiFlexItem--flexGrowZero">
<div ${hidden} class="euiFlexItem euiFlexItem--flexGrowZero">
<button class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall" type="button" id="downloadReport">
<span class="euiButtonEmpty__content"><span class="euiButtonEmpty__text">${name}</span>
</span>
</button>
</div>
`
}
`;
};

export const popoverMenu = () => {
return `
return `
<div>
<div data-focus-guard="true" tabindex="-1" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;">
</div>
<div data-focus-guard="true" tabindex="-1" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;">
</div>
<div data-focus-lock-disabled="disabled">
<div data-focus-lock-disabled="disabled" hidden>
<div class="euiPanel euiPopover__panel euiPopover__panel--bottom euiPopover__panel-isOpen euiPopover__panel-withTitle" aria-live="assertive" role="dialog" aria-modal="true" aria-describedby="i199c7fc0-f92e-11ea-a40d-395bfe9dc89a" style="top: 97px; left: 255.583px; z-index: 2000;" id="reportPopover">
<div class="euiPopover__panelArrow euiPopover__panelArrow--bottom" style="left: 15.9417px; top: 0px;">
</div>
Expand Down Expand Up @@ -95,16 +96,18 @@ export const popoverMenu = () => {
</div>
</div>
<div data-focus-guard="true" tabindex="-1" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"></div>
`
}
`;
};

export const popoverMenuDiscover = (savedSearchAvailable) => {
const buttonClass = savedSearchAvailable ? 'euiContextMenuItem' : 'euiContextMenuItem euiContextMenuItem-isDisabled';
const buttonClass = savedSearchAvailable
? 'euiContextMenuItem'
: 'euiContextMenuItem euiContextMenuItem-isDisabled';
const button = savedSearchAvailable ? 'button' : 'button disabled';
const popoverHeight = savedSearchAvailable ? '354px' : '322px';
const message = savedSearchAvailable ?
`Files can take a minute or two to generate depending on the size of your source data.` :
`Save this search to enable CSV reports.`;
const message = savedSearchAvailable
? `Files can take a minute or two to generate depending on the size of your source data.`
: `Save this search to enable CSV reports.`;

return `
<div>
Expand Down Expand Up @@ -176,7 +179,7 @@ export const popoverMenuDiscover = (savedSearchAvailable) => {
</div>
</div>
<div data-focus-guard="true" tabindex="-1" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"></div>
`
`;
};

export const reportGenerationSuccess = () => {
Expand Down Expand Up @@ -205,8 +208,8 @@ export const reportGenerationSuccess = () => {
href="opendistro_kibana_reports#/" rel="noreferrer">Reports</a>.</p>
</div>
</div>
`
}
`;
};

export const reportGenerationFailure = () => {
return `
Expand All @@ -232,8 +235,8 @@ export const reportGenerationFailure = () => {
<p>There was an error generating this report</p>
</div>
</div>
`
}
`;
};

export const reportGenerationInProgressModal = () => {
return `
Expand Down Expand Up @@ -274,5 +277,5 @@ export const reportGenerationInProgressModal = () => {
</div>
<div data-focus-guard="true" tabindex="0" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"></div>
</div>
`
}
`;
};
1 change: 1 addition & 0 deletions kibana-reports/public/components/main/main_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const addReportsTableContent = (data) => {
url: `${location.host}${report.query_url}`,
format: reportParams.core_params.report_format,
};
console.log(reportsTableEntry.url);
reportsTableItems.push(reportsTableEntry);
}
return reportsTableItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export function ReportDefinitionDetails(props) {
/>
<EuiFlexItem />
</EuiFlexGroup>
<EuiSpacer />
{/* <EuiSpacer />
<EuiFlexGroup>
<ReportDetailsComponent
reportDetailsComponentTitle={'Report header'}
Expand All @@ -564,15 +564,15 @@ export function ReportDefinitionDetails(props) {
/>
<EuiFlexItem />
<EuiFlexItem />
</EuiFlexGroup>
</EuiFlexGroup> */}
<EuiSpacer />
<EuiTitle>
<h3>Report trigger</h3>
</EuiTitle>
<EuiSpacer />
{triggerSection}
<EuiSpacer />
<EuiTitle>
{/* <EuiTitle>
<h3>Notification settings</h3>
</EuiTitle>
<EuiSpacer />
Expand All @@ -596,7 +596,7 @@ export function ReportDefinitionDetails(props) {
)}
/>
<ReportDetailsComponent />
</EuiFlexGroup>
</EuiFlexGroup> */}
</EuiPageContent>
<EuiGlobalToastList
toasts={toasts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export function ReportDetails(props) {
reportDetailsComponentContent={reportDetails['state']}
/>
</EuiFlexGroup>
<EuiSpacer />
{/* <EuiSpacer />
<EuiFlexGroup>
<ReportDetailsComponent
reportDetailsComponentTitle={'Report header'}
Expand All @@ -327,7 +327,7 @@ export function ReportDetails(props) {
/>
<ReportDetailsComponent />
<ReportDetailsComponent />
</EuiFlexGroup>
</EuiFlexGroup> */}
<EuiSpacer />
<EuiTitle>
<h3>Report trigger</h3>
Expand All @@ -348,7 +348,7 @@ export function ReportDetails(props) {
/>
<ReportDetailsComponent />
</EuiFlexGroup>
<EuiSpacer />
{/* <EuiSpacer />
<EuiTitle>
<h3>Notification settings</h3>
</EuiTitle>
Expand All @@ -371,7 +371,7 @@ export function ReportDetails(props) {
)}
/>
<ReportDetailsComponent />
</EuiFlexGroup>
</EuiFlexGroup> */}
</EuiPageContent>
<EuiGlobalToastList
toasts={toasts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function ReportDelivery(props: ReportDeliveryProps) {
}, []);

return (
<EuiPageContent panelPaddingSize={'l'}>
<EuiPageContent panelPaddingSize={'l'} hidden>
<EuiPageHeader>
<EuiTitle>
<h2>Notification settings</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export function ReportSettings(props: ReportSettingProps) {

const [reportName, setReportName] = useState('');
const [reportDescription, setReportDescription] = useState('');
const [reportSourceId, setReportSourceId] = useState('dashboardReportSource');
const [reportSourceId, setReportSourceId] = useState(
REPORT_SOURCE_RADIOS[0].id
);

const [dashboardSourceSelect, setDashboardSourceSelect] = useState('');
const [dashboards, setDashboards] = useState([]);
Expand All @@ -94,7 +96,7 @@ export function ReportSettings(props: ReportSettingProps) {
const [savedSearchSourceSelect, setSavedSearchSourceSelect] = useState('');
const [savedSearches, setSavedSearches] = useState([]);

const [fileFormat, setFileFormat] = useState('pdf');
const [fileFormat, setFileFormat] = useState('csv');

const handleDashboards = (e) => {
setDashboards(e);
Expand Down Expand Up @@ -516,37 +518,31 @@ export function ReportSettings(props: ReportSettingProps) {
savedSearch: [],
};
reportDefinitionRequest.report_params.core_params.report_format = fileFormat;
await httpClientProps
.get('../api/reporting/getReportSource/dashboard')
.then(async (response) => {
let dashboardOptions = getDashboardOptions(response['hits']['hits']);
reportSourceOptions.dashboard = dashboardOptions;
handleDashboards(dashboardOptions);
if (!edit) {
setDashboardSourceSelect(dashboardOptions[0].value);
reportDefinitionRequest.report_params.report_source = 'Dashboard';
reportDefinitionRequest['report_params']['core_params']['base_url'] =
getDashboardBaseUrlCreate(edit, editDefinitionId, false) +
response['hits']['hits'][0]['_id'].substring(10);
}
})
.catch((error) => {
console.log('error when fetching dashboards:', error);
});

await httpClientProps
.get('../api/reporting/getReportSource/visualization')
.then(async (response) => {
let visualizationOptions = getVisualizationOptions(
response['hits']['hits']
);
reportSourceOptions.visualizations = visualizationOptions;
await handleVisualizations(visualizationOptions);
await setVisualizationSourceSelect(visualizationOptions[0].value);
})
.catch((error) => {
console.log('error when fetching visualizations:', error);
});
// await httpClientProps
// .get('../api/reporting/getReportSource/dashboard')
// .then(async (response) => {
// let dashboardOptions = getDashboardOptions(response['hits']['hits']);
// reportSourceOptions.dashboard = dashboardOptions;
// handleDashboards(dashboardOptions);

// })
// .catch((error) => {
// console.log('error when fetching dashboards:', error);
// });

// await httpClientProps
// .get('../api/reporting/getReportSource/visualization')
// .then(async (response) => {
// let visualizationOptions = getVisualizationOptions(
// response['hits']['hits']
// );
// reportSourceOptions.visualizations = visualizationOptions;
// await handleVisualizations(visualizationOptions);
// await setVisualizationSourceSelect(visualizationOptions[0].value);
// })
// .catch((error) => {
// console.log('error when fetching visualizations:', error);
// });

await httpClientProps
.get('../api/reporting/getReportSource/search')
Expand All @@ -556,7 +552,16 @@ export function ReportSettings(props: ReportSettingProps) {
);
reportSourceOptions.savedSearch = savedSearchOptions;
await handleSavedSearches(savedSearchOptions);
await setSavedSearchSourceSelect(savedSearchOptions[0].value);

if (!edit) {
setSavedSearchSourceSelect(savedSearchOptions[0].value);
reportDefinitionRequest.report_params.core_params.saved_search_id =
savedSearchOptions[0].value;
reportDefinitionRequest.report_params.report_source = 'Saved search';
reportDefinitionRequest['report_params']['core_params']['base_url'] =
getSavedSearchBaseUrlCreate(edit, false) +
response['hits']['hits'][0]['_id'].substring(7);
}
})
.catch((error) => {
console.log('error when fetching saved searches:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
*/

export const REPORT_SOURCE_RADIOS = [
{
id: 'dashboardReportSource',
label: 'Dashboard',
},
{
id: 'visualizationReportSource',
label: 'Visualization',
},
// {
// id: 'dashboardReportSource',
// label: 'Dashboard',
// },
// {
// id: 'visualizationReportSource',
// label: 'Visualization',
// },
{
id: 'savedSearchReportSource',
label: 'Saved search',
Expand Down

0 comments on commit e304841

Please sign in to comment.