Skip to content

Commit

Permalink
[SIP-36] Migrate setupApp.js to setupApp.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
erik_ritter committed Feb 20, 2020
1 parent 74423e5 commit 1dfacb7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
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');
}

0 comments on commit 1dfacb7

Please sign in to comment.