Skip to content

Commit

Permalink
Merge branch 'master' of github.com:preset-io/superset into lyndsi/sp…
Browse files Browse the repository at this point in the history
…lit-save-btn
  • Loading branch information
lyndsiWilliams committed Aug 1, 2022
2 parents a8ef2ea + 3a11856 commit 548c804
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ superset:
superset load-examples

# Install node packages
cd superset-frontend; npm install
cd superset-frontend; npm ci

update: update-py update-js

Expand Down Expand Up @@ -101,7 +101,7 @@ node-app:

build-cypress:
cd superset-frontend; npm run build-instrumented
cd superset-frontend/cypress-base; npm install
cd superset-frontend/cypress-base; npm ci

open-cypress:
if ! [ $(port) ]; then cd superset-frontend/cypress-base; CYPRESS_BASE_URL=http://localhost:9000 npm run cypress open; fi
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/installation/running-on-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ superset-worker-75b48bbcc-qrq49 1/1 Running 0 4m12s

The exact list will depend on some of your specific configuration overrides but you should generally expect:

- N `superset-xxxx-yyyy` and `superset-worker-xxxx-yyyy` pods (depending on your `replicaCount` value)
- N `superset-xxxx-yyyy` and `superset-worker-xxxx-yyyy` pods (depending on your `supersetNode.replicaCount` and `supersetWorker.replicaCount` values)
- 1 `superset-postgresql-0` depending on your postgres settings
- 1 `superset-redis-master-0` depending on your redis settings
- 1 `superset-celerybeat-xxxx-yyyy` pod if you have `supersetCeleryBeat.enabled = true` in your values overrides
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ maintainers:
- name: craig-rueda
email: [email protected]
url: https://github.com/craig-rueda
version: 0.6.6
version: 0.7.0
dependencies:
- name: postgresql
version: 11.1.22
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ metadata:
{{ toYaml .Values.supersetWorker.deploymentAnnotations | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.supersetWorker.replicaCount }}
selector:
matchLabels:
app: {{ template "superset.name" . }}-worker
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ metadata:
{{ toYaml .Values.supersetNode.deploymentAnnotations | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.supersetNode.replicaCount }}
selector:
matchLabels:
app: {{ template "superset.name" . }}
Expand Down
12 changes: 8 additions & 4 deletions helm/superset/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"type": "object",
"additionalProperties": true,
"properties": {
"replicaCount": {
"type": "integer"
},
"runAsUser": {
"type": "integer"
},
Expand Down Expand Up @@ -216,6 +213,9 @@
"type": "object",
"additionalProperties": false,
"properties": {
"replicaCount": {
"type": "integer"
},
"command": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.23.0/_definitions.json##/definitions/io.k8s.api.core.v1.Container/properties/command"
},
Expand Down Expand Up @@ -287,6 +287,7 @@
}
},
"required": [
"replicaCount",
"command",
"connections",
"env",
Expand All @@ -297,6 +298,9 @@
"type": "object",
"additionalProperties": false,
"properties": {
"replicaCount": {
"type": "integer"
},
"command": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.23.0/_definitions.json##/definitions/io.k8s.api.core.v1.Container/properties/command"
},
Expand Down Expand Up @@ -326,6 +330,7 @@
}
},
"required": [
"replicaCount",
"command",
"forceReload"
]
Expand Down Expand Up @@ -594,7 +599,6 @@
}
},
"required": [
"replicaCount",
"runAsUser",
"serviceAccount",
"bootstrapScript",
Expand Down
4 changes: 2 additions & 2 deletions helm/superset/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

# User ID directive. This user must have enough permissions to run the bootstrap script
# Runn containers as root is not recommended in production. Change this to another UID - e.g. 1000 to be more secure
runAsUser: 0
Expand Down Expand Up @@ -224,6 +222,7 @@ hostAliases: []
##
## Superset node configuration
supersetNode:
replicaCount: 1
command:
- "/bin/sh"
- "-c"
Expand Down Expand Up @@ -268,6 +267,7 @@ supersetNode:
##
## Superset worker configuration
supersetWorker:
replicaCount: 1
command:
- "/bin/sh"
- "-c"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({

setShouldOverwriteDataset(false);
setDatasetName(getDefaultDatasetName());
onHide();
};

const loadDatasetOverwriteOptions = useCallback(
Expand Down
59 changes: 59 additions & 0 deletions superset-frontend/src/components/GenericLink/GenericLink.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import { GenericLink } from './GenericLink';

test('renders', () => {
render(<GenericLink to="/explore">Link to Explore</GenericLink>, {
useRouter: true,
});
expect(screen.getByText('Link to Explore')).toBeVisible();
});

test('navigates to internal URL', () => {
render(<GenericLink to="/explore">Link to Explore</GenericLink>, {
useRouter: true,
});
const internalLink = screen.getByTestId('internal-link');
expect(internalLink).toHaveAttribute('href', '/explore');
});

test('navigates to external URL', () => {
render(
<GenericLink to="https://superset.apache.org/">
Link to external website
</GenericLink>,
{ useRouter: true },
);
const externalLink = screen.getByTestId('external-link');
expect(externalLink).toHaveAttribute('href', 'https://superset.apache.org/');
});

test('navigates to external URL without host', () => {
render(
<GenericLink to="superset.apache.org/">
Link to external website
</GenericLink>,
{ useRouter: true },
);
const externalLink = screen.getByTestId('external-link');
expect(externalLink).toHaveAttribute('href', '//superset.apache.org/');
});
52 changes: 52 additions & 0 deletions superset-frontend/src/components/GenericLink/GenericLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* 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 { Link, LinkProps } from 'react-router-dom';
import { isUrlExternal, parseUrl } from 'src/utils/urlUtils';

export const GenericLink = <S,>({
to,
component,
replace,
innerRef,
children,
...rest
}: React.PropsWithoutRef<LinkProps<S>> &
React.RefAttributes<HTMLAnchorElement>) => {
if (typeof to === 'string' && isUrlExternal(to)) {
return (
<a data-test="external-link" href={parseUrl(to)} {...rest}>
{children}
</a>
);
}
return (
<Link
data-test="internal-link"
to={to}
component={component}
replace={replace}
innerRef={innerRef}
{...rest}
>
{children}
</Link>
);
};
31 changes: 19 additions & 12 deletions superset-frontend/src/dashboard/actions/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,25 @@ export const hydrateDashboard =
if (!metadata.chart_configuration) {
metadata.chart_configuration = {};
}
if (behaviors.includes(Behavior.INTERACTIVE_CHART)) {
if (!metadata.chart_configuration[chartId]) {
metadata.chart_configuration[chartId] = {
id: chartId,
crossFilters: {
scope: {
rootPath: [DASHBOARD_ROOT_ID],
excluded: [chartId], // By default it doesn't affects itself
},
},
};
}
metadata.chart_configuration[chartId].crossFilters.chartsInScope =
getChartIdsInFilterScope(
metadata.chart_configuration[chartId].crossFilters.scope,
chartQueries,
dashboardLayout.present,
);
}
if (
behaviors.includes(Behavior.INTERACTIVE_CHART) &&
!metadata.chart_configuration[chartId]
Expand All @@ -348,21 +367,9 @@ export const hydrateDashboard =
rootPath: [DASHBOARD_ROOT_ID],
excluded: [chartId], // By default it doesn't affects itself
},
chartsInScope: Array.from(sliceIds),
},
};
}
if (
behaviors.includes(Behavior.INTERACTIVE_CHART) &&
!metadata.chart_configuration[chartId].crossFilters?.chartsInScope
) {
metadata.chart_configuration[chartId].crossFilters.chartsInScope =
getChartIdsInFilterScope(
metadata.chart_configuration[chartId].crossFilters.scope,
charts,
dashboardLayout.present,
);
}
});
}

