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

chore: add workflow that doesn't succeed until PR tasks completed #597

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Implements _Jira issue link_

Relates to _maps-app PR_

---

### Description

_text_

---

### TODO

- [ ] Tests added
- [ ] PRs for Maps app created
- [ ] _todo_
14 changes: 14 additions & 0 deletions .github/workflows/check-tasklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: GitHub Task List Checker
on:
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
task-list-checker:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Check for incomplete task list items
uses: Shopify/task-list-checker@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn d2-style check commit "$1"
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/earthengine/ee_api_js_worker.js
24 changes: 8 additions & 16 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ const { config } = require('@dhis2/cli-style')

module.exports = {
...require(config.prettier),
printWidth: 80,
tabWidth: 4,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: true,
bracketSameLine: false,
jsxSingleQuote: false,
arrowParens: 'avoid',
rangeStart: 0,
rangeEnd: Infinity,
proseWrap: 'preserve',
requirePragma: false,
insertPragma: false,
endOfLine: 'lf',
overrides: [
{
files: 'pull_request_template.md',
options: {
tabWidth: 2,
},
},
],
}
54 changes: 27 additions & 27 deletions src/Map.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Evented, Map } from 'maplibre-gl'
import 'maplibre-gl/dist/maplibre-gl.css'
import Layer from './layers/Layer'
import layerTypes from './layers/layerTypes'
import controlTypes from './controls/controlTypes'
import controlsLocale from './controls/controlsLocale'
import MultiTouch from './controls/MultiTouch'
import { transformRequest } from './utils/images'
import { mapStyle } from './utils/style'
import { getBoundsFromLayers } from './utils/geometry'
import syncMaps from './utils/sync'
import { getFeaturesString } from './utils/core'
import { OVERLAY_START_POSITION } from './utils/layers'
import Popup from './ui/Popup'
import Label from './ui/Label'
import controlsLocale from './controls/controlsLocale.js'
import controlTypes from './controls/controlTypes.js'
import MultiTouch from './controls/MultiTouch.js'
import Layer from './layers/Layer.js'
import layerTypes from './layers/layerTypes.js'
import Label from './ui/Label.js'
import Popup from './ui/Popup.js'
import { getFeaturesString } from './utils/core.js'
import { getBoundsFromLayers } from './utils/geometry.js'
import { transformRequest } from './utils/images.js'
import { OVERLAY_START_POSITION } from './utils/layers.js'
import { mapStyle } from './utils/style.js'
import syncMaps from './utils/sync.js'
import './Map.css'

const renderedClass = 'dhis2-map-rendered'
Expand Down Expand Up @@ -51,7 +51,7 @@ export class MapGL extends Evented {

// Translate strings
if (locale) {
Object.keys(mapgl._locale).forEach(id => {
Object.keys(mapgl._locale).forEach((id) => {
const str = mapgl._locale[id]
if (locale[str]) {
mapgl._locale[id] = locale[str]
Expand Down Expand Up @@ -130,7 +130,7 @@ export class MapGL extends Evented {
}

async removeLayer(layer) {
this._layers = this._layers.filter(l => l !== layer)
this._layers = this._layers.filter((l) => l !== layer)

await layer.removeFrom(this)

Expand Down Expand Up @@ -173,7 +173,7 @@ export class MapGL extends Evented {
}

hasLayer(layer) {
return !!this._layers.find(l => l === layer)
return !!this._layers.find((l) => l === layer)
}

addControl(config) {
Expand Down Expand Up @@ -223,7 +223,7 @@ export class MapGL extends Evented {
this.fire('ready', this)
}

onClick = evt => {
onClick = (evt) => {
const eventObj = this._createClickEvent(evt)
const { feature } = eventObj

Expand All @@ -238,7 +238,7 @@ export class MapGL extends Evented {
this.fire('click', eventObj)
}

onContextMenu = evt => {
onContextMenu = (evt) => {
const eventObj = this._createClickEvent(evt)

if (eventObj.feature) {
Expand All @@ -249,7 +249,7 @@ export class MapGL extends Evented {
}
}

onMouseMove = evt => {
onMouseMove = (evt) => {
const feature = this.getEventFeature(evt)
let layer

Expand Down Expand Up @@ -280,7 +280,7 @@ export class MapGL extends Evented {

// Add rendered class if map is idle
onIdle = () => {
if (this.getLayers().some(layer => layer._isLoading)) {
if (this.getLayers().some((layer) => layer._isLoading)) {
return
}

Expand All @@ -296,15 +296,15 @@ export class MapGL extends Evented {
) {
if (this._hoverFeatures) {
// Clear state for existing hover features
this._hoverFeatures.forEach(feature =>
this._hoverFeatures.forEach((feature) =>
this.setFeatureState(feature, { hover: false })
)
this._hoverFeatures = null
}

if (Array.isArray(features)) {
this._hoverFeatures = features
features.forEach(feature =>
features.forEach((feature) =>
this.setFeatureState(feature, { hover: true })
)
}
Expand All @@ -323,7 +323,7 @@ export class MapGL extends Evented {

onMouseOut = () => this.hideLabel()

onError = evt => {
onError = (evt) => {
// TODO: Use optional chaining when DHIS2 Maps 2.35 is not supported
if (evt && evt.error && evt.error.message && console && console.error) {
const { message } = evt.error
Expand All @@ -343,8 +343,8 @@ export class MapGL extends Evented {
// TODO: throttle?
getEventFeature(evt) {
const layers = this.getLayers()
.filter(l => l.isInteractive())
.map(l => l.getInteractiveIds())
.filter((l) => l.isInteractive())
.map((l) => l.getInteractiveIds())
.reduce((out, ids) => [...out, ...ids], [])
let feature

Expand All @@ -358,7 +358,7 @@ export class MapGL extends Evented {
}

getLayerFromId(id) {
return this._layers.find(layer => layer.hasLayerId(id))
return this._layers.find((layer) => layer.hasLayerId(id))
}

getLayerAtIndex(index) {
Expand Down Expand Up @@ -396,7 +396,7 @@ export class MapGL extends Evented {
return this._beforeId &&
this.getMapGL()
.getStyle()
.layers.find(layer => layer.id === this._beforeId)
.layers.find((layer) => layer.id === this._beforeId)
? this._beforeId
: undefined
}
Expand Down
26 changes: 14 additions & 12 deletions src/controls/Measure.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import turfLength from '@turf/length'
import turfArea from '@turf/area'
import bbox from '@turf/bbox'
import turfLength from '@turf/length'
import { createElement } from '../utils/dom'

Check warning on line 4 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/dom"

Check warning on line 4 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/dom"
import { numberPrecision, kmToMiles } from '../utils/numbers'
import { featureCollection } from '../utils/geometry'

Check warning on line 5 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/geometry"

Check warning on line 5 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/geometry"
import { numberPrecision, kmToMiles } from '../utils/numbers'

Check warning on line 6 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/numbers"

Check warning on line 6 in src/controls/Measure.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "../utils/numbers"
import './Measure.css'

// Inspired by https://github.com/ljagis/leaflet-measure
Expand Down Expand Up @@ -235,19 +235,21 @@
_finishMeasure = () => {
const mapgl = this._map.getMapGL()
const geojson = this._geojson
const points = geojson.features.filter(f => f.geometry.type === 'Point')
const points = geojson.features.filter(
(f) => f.geometry.type === 'Point'
)
const locale = this.locale
const numFormat = this._numFormat

if (points.length < 2) {
return this._endMeasure()
} else if (points.length > 2) {
const lineIndex = geojson.features.findIndex(
f => f === this._linestring
(f) => f === this._linestring
)

this._linestring.geometry.coordinates = [
...points.map(point => point.geometry.coordinates),
...points.map((point) => point.geometry.coordinates),
points[0].geometry.coordinates,
]

Expand Down Expand Up @@ -328,12 +330,12 @@
this._isActive ? this._startMeasure() : this._endMeasure()
}

_onMapClick = evt => {
_onMapClick = (evt) => {
const mapgl = this._map.getMapGL()
const geojson = this._geojson
const locale = this.locale
const numFormat = this._numFormat
let points = geojson.features.filter(f => f.geometry.type === 'Point')
let points = geojson.features.filter((f) => f.geometry.type === 'Point')

const clikedFeature = mapgl.queryRenderedFeatures(evt.point, {
layers: ['measure-points'],
Expand All @@ -342,7 +344,7 @@
// If a feature was clicked, remove it from the map
if (clikedFeature) {
const { id } = clikedFeature.properties
points = points.filter(p => p.properties.id !== id)
points = points.filter((p) => p.properties.id !== id)
} else {
points = [
...points,
Expand All @@ -367,7 +369,7 @@
)
} else {
this._linestring.geometry.coordinates = points.map(
point => point.geometry.coordinates
(point) => point.geometry.coordinates
)

geojson.features.push(this._linestring)
Expand All @@ -393,7 +395,7 @@
if (points.length > 2) {
this._polygon.geometry.coordinates = [
[
...points.map(point => point.geometry.coordinates),
...points.map((point) => point.geometry.coordinates),
points[0].geometry.coordinates,
],
]
Expand Down Expand Up @@ -421,7 +423,7 @@
mapgl.getSource('measure').setData(geojson)
}

_onMouseMove = evt => {
_onMouseMove = (evt) => {
const mapgl = this._map.getMapGL()

const features = mapgl.queryRenderedFeatures(evt.point, {
Expand All @@ -438,7 +440,7 @@
const mapgl = this._map.getMapGL()
const layers = ['measure-points', 'measure-line', 'measure-polygon']

layers.forEach(layer => {
layers.forEach((layer) => {
if (mapgl.getLayer(layer)) {
mapgl.moveLayer(layer)
}
Expand Down
4 changes: 2 additions & 2 deletions src/controls/MultiTouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MultiTouch {
let x = 0
let y = 0

;[].forEach.call(event.touches, touch => {
;[].forEach.call(event.touches, (touch) => {
x += touch.screenX
y += touch.screenY
})
Expand All @@ -44,7 +44,7 @@ class MultiTouch {
let x = 0
let y = 0

;[].forEach.call(event.touches, touch => {
;[].forEach.call(event.touches, (touch) => {
x += touch.screenX
y += touch.screenY
})
Expand Down
14 changes: 7 additions & 7 deletions src/controls/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
const urlParams = new URLSearchParams(Object.entries(params))

return fetch(`https://nominatim.openstreetmap.org/search?${urlParams}`)
.then(response => (response.ok ? response.json() : []))
.then(json =>
json.map(result => {
.then((response) => (response.ok ? response.json() : []))
.then((json) =>
json.map((result) => {
const {
display_name: name,
lon: lng,
Expand Down Expand Up @@ -88,7 +88,7 @@
filter: false,
limit: this.options.limit,
})
this._typeahead.getItemValue = item => item.name
this._typeahead.getItemValue = (item) => item.name

this._collapseSearchControl()

Expand All @@ -102,7 +102,7 @@
}

// Clear search list when input field is changing
_onKeyDown = evt =>
_onKeyDown = (evt) =>

Check warning on line 105 in src/controls/Search.js

View workflow job for this annotation

GitHub Actions / verify

'evt' is defined but never used

Check warning on line 105 in src/controls/Search.js

View workflow job for this annotation

GitHub Actions / verify

'evt' is defined but never used
setTimeout(() => {
const { selected } = this._typeahead

Expand Down Expand Up @@ -140,7 +140,7 @@
this._loadingEl.style.display = 'block'

this.geocodeRequest(searchInput, this._map.getBounds(), this.options)
.then(results => {
.then((results) => {
let items = results

this._loadingEl.style.display = 'none'
Expand All @@ -162,7 +162,7 @@
.catch(() => (this._loadingEl.style.display = 'none'))
}

_clear = evt => {
_clear = (evt) => {
if (evt) {
evt.preventDefault()
}
Expand Down
6 changes: 3 additions & 3 deletions src/controls/controlTypes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ScaleControl } from 'maplibre-gl'
import Attribution from './Attribution'

Check warning on line 2 in src/controls/controlTypes.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "./Attribution"

Check warning on line 2 in src/controls/controlTypes.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "./Attribution"
import Navigation from './Navigation'
import Search from './Search'
import Measure from './Measure'
import FitBounds from './FitBounds'

Check warning on line 3 in src/controls/controlTypes.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "./FitBounds"

Check warning on line 3 in src/controls/controlTypes.js

View workflow job for this annotation

GitHub Actions / verify

Missing file extension "js" for "./FitBounds"
import Fullscreen from './Fullscreen'
import Measure from './Measure'
import Navigation from './Navigation'
import Search from './Search'
import './Controls.css'

export default {
Expand Down
Loading
Loading