From 4a28f3f5539ba98aa1a6d0052ccf443104e7a6fa Mon Sep 17 00:00:00 2001 From: amitkumarsingh1991 Date: Tue, 14 May 2019 18:36:32 +0530 Subject: [PATCH 1/4] enhance render method --- ClusteredMapView.js | 137 +++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 73 deletions(-) diff --git a/ClusteredMapView.js b/ClusteredMapView.js index 9a9334b..65f49f0 100644 --- a/ClusteredMapView.js +++ b/ClusteredMapView.js @@ -1,111 +1,103 @@ -'use-strict' +"use-strict"; // base libs -import PropTypes from 'prop-types' -import React, { PureComponent } from 'react' -import { - Platform, - Dimensions, - LayoutAnimation -} from 'react-native' +import PropTypes from "prop-types"; +import React, { PureComponent } from "react"; +import { Platform, Dimensions, LayoutAnimation } from "react-native"; // map-related libs -import MapView from 'react-native-maps' -import SuperCluster from 'supercluster' -import GeoViewport from '@mapbox/geo-viewport' +import MapView from "react-native-maps"; +import SuperCluster from "supercluster"; +import GeoViewport from "@mapbox/geo-viewport"; // components / views -import ClusterMarker from './ClusterMarker' +import ClusterMarker from "./ClusterMarker"; // libs / utils -import { - regionToBoundingBox, - itemToGeoJSONFeature -} from './util' +import { regionToBoundingBox, itemToGeoJSONFeature } from "./util"; export default class ClusteredMapView extends PureComponent { - constructor(props) { - super(props) + super(props); this.state = { data: [], // helds renderable clusters and markers - region: props.region || props.initialRegion, // helds current map region - } + region: props.region || props.initialRegion // helds current map region + }; - this.isAndroid = Platform.OS === 'android' - this.dimensions = [props.width, props.height] + this.isAndroid = Platform.OS === "android"; + this.dimensions = [props.width, props.height]; - this.mapRef = this.mapRef.bind(this) - this.onClusterPress = this.onClusterPress.bind(this) - this.onRegionChangeComplete = this.onRegionChangeComplete.bind(this) + this.mapRef = this.mapRef.bind(this); + this.onClusterPress = this.onClusterPress.bind(this); + this.onRegionChangeComplete = this.onRegionChangeComplete.bind(this); } componentDidMount() { - this.clusterize(this.props.data) + this.clusterize(this.props.data); } componentWillReceiveProps(nextProps) { - if (this.props.data !== nextProps.data) - this.clusterize(nextProps.data) + if (this.props.data !== nextProps.data) this.clusterize(nextProps.data); } componentWillUpdate(nextProps, nextState) { if (!this.isAndroid && this.props.animateClusters && this.clustersChanged(nextState)) - LayoutAnimation.configureNext(this.props.layoutAnimationConf) + LayoutAnimation.configureNext(this.props.layoutAnimationConf); } mapRef(ref) { - this.mapview = ref + this.mapview = ref; } getMapRef() { - return this.mapview + return this.mapview; } getClusteringEngine() { - return this.index + return this.index; } clusterize(dataset) { - this.index = new SuperCluster({ // eslint-disable-line new-cap + this.index = new SuperCluster({ + // eslint-disable-line new-cap extent: this.props.extent, minZoom: this.props.minZoom, maxZoom: this.props.maxZoom, - radius: this.props.radius || (this.dimensions[0] * .045), // 4.5% of screen width - }) + radius: this.props.radius || this.dimensions[0] * 0.045 // 4.5% of screen width + }); // get formatted GeoPoints for cluster - const rawData = dataset.map(item => itemToGeoJSONFeature(item, this.props.accessor)) + const rawData = dataset.map(item => itemToGeoJSONFeature(item, this.props.accessor)); // load geopoints into SuperCluster - this.index.load(rawData) + this.index.load(rawData); - const data = this.getClusters(this.state.region) - this.setState({ data }) + const data = this.getClusters(this.state.region); + this.setState({ data }); } clustersChanged(nextState) { - return this.state.data.length !== nextState.data.length + return this.state.data.length !== nextState.data.length; } onRegionChangeComplete(region) { - let data = this.getClusters(region) + let data = this.getClusters(region); this.setState({ region, data }, () => { - this.props.onRegionChangeComplete && this.props.onRegionChangeComplete(region, data) - }) + this.props.onRegionChangeComplete && this.props.onRegionChangeComplete(region, data); + }); } getClusters(region) { const bbox = regionToBoundingBox(region), - viewport = (region.longitudeDelta) >= 40 ? { zoom: this.props.minZoom } : GeoViewport.viewport(bbox, this.dimensions) + viewport = + region.longitudeDelta >= 40 ? { zoom: this.props.minZoom } : GeoViewport.viewport(bbox, this.dimensions); - return this.index.getClusters(bbox, viewport.zoom) + return this.index.getClusters(bbox, viewport.zoom); } onClusterPress(cluster) { - // cluster press behavior might be extremely custom. if (!this.props.preserveClusterPressBehavior) { - this.props.onClusterPress && this.props.onClusterPress(cluster.properties.cluster_id) - return + this.props.onClusterPress && this.props.onClusterPress(cluster.properties.cluster_id); + return; } // ////////////////////////////////////////////////////////////////////////////////// @@ -113,43 +105,42 @@ export default class ClusteredMapView extends PureComponent { // ////////////////////////////////////////////////////////////////////////////////// // get cluster children const children = this.index.getLeaves(cluster.properties.cluster_id, this.props.clusterPressMaxChildren), - markers = children.map(c => c.properties.item) + markers = children.map(c => c.properties.item); // fit right around them, considering edge padding - this.mapview.fitToCoordinates(markers.map(m => m.location), { edgePadding: this.props.edgePadding }) + this.mapview.fitToCoordinates(markers.map(m => m.location), { edgePadding: this.props.edgePadding }); - this.props.onClusterPress && this.props.onClusterPress(cluster.properties.cluster_id, markers) + this.props.onClusterPress && this.props.onClusterPress(cluster.properties.cluster_id, markers); } render() { - const { style, ...props } = this.props + const { style, ...props } = this.props; return ( - - { - this.props.clusteringEnabled && this.state.data.map((d) => { + + {this.props.clusteringEnabled && + this.state.data.map(d => { if (d.properties.point_count === 0) - return this.props.renderMarker(d.properties.item) + return this.props.renderMarker( + d.properties.item, + this.state.data.map(item => { + return !item.properties.point_count && item.properties.item.data; + }) + ); return ( - ) - }) - } - { - !this.props.clusteringEnabled && this.props.data.map(d => this.props.renderMarker(d)) - } + key={`cluster-${d.properties.cluster_id}`} + /> + ); + })} + {!this.props.clusteringEnabled && this.props.data.map(d => this.props.renderMarker(d))} {this.props.children} - ) + ); } } @@ -157,16 +148,16 @@ ClusteredMapView.defaultProps = { minZoom: 1, maxZoom: 16, extent: 512, - accessor: 'location', + accessor: "location", animateClusters: true, clusteringEnabled: true, clusterPressMaxChildren: 100, preserveClusterPressBehavior: true, - width: Dimensions.get('window').width, - height: Dimensions.get('window').height, + width: Dimensions.get("window").width, + height: Dimensions.get("window").height, layoutAnimationConf: LayoutAnimation.Presets.spring, edgePadding: { top: 10, left: 10, right: 10, bottom: 10 } -} +}; ClusteredMapView.propTypes = { ...MapView.propTypes, @@ -196,4 +187,4 @@ ClusteredMapView.propTypes = { // string // mutiple accessor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]) -} +}; From 3e206224467e75fb4a8766c291a58c9bff12dcee Mon Sep 17 00:00:00 2001 From: amitkumarsingh1991 Date: Tue, 14 May 2019 19:03:38 +0530 Subject: [PATCH 2/4] with remove gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4926076..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.vscode/ -node_modules/ \ No newline at end of file From 93a092822dc22646d74bfac08d374d4b0af3077a Mon Sep 17 00:00:00 2001 From: afathi-noon <34736044+afathi-noon@users.noreply.github.com> Date: Mon, 21 Dec 2020 21:54:22 +0400 Subject: [PATCH 3/4] Pushing secrets scanner to all repositories --- .github/workflows/secrets-shield.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/secrets-shield.yml diff --git a/.github/workflows/secrets-shield.yml b/.github/workflows/secrets-shield.yml new file mode 100644 index 0000000..65002ea --- /dev/null +++ b/.github/workflows/secrets-shield.yml @@ -0,0 +1,17 @@ +name: Gitrack Shield Action + +on: [pull_request] + +jobs: + secrets: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@master + - name: Setup Gitrack Shield + run: | + curl -sfL https://storage.googleapis.com/security-tests-8a473ab3b5/gitrack-shield-scanner.sh | sh - + + - name: Running Gitrack Shield (Secrets Scanning) + run: | + python3 gitrack-shield/gitrack-shield.py ${{ github.workspace }} From 2745b0801b8383580eb3f90b618090f170aa3dd2 Mon Sep 17 00:00:00 2001 From: afathi-noon <34736044+afathi-noon@users.noreply.github.com> Date: Sun, 27 Dec 2020 03:50:05 +0400 Subject: [PATCH 4/4] Delete secrets-shield.yml --- .github/workflows/secrets-shield.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/secrets-shield.yml diff --git a/.github/workflows/secrets-shield.yml b/.github/workflows/secrets-shield.yml deleted file mode 100644 index 65002ea..0000000 --- a/.github/workflows/secrets-shield.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Gitrack Shield Action - -on: [pull_request] - -jobs: - secrets: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@master - - name: Setup Gitrack Shield - run: | - curl -sfL https://storage.googleapis.com/security-tests-8a473ab3b5/gitrack-shield-scanner.sh | sh - - - - name: Running Gitrack Shield (Secrets Scanning) - run: | - python3 gitrack-shield/gitrack-shield.py ${{ github.workspace }}