Expand Down
54 changes: 54 additions & 0 deletions superset-frontend/src/utils/urlUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* 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 { isUrlExternal, parseUrl } from './urlUtils';

test('isUrlExternal', () => {
expect(isUrlExternal('http://google.com')).toBeTruthy();
expect(isUrlExternal('https://google.com')).toBeTruthy();
expect(isUrlExternal('//google.com')).toBeTruthy();
expect(isUrlExternal('google.com')).toBeTruthy();
expect(isUrlExternal('www.google.com')).toBeTruthy();
expect(isUrlExternal('mailto:[email protected]')).toBeTruthy();

// treat all urls starting with protocol or hostname as external
// such urls are not handled well by react-router Link component
expect(isUrlExternal('http://localhost:8888/port')).toBeTruthy();
expect(isUrlExternal('https://localhost/secure')).toBeTruthy();
expect(isUrlExternal('http://localhost/about')).toBeTruthy();
expect(isUrlExternal('HTTP://localhost/about')).toBeTruthy();
expect(isUrlExternal('//localhost/about')).toBeTruthy();
expect(isUrlExternal('localhost/about')).toBeTruthy();

expect(isUrlExternal('/about')).toBeFalsy();
expect(isUrlExternal('#anchor')).toBeFalsy();
});

test('parseUrl', () => {
expect(parseUrl('http://google.com')).toEqual('http://google.com');
expect(parseUrl('//google.com')).toEqual('//google.com');
expect(parseUrl('mailto:[email protected]')).toEqual(
'mailto:[email protected]',
);
expect(parseUrl('google.com')).toEqual('//google.com');
expect(parseUrl('www.google.com')).toEqual('//www.google.com');

expect(parseUrl('/about')).toEqual('/about');
expect(parseUrl('#anchor')).toEqual('#anchor');
});
Loading

0 comments on commit 548c804

Please sign in to comment.