Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIP-36] Migrate setupApp.js to setupApp.ts #9180

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.5.5",
"@types/jest": "^23.3.5",
"@types/jquery": "^3.3.32",
"@types/react": "^16.4.18",
"@types/react-dom": "^16.0.9",
"@types/react-table": "^7.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import $ from 'jquery';
import { SupersetClient } from '@superset-ui/connection';
import getClientErrorObject from '../utils/getClientErrorObject';

function showApiMessage(resp) {
function showApiMessage(resp: { severity?: string; message: string }) {
const template =
'<div class="alert"> ' +
'<button type="button" class="close" ' +
Expand All @@ -33,9 +33,11 @@ function showApiMessage(resp) {
.appendTo($('#alert-container'));
}

function toggleCheckbox(apiUrlPrefix, selector) {
SupersetClient.get({ endpoint: apiUrlPrefix + $(selector)[0].checked })
.then(() => {})
function toggleCheckbox(apiUrlPrefix: string, selector: string) {
SupersetClient.get({
endpoint: apiUrlPrefix + ($(selector)[0] as HTMLInputElement).checked,
})
.then(() => undefined)
.catch(response =>
getClientErrorObject(response).then(parsedResp => {
if (parsedResp && parsedResp.message) {
Expand All @@ -55,10 +57,17 @@ export default function setupApp() {
});

// for language picker dropdown
$('#language-picker a').click(function(ev) {
$('#language-picker a').click(function(
ev: JQuery.ClickEvent<
HTMLLinkElement,
null,
HTMLLinkElement,
HTMLLinkElement
>,
) {
ev.preventDefault();
SupersetClient.get({
endpoint: ev.currentTarget.getAttribute('href'),
endpoint: ev.currentTarget.href,
parseMethod: null,
}).then(() => {
location.reload();
Expand All @@ -68,7 +77,9 @@ export default function setupApp() {

// A set of hacks to allow apps to run within a FAB template
// this allows for the server side generated menus to function
// @ts-ignore
window.$ = $;
// @ts-ignore
window.jQuery = $;
require('bootstrap');
}