diff --git a/assets/css/react-select.css b/assets/css/react-select.css
deleted file mode 100644
index 27a598d61..000000000
--- a/assets/css/react-select.css
+++ /dev/null
@@ -1,97 +0,0 @@
-.filter-list-text:hover ~ .filter-list-edit {
- display: flex;
-}
-
-.filter-list-text:hover ~ .filter-list-remove {
- display: none;
-}
-
-.filter-select__control:focus-within {
- box-shadow: rgb(255, 255, 255) 0px 0px 0px 0px, rgb(99, 102, 241) 0px 0px 0px 1px, rgba(0, 0, 0, 0) 0px 0px 0px 0px; /* indigo-500 */
-}
-
-.filter-select__value-container {
- padding-left: 1rem !important;
-}
-
-.filter-select__control {
- @apply dark:bg-gray-900 border-gray-300 dark:border-gray-700 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 pr-8;
- border-radius: 0.375rem !important;
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
- background-position: right 0.5rem center;
- background-repeat: no-repeat;
- background-size: 1.35rem 1.35rem;
-}
-
-.filter-select__control:hover {
- @apply cursor-pointer;
- border-color: rgb(156, 163, 175) !important; /* gray-400 */
-}
-
-.filter-select__indicator-separator {
- @apply hidden;
-}
-
-.filter-select__dropdown-indicator {
- display: none !important;
-}
-
-.filter-select__input {
- @apply w-full text-base sm:text-sm;
- margin: 0 !important;
-}
-
-.filter-select__input input {
- width: 100% !important;
- box-shadow: none !important;
-}
-
-.dark .filter-select__input input {
- color: rgb(209, 213, 219) !important; /* gray-300 */
-}
-
-.filter-select__value-container > :not(.filter-select__single-value) {
- @apply w-full;
- padding-top: 0 !important;
-}
-
-.filter-select__loading-indicator {
- color: rgb(79, 70, 229) !important; /* indigo-600 */
-}
-
-.filter-select__loading-indicator > span {
- height: 1.5em;
- width: 1.5em;
-}
-
-.filter-select__single-value {
- @apply dark:text-gray-400 text-base sm:text-sm;
-}
-
-.filter-select__menu-list {
- @apply dark:bg-gray-900;
-}
-
-.filter-select__option {
- @apply dark:text-gray-300;
- font-size: 1rem !important;
- line-height: 1.5rem !important;
- cursor: pointer !important;
-}
-
-@media (min-width: 640px) {
- .filter-select__option {
- font-size: 0.875rem !important;
- line-height: 1.25rem !important;
- }
-}
-
-.filter-select__option--is-focused {
- background-color: rgb(99, 102, 241) !important; /* indigo-500 */
- color: white !important;
-}
-
-.dark .filter-select__option--is-focused {
- background-color: rgb(79, 70, 229) !important; /* indigo-600 */
-}
-
diff --git a/assets/js/app.js b/assets/js/app.js
index 81e2debee..9a2ea9ac1 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -1,5 +1,4 @@
import "../css/app.css"
-import "../css/react-select.css"
import "flatpickr/dist/flatpickr.min.css"
import "./polyfills/closest"
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
diff --git a/assets/js/dashboard/components/search-select.js b/assets/js/dashboard/components/search-select.js
new file mode 100644
index 000000000..e29bfd57f
--- /dev/null
+++ b/assets/js/dashboard/components/search-select.js
@@ -0,0 +1,115 @@
+import React, {useState, useCallback} from 'react'
+import {useCombobox} from 'downshift'
+import classNames from 'classnames'
+import debounce from 'debounce-promise'
+
+function selectInputText(e) {
+ e.target.select()
+}
+
+function ChevronDown() {
+ return (
+
+ )
+}
+
+function Spinner() {
+ return (
+
+ )
+}
+
+export default function SearchSelect(props) {
+ const [items, setItems] = useState([])
+ const [loading, setLoading] = useState(false)
+ const [initialLoadComplete, setInitialLoadComplete] = useState(false)
+
+ function fetchOptions({inputValue, isOpen}) {
+ setLoading(isOpen)
+
+ return props.fetchOptions(inputValue).then((loadedItems) => {
+ setLoading(false)
+ setItems(loadedItems)
+ })
+ }
+
+ const debouncedFetchOptions = useCallback(debounce(fetchOptions, 200), [])
+
+ const {
+ isOpen,
+ inputValue,
+ getToggleButtonProps,
+ getLabelProps,
+ getMenuProps,
+ getInputProps,
+ getComboboxProps,
+ highlightedIndex,
+ getItemProps,
+ selectItem,
+ closeMenu,
+ setInputValue
+ } = useCombobox({
+ items: items,
+ onInputValueChange: (changes) => {
+ debouncedFetchOptions(changes)
+ props.onInput(changes.inputValue)
+ },
+ initialSelectedItem: props.initialSelectedItem,
+ onIsOpenChange: ({inputValue}) => {
+ if (!initialLoadComplete) {
+ fetchOptions({inputValue: inputValue, isOpen: true}).then(() => {
+ setInitialLoadComplete(true)
+ })
+ }
+ }
+ })
+
+ function keydown(e) {
+ if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || e.isComposing || e.keyCode === 229) return
+
+ if (e.key == 'Enter' && isOpen && highlightedIndex === -1) {
+ closeMenu()
+ e.preventDefault()
+ }
+ }
+
+ return (
+
+
+
+
+ { !loading && }
+ { loading && }
+
+
+
+ { isOpen &&
+
+ { !loading && items.length == 0 &&
+ - No results found
+ }
+ { loading && items.length == 0 &&
+ - Loading options...
+ }
+
+ {
+ items.map((item, index) => (
+ -
+ {item}
+
+ ))
+ }
+
+ }
+
+
+ )
+}
diff --git a/assets/js/dashboard/datepicker.js b/assets/js/dashboard/datepicker.js
index d3aee1791..c5b4a897f 100644
--- a/assets/js/dashboard/datepicker.js
+++ b/assets/js/dashboard/datepicker.js
@@ -106,6 +106,8 @@ class DatePicker extends React.Component {
if (keys.includes(e.key.toLowerCase())) {
navigateToQuery(history, query, {...newSearch, ...(redirects[keys.indexOf(e.key.toLowerCase())])});
+ } else if (e.key.toLowerCase() === 'f') {
+ return history.push({pathname: `/${encodeURIComponent(this.props.site.domain)}/filter`, search: window.location.search})
} else if (e.key.toLowerCase() === 'c') {
this.setState({mode: 'calendar', open: true}, this.openCalendar);
} else if (newSearch.date) {
diff --git a/assets/js/dashboard/filters.js b/assets/js/dashboard/filters.js
index 9ae721d31..cd0010cea 100644
--- a/assets/js/dashboard/filters.js
+++ b/assets/js/dashboard/filters.js
@@ -1,6 +1,6 @@
import React from 'react';
import { withRouter, Link } from 'react-router-dom'
-import { countFilters, formattedFilters, navigateToQuery, removeQueryParam } from './query'
+import { countFilters, formattedFilters, navigateToQuery } from './query'
import Datamap from 'datamaps'
import Transition from "../transition.js";
@@ -279,15 +279,16 @@ class Filters extends React.Component {
renderFilterList() {
const { history, query, site } = this.props;
- const { viewport } = this.state;
return (
{(this.appliedFilters.map((filter) => this.renderListFilter(history, filter, query)))}
-
-
- {viewport <= 768 ? "Filter" : "Add Filter"}
+
+
+
+ Filter
+
);
}
diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.js
index 71bddf47b..b5c30d25c 100644
--- a/assets/js/dashboard/query.js
+++ b/assets/js/dashboard/query.js
@@ -144,12 +144,6 @@ export function toHuman(query) {
}
}
-export function removeQueryParam(search, parameter) {
- const q = new URLSearchParams(search)
- q.delete(parameter)
- return q.toString()
-}
-
export function eventName(query) {
if (query.filters.goal) {
if (query.filters.goal.startsWith('Visit ')) {
diff --git a/assets/js/dashboard/stats/modals/filter.js b/assets/js/dashboard/stats/modals/filter.js
index da362424c..d49cd8b1b 100644
--- a/assets/js/dashboard/stats/modals/filter.js
+++ b/assets/js/dashboard/stats/modals/filter.js
@@ -2,59 +2,42 @@ import React from "react";
import { withRouter, Redirect } from 'react-router-dom'
import Datamap from 'datamaps'
-import AsyncSelect from 'react-select/async'
-import debounce from 'lodash.debounce'
+import SearchSelect from '../../components/search-select'
import Modal from './modal'
import { parseQuery, formattedFilters, navigateToQuery } from '../../query'
import Transition from "../../../transition";
import * as api from '../../api'
+function getFilterValue(selectedFilter, query) {
+ const negated = !!query.filters[selectedFilter] && query.filters[selectedFilter][0] === '!'
+ let filterValue = negated ? query.filters[selectedFilter].slice(1) : (query.filters[selectedFilter] || "")
+
+ if (selectedFilter == 'country') {
+ const allCountries = Datamap.prototype.worldTopo.objects.world.geometries;
+ const selectedCountry = allCountries.find((c) => c.id === filterValue) || { properties: { name: filterValue } };
+ filterValue = selectedCountry.properties.name
+ }
+
+ return {filterValue, negated}
+}
+
+
class FilterModal extends React.Component {
constructor(props) {
super(props)
- this.state = {
- query: parseQuery(props.location.search, props.site),
- selectedFilter: "",
- negated: false,
- updatedValue: "",
- inputValue: "",
- forceReloadSuggestions: 0,
- defaultOptions: []
- }
+ const query = parseQuery(props.location.search, props.site)
+ const selectedFilter = this.props.match.params.field || 'page'
+
+ this.state = Object.assign({selectedFilter, query}, getFilterValue(selectedFilter, query))
- this.editableGoals = Object.keys(this.state.query.filters).filter(filter => !['props'].includes(filter))
- this.renderSelector = this.renderSelector.bind(this)
- this.fetchSuggestions = this.fetchSuggestions.bind(this)
this.handleKeydown = this.handleKeydown.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
- this.fieldSelectRef = React.createRef()
- this.debouncedFetchSuggestions = debounce((q, callback) => this.fetchSuggestions(q, callback), 150)
}
componentDidMount() {
- this.setState({ selectedFilter: this.props.match.params.field })
- this.fieldSelectRef.current.focus()
document.addEventListener("keydown", this.handleKeydown)
}
- componentDidUpdate(prevProps, prevState) {
- const { query, selectedFilter, updatedValue, forceReloadSuggestions } = this.state
-
- if (prevState.selectedFilter !== selectedFilter) {
- const negated = !!query.filters[selectedFilter] && query.filters[selectedFilter][0] == '!' && this.negationSupported(selectedFilter)
- let updatedValue = negated ? query.filters[selectedFilter].slice(1) : (query.filters[selectedFilter] || "")
-
- if (selectedFilter == 'country') {
- const allCountries = Datamap.prototype.worldTopo.objects.world.geometries;
- const selectedCountry = allCountries.find((c) => c.id === updatedValue) || { properties: { name: updatedValue } };
- updatedValue = selectedCountry.properties.name
- }
-
- if (selectedFilter) this.fetchSuggestions('', (defaultOptions) => this.setState({ defaultOptions }))
- this.setState({ updatedValue, inputValue: updatedValue, negated, forceReloadSuggestions: forceReloadSuggestions + 1 })
- }
- }
-
componentWillUnmount() {
document.removeEventListener("keydown", this.handleKeydown);
}
@@ -71,89 +54,70 @@ class FilterModal extends React.Component {
return ['page', 'entry_page', 'exit_page'].includes(filter)
}
- fetchSuggestions(searchQuery = "", callback) {
- const { query, selectedFilter } = this.state
+ fetchOptions(input) {
+ const {query, selectedFilter} = this.state
const updatedQuery = { ...query, filters: { ...query.filters, [selectedFilter]: null } }
- if (selectedFilter == 'country') {
- const matchedCountries = Datamap.prototype.worldTopo.objects.world.geometries.filter(c => c.properties.name.includes(searchQuery.trim()))
+ if (selectedFilter === 'country') {
+ const matchedCountries = Datamap.prototype.worldTopo.objects.world.geometries.filter(c => c.properties.name.toLowerCase().includes(input.trim().toLowerCase()))
const matches = matchedCountries.map(c => c.id)
- api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/suggestions/country`, updatedQuery, { q: matches })
+ return api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/suggestions/country`, updatedQuery, { q: matches })
.then((res) => {
- const result = res.map(code => matchedCountries.filter(c => c.id == code)[0].properties.name).map(r => ({ label: r, value: r }))
- callback(result)
+ return res.map(code => matchedCountries.filter(c => c.id == code)[0].properties.name)
})
} else {
- api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/suggestions/${selectedFilter}`, updatedQuery, { q: searchQuery.trim() })
- .then((res) => {
- const result = res.map(r => ({ label: r, value: r }))
- callback(result)
- })
+ return api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/suggestions/${selectedFilter}`, updatedQuery, { q: input.trim() })
}
}
- renderSelector(filter) {
- const { updatedValue, selectedFilter, inputValue, forceReloadSuggestions, defaultOptions } = this.state;
-
- if (!filter) return null
+ onInput(val) {
+ this.setState({filterValue: val})
+ }
+ renderSearchSelector(filter) {
return (
- this.debouncedFetchSuggestions(q, callback)}
- placeholder='Filter value'
- maxMenuHeight={250}
- tabSelectsValue={false}
- classNamePrefix='filter-select'
- blurInputOnSelect
- noOptionsMessage={() => (
-
-
- No results found in current dashboard, try removing some filters, checking your input and ensuring this {formattedFilters[selectedFilter].toLowerCase()} exists
-
- )}
- loadingMessage={() => (
-
- Loading filter suggestions
-
- )}
- value={inputValue == '' ? { label: 'Enter a filter value', value: '' } : { label: updatedValue, value: `${updatedValue } ` }}
- onChange={({ value }, a) => {
- this.setState({ updatedValue: value, inputValue: value, forceReloadSuggestions: forceReloadSuggestions + 1 })
- }}
- onInputChange={(value, { action }) => {
- if (action == 'input-change') this.setState({ inputValue: value })
- if (action == 'menu-close' || action == 'input-blur') this.setState(({inputValue}) => ({ updatedValue: inputValue }))
- }}
- inputValue={inputValue}
- onBlur={() => this.setState({ forceReloadSuggestions: forceReloadSuggestions + 1 })}
- />)
+
+ )
+ }
+
+ selectFilterAndCloseModal(filterKey, filterValue) {
+ const queryString = new URLSearchParams(window.location.search)
+
+ if (filterValue) {
+ queryString.set(filterKey, filterValue)
+ } else {
+ queryString.delete(filterKey)
+ }
+
+ this.props.history.replace({pathname: `/${encodeURIComponent(this.props.site.domain)}`, search: queryString.toString()})
}
handleSubmit() {
- const { selectedFilter, negated, updatedValue } = this.state;
- const validFilter = this.editableGoals.includes(selectedFilter) && updatedValue.trim()
+ const { selectedFilter, negated, filterValue } = this.state;
- let finalFilterValue = (this.negationSupported(selectedFilter) && negated ? '!' : '') + updatedValue.trim()
+ let finalFilterValue = (this.negationSupported(selectedFilter) && negated ? '!' : '') + filterValue.trim()
if (selectedFilter == 'country') {
const allCountries = Datamap.prototype.worldTopo.objects.world.geometries;
const selectedCountry = allCountries.find((c) => c.properties.name === finalFilterValue) || { id: finalFilterValue };
finalFilterValue = selectedCountry.id
}
- const finalizedQuery = new URLSearchParams(window.location.search)
- finalizedQuery.set(selectedFilter, finalFilterValue)
- if (validFilter) {
- this.setState({ finalizedQuery })
- }
+ this.selectFilterAndCloseModal(selectedFilter, finalFilterValue)
+ }
+
+ updateSelectedFilter(e) {
+ this.setState(Object.assign({selectedFilter: e.target.value}, getFilterValue(e.target.value, this.state.query)))
}
renderBody() {
- const { selectedFilter, negated, updatedValue, query } = this.state;
- const validFilter = this.editableGoals.includes(selectedFilter) && updatedValue.trim()
+ const { selectedFilter, negated, filterValue, query } = this.state;
+ const editableFilters = Object.keys(this.state.query.filters).filter(filter => !['props'].includes(filter))
return (
<>
@@ -163,14 +127,13 @@ class FilterModal extends React.Component {
+ {this.renderHints()}
>
)
}
- render() {
- const { finalizedQuery } = this.state;
-
- if (finalizedQuery)
- return
+ renderHints() {
+ if (['page', 'entry_page', 'exit_page'].includes(this.state.selectedFilter)) {
+ return (
+ Hint: You can use double asterisks to match any character e.g. /blog**
+ )
+ }
+ }
+ render() {
return (
{ this.renderBody()}
diff --git a/assets/package-lock.json b/assets/package-lock.json
index ecbb20a27..6c2970a04 100644
--- a/assets/package-lock.json
+++ b/assets/package-lock.json
@@ -17,12 +17,14 @@
"autoprefixer": "^10.2.6",
"babel-loader": "^8.2.2",
"chart.js": "^3.3.2",
+ "classnames": "^2.3.1",
"copy-webpack-plugin": "^9.0.0",
"css-loader": "^5.2.6",
"css-minimizer-webpack-plugin": "^3.0.1",
"datamaps": "^0.5.9",
+ "debounce-promise": "^3.1.2",
+ "downshift": "^6.1.3",
"iframe-resizer": "^4.3.2",
- "lodash.debounce": "^4.0.8",
"mini-css-extract-plugin": "^1.6.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
@@ -33,7 +35,6 @@
"react-flatpickr": "3.10.5",
"react-flip-move": "^3.0.4",
"react-router-dom": "^5.2.0",
- "react-select": "^4.3.1",
"react-transition-group": "^4.4.2",
"tailwindcss": "^2.1.2",
"terser-webpack-plugin": "^5.1.2",
@@ -1516,86 +1517,6 @@
"node": ">=10.0.0"
}
},
- "node_modules/@emotion/cache": {
- "version": "11.4.0",
- "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.4.0.tgz",
- "integrity": "sha512-Zx70bjE7LErRO9OaZrhf22Qye1y4F7iDl+ITjet0J+i+B88PrAOBkKvaAWhxsZf72tDLajwCgfCjJ2dvH77C3g==",
- "dependencies": {
- "@emotion/memoize": "^0.7.4",
- "@emotion/sheet": "^1.0.0",
- "@emotion/utils": "^1.0.0",
- "@emotion/weak-memoize": "^0.2.5",
- "stylis": "^4.0.3"
- }
- },
- "node_modules/@emotion/hash": {
- "version": "0.8.0",
- "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz",
- "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow=="
- },
- "node_modules/@emotion/memoize": {
- "version": "0.7.5",
- "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.5.tgz",
- "integrity": "sha512-igX9a37DR2ZPGYtV6suZ6whr8pTFtyHL3K/oLUotxpSVO2ASaprmAe2Dkq7tBo7CRY7MMDrAa9nuQP9/YG8FxQ=="
- },
- "node_modules/@emotion/react": {
- "version": "11.4.0",
- "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.4.0.tgz",
- "integrity": "sha512-4XklWsl9BdtatLoJpSjusXhpKv9YVteYKh9hPKP1Sxl+mswEFoUe0WtmtWjxEjkA51DQ2QRMCNOvKcSlCQ7ivg==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@emotion/cache": "^11.4.0",
- "@emotion/serialize": "^1.0.2",
- "@emotion/sheet": "^1.0.1",
- "@emotion/utils": "^1.0.0",
- "@emotion/weak-memoize": "^0.2.5",
- "hoist-non-react-statics": "^3.3.1"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0",
- "react": ">=16.8.0"
- },
- "peerDependenciesMeta": {
- "@babel/core": {
- "optional": true
- },
- "@types/react": {
- "optional": true
- }
- }
- },
- "node_modules/@emotion/serialize": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.0.2.tgz",
- "integrity": "sha512-95MgNJ9+/ajxU7QIAruiOAdYNjxZX7G2mhgrtDWswA21VviYIRP1R5QilZ/bDY42xiKsaktP4egJb3QdYQZi1A==",
- "dependencies": {
- "@emotion/hash": "^0.8.0",
- "@emotion/memoize": "^0.7.4",
- "@emotion/unitless": "^0.7.5",
- "@emotion/utils": "^1.0.0",
- "csstype": "^3.0.2"
- }
- },
- "node_modules/@emotion/sheet": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.0.1.tgz",
- "integrity": "sha512-GbIvVMe4U+Zc+929N1V7nW6YYJtidj31lidSmdYcWozwoBIObXBnaJkKNDjZrLm9Nc0BR+ZyHNaRZxqNZbof5g=="
- },
- "node_modules/@emotion/unitless": {
- "version": "0.7.5",
- "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz",
- "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg=="
- },
- "node_modules/@emotion/utils": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.0.0.tgz",
- "integrity": "sha512-mQC2b3XLDs6QCW+pDQDiyO/EdGZYOygE8s5N5rrzjSI4M3IejPE/JPndCBwRT9z982aqQNi6beWs1UeayrQxxA=="
- },
- "node_modules/@emotion/weak-memoize": {
- "version": "0.2.5",
- "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz",
- "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA=="
- },
"node_modules/@eslint/eslintrc": {
"version": "0.2.2",
"dev": true,
@@ -2678,6 +2599,11 @@
"node": ">=6.0"
}
},
+ "node_modules/classnames": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
+ "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
+ },
"node_modules/clone-deep": {
"version": "4.0.1",
"license": "MIT",
@@ -2748,6 +2674,11 @@
"version": "1.0.1",
"license": "MIT"
},
+ "node_modules/compute-scroll-into-view": {
+ "version": "1.0.17",
+ "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.17.tgz",
+ "integrity": "sha512-j4dx+Fb0URmzbwwMUrhqWM2BEWHdFGx+qZ9qqASHRPqvTYdqvWnHg0H1hIbcyLnvgnoNAVMlwkepyqM3DaIFUg=="
+ },
"node_modules/concat-map": {
"version": "0.0.1",
"license": "MIT"
@@ -3270,6 +3201,11 @@
"topojson": "^1.6.19"
}
},
+ "node_modules/debounce-promise": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/debounce-promise/-/debounce-promise-3.1.2.tgz",
+ "integrity": "sha512-rZHcgBkbYavBeD9ej6sP56XfG53d51CD4dnaw989YX/nZ/ZJfgRx/9ePKmTNiUiyQvh4mtrMoS3OAWW+yoYtpg=="
+ },
"node_modules/debug": {
"version": "4.3.1",
"license": "MIT",
@@ -3419,6 +3355,25 @@
"domelementtype": "1"
}
},
+ "node_modules/downshift": {
+ "version": "6.1.3",
+ "resolved": "https://registry.npmjs.org/downshift/-/downshift-6.1.3.tgz",
+ "integrity": "sha512-RA1MuaNcTbt0j+sVLhSs8R2oZbBXYAtdQP/V+uHhT3DoDteZzJPjlC+LQVm9T07Wpvo84QXaZtUCePLDTDwGXg==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10",
+ "compute-scroll-into-view": "^1.0.17",
+ "prop-types": "^15.7.2",
+ "react-is": "^17.0.2"
+ },
+ "peerDependencies": {
+ "react": ">=16.12.0"
+ }
+ },
+ "node_modules/downshift/node_modules/react-is": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
+ "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
+ },
"node_modules/duplexer": {
"version": "0.1.2",
"dev": true,
@@ -5693,11 +5648,6 @@
"version": "2.0.14",
"license": "CC0-1.0"
},
- "node_modules/memoize-one": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
- "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
- },
"node_modules/meow": {
"version": "8.0.0",
"dev": true,
@@ -7500,17 +7450,6 @@
"react-dom": ">=16.3.x"
}
},
- "node_modules/react-input-autosize": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/react-input-autosize/-/react-input-autosize-3.0.0.tgz",
- "integrity": "sha512-nL9uS7jEs/zu8sqwFE5MAPx6pPkNAriACQ2rGLlqmKr2sPGtN7TXTyDdQt4lbNXVx7Uzadb40x8qotIuru6Rhg==",
- "dependencies": {
- "prop-types": "^15.5.8"
- },
- "peerDependencies": {
- "react": "^16.3.0 || ^17.0.0"
- }
- },
"node_modules/react-is": {
"version": "16.11.0",
"license": "MIT"
@@ -7550,24 +7489,6 @@
"react": ">=15"
}
},
- "node_modules/react-select": {
- "version": "4.3.1",
- "resolved": "https://registry.npmjs.org/react-select/-/react-select-4.3.1.tgz",
- "integrity": "sha512-HBBd0dYwkF5aZk1zP81Wx5UsLIIT2lSvAY2JiJo199LjoLHoivjn9//KsmvQMEFGNhe58xyuOITjfxKCcGc62Q==",
- "dependencies": {
- "@babel/runtime": "^7.12.0",
- "@emotion/cache": "^11.4.0",
- "@emotion/react": "^11.1.1",
- "memoize-one": "^5.0.0",
- "prop-types": "^15.6.0",
- "react-input-autosize": "^3.0.0",
- "react-transition-group": "^4.3.0"
- },
- "peerDependencies": {
- "react": "^16.8.0 || ^17.0.0",
- "react-dom": "^16.8.0 || ^17.0.0"
- }
- },
"node_modules/react-transition-group": {
"version": "4.4.2",
"license": "BSD-3-Clause",
@@ -8818,11 +8739,6 @@
"node": ">=10.0.0"
}
},
- "node_modules/stylis": {
- "version": "4.0.10",
- "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.10.tgz",
- "integrity": "sha512-m3k+dk7QeJw660eIKRRn3xPF6uuvHs/FFzjX3HQ5ove0qYsiygoAhwn5a3IYKaZPo5LrYD0rfVmtv1gNY1uYwg=="
- },
"node_modules/sugarss": {
"version": "2.0.0",
"dev": true,
@@ -10722,74 +10638,6 @@
"@discoveryjs/json-ext": {
"version": "0.5.3"
},
- "@emotion/cache": {
- "version": "11.4.0",
- "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.4.0.tgz",
- "integrity": "sha512-Zx70bjE7LErRO9OaZrhf22Qye1y4F7iDl+ITjet0J+i+B88PrAOBkKvaAWhxsZf72tDLajwCgfCjJ2dvH77C3g==",
- "requires": {
- "@emotion/memoize": "^0.7.4",
- "@emotion/sheet": "^1.0.0",
- "@emotion/utils": "^1.0.0",
- "@emotion/weak-memoize": "^0.2.5",
- "stylis": "^4.0.3"
- }
- },
- "@emotion/hash": {
- "version": "0.8.0",
- "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz",
- "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow=="
- },
- "@emotion/memoize": {
- "version": "0.7.5",
- "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.5.tgz",
- "integrity": "sha512-igX9a37DR2ZPGYtV6suZ6whr8pTFtyHL3K/oLUotxpSVO2ASaprmAe2Dkq7tBo7CRY7MMDrAa9nuQP9/YG8FxQ=="
- },
- "@emotion/react": {
- "version": "11.4.0",
- "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.4.0.tgz",
- "integrity": "sha512-4XklWsl9BdtatLoJpSjusXhpKv9YVteYKh9hPKP1Sxl+mswEFoUe0WtmtWjxEjkA51DQ2QRMCNOvKcSlCQ7ivg==",
- "requires": {
- "@babel/runtime": "^7.13.10",
- "@emotion/cache": "^11.4.0",
- "@emotion/serialize": "^1.0.2",
- "@emotion/sheet": "^1.0.1",
- "@emotion/utils": "^1.0.0",
- "@emotion/weak-memoize": "^0.2.5",
- "hoist-non-react-statics": "^3.3.1"
- }
- },
- "@emotion/serialize": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.0.2.tgz",
- "integrity": "sha512-95MgNJ9+/ajxU7QIAruiOAdYNjxZX7G2mhgrtDWswA21VviYIRP1R5QilZ/bDY42xiKsaktP4egJb3QdYQZi1A==",
- "requires": {
- "@emotion/hash": "^0.8.0",
- "@emotion/memoize": "^0.7.4",
- "@emotion/unitless": "^0.7.5",
- "@emotion/utils": "^1.0.0",
- "csstype": "^3.0.2"
- }
- },
- "@emotion/sheet": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.0.1.tgz",
- "integrity": "sha512-GbIvVMe4U+Zc+929N1V7nW6YYJtidj31lidSmdYcWozwoBIObXBnaJkKNDjZrLm9Nc0BR+ZyHNaRZxqNZbof5g=="
- },
- "@emotion/unitless": {
- "version": "0.7.5",
- "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz",
- "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg=="
- },
- "@emotion/utils": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.0.0.tgz",
- "integrity": "sha512-mQC2b3XLDs6QCW+pDQDiyO/EdGZYOygE8s5N5rrzjSI4M3IejPE/JPndCBwRT9z982aqQNi6beWs1UeayrQxxA=="
- },
- "@emotion/weak-memoize": {
- "version": "0.2.5",
- "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz",
- "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA=="
- },
"@eslint/eslintrc": {
"version": "0.2.2",
"dev": true,
@@ -11497,6 +11345,11 @@
"tslib": "^1.9.0"
}
},
+ "classnames": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
+ "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
+ },
"clone-deep": {
"version": "4.0.1",
"requires": {
@@ -11549,6 +11402,11 @@
"commondir": {
"version": "1.0.1"
},
+ "compute-scroll-into-view": {
+ "version": "1.0.17",
+ "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.17.tgz",
+ "integrity": "sha512-j4dx+Fb0URmzbwwMUrhqWM2BEWHdFGx+qZ9qqASHRPqvTYdqvWnHg0H1hIbcyLnvgnoNAVMlwkepyqM3DaIFUg=="
+ },
"concat-map": {
"version": "0.0.1"
},
@@ -11865,6 +11723,11 @@
"topojson": "^1.6.19"
}
},
+ "debounce-promise": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/debounce-promise/-/debounce-promise-3.1.2.tgz",
+ "integrity": "sha512-rZHcgBkbYavBeD9ej6sP56XfG53d51CD4dnaw989YX/nZ/ZJfgRx/9ePKmTNiUiyQvh4mtrMoS3OAWW+yoYtpg=="
+ },
"debug": {
"version": "4.3.1",
"requires": {
@@ -11968,6 +11831,24 @@
"domelementtype": "1"
}
},
+ "downshift": {
+ "version": "6.1.3",
+ "resolved": "https://registry.npmjs.org/downshift/-/downshift-6.1.3.tgz",
+ "integrity": "sha512-RA1MuaNcTbt0j+sVLhSs8R2oZbBXYAtdQP/V+uHhT3DoDteZzJPjlC+LQVm9T07Wpvo84QXaZtUCePLDTDwGXg==",
+ "requires": {
+ "@babel/runtime": "^7.13.10",
+ "compute-scroll-into-view": "^1.0.17",
+ "prop-types": "^15.7.2",
+ "react-is": "^17.0.2"
+ },
+ "dependencies": {
+ "react-is": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
+ "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
+ }
+ }
+ },
"duplexer": {
"version": "0.1.2",
"dev": true
@@ -13375,11 +13256,6 @@
"mdn-data": {
"version": "2.0.14"
},
- "memoize-one": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
- "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
- },
"meow": {
"version": "8.0.0",
"dev": true,
@@ -14494,14 +14370,6 @@
"version": "3.0.4",
"requires": {}
},
- "react-input-autosize": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/react-input-autosize/-/react-input-autosize-3.0.0.tgz",
- "integrity": "sha512-nL9uS7jEs/zu8sqwFE5MAPx6pPkNAriACQ2rGLlqmKr2sPGtN7TXTyDdQt4lbNXVx7Uzadb40x8qotIuru6Rhg==",
- "requires": {
- "prop-types": "^15.5.8"
- }
- },
"react-is": {
"version": "16.11.0"
},
@@ -14532,20 +14400,6 @@
"tiny-warning": "^1.0.0"
}
},
- "react-select": {
- "version": "4.3.1",
- "resolved": "https://registry.npmjs.org/react-select/-/react-select-4.3.1.tgz",
- "integrity": "sha512-HBBd0dYwkF5aZk1zP81Wx5UsLIIT2lSvAY2JiJo199LjoLHoivjn9//KsmvQMEFGNhe58xyuOITjfxKCcGc62Q==",
- "requires": {
- "@babel/runtime": "^7.12.0",
- "@emotion/cache": "^11.4.0",
- "@emotion/react": "^11.1.1",
- "memoize-one": "^5.0.0",
- "prop-types": "^15.6.0",
- "react-input-autosize": "^3.0.0",
- "react-transition-group": "^4.3.0"
- }
- },
"react-transition-group": {
"version": "4.4.2",
"requires": {
@@ -15376,11 +15230,6 @@
"stylelint-config-recommended": "^3.0.0"
}
},
- "stylis": {
- "version": "4.0.10",
- "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.10.tgz",
- "integrity": "sha512-m3k+dk7QeJw660eIKRRn3xPF6uuvHs/FFzjX3HQ5ove0qYsiygoAhwn5a3IYKaZPo5LrYD0rfVmtv1gNY1uYwg=="
- },
"sugarss": {
"version": "2.0.0",
"dev": true,
diff --git a/assets/package.json b/assets/package.json
index 28fb50eea..d1050df45 100644
--- a/assets/package.json
+++ b/assets/package.json
@@ -17,12 +17,14 @@
"autoprefixer": "^10.2.6",
"babel-loader": "^8.2.2",
"chart.js": "^3.3.2",
+ "classnames": "^2.3.1",
"copy-webpack-plugin": "^9.0.0",
"css-loader": "^5.2.6",
"css-minimizer-webpack-plugin": "^3.0.1",
"datamaps": "^0.5.9",
+ "debounce-promise": "^3.1.2",
+ "downshift": "^6.1.3",
"iframe-resizer": "^4.3.2",
- "lodash.debounce": "^4.0.8",
"mini-css-extract-plugin": "^1.6.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
@@ -33,7 +35,6 @@
"react-flatpickr": "3.10.5",
"react-flip-move": "^3.0.4",
"react-router-dom": "^5.2.0",
- "react-select": "^4.3.1",
"react-transition-group": "^4.4.2",
"tailwindcss": "^2.1.2",
"terser-webpack-plugin": "^5.1.2",
diff --git a/config/runtime.exs b/config/runtime.exs
index da73e0ff2..48c08b58e 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -138,7 +138,7 @@ is_selfhost =
{site_limit, ""} =
config_dir
- |> get_var_from_path_or_env("SITE_LIMIT", "20")
+ |> get_var_from_path_or_env("SITE_LIMIT", "50")
|> Integer.parse()
site_limit_exempt =
@@ -232,8 +232,8 @@ case mailer_adapter do
password: get_var_from_path_or_env(config_dir, "SMTP_USER_PWD"),
tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
- ssl: get_var_from_path_or_env(config_dir, "SMTP_HOST_SSL_ENABLED", false),
- retries: get_var_from_path_or_env(config_dir, "SMTP_RETRIES", 2),
+ ssl: get_var_from_path_or_env(config_dir, "SMTP_HOST_SSL_ENABLED") || false,
+ retries: get_var_from_path_or_env(config_dir, "SMTP_RETRIES") || 2,
no_mx_lookups: get_var_from_path_or_env(config_dir, "SMTP_MX_LOOKUPS_ENABLED") || true
"Bamboo.LocalAdapter" ->
diff --git a/lib/plausible_web/plugs/tracker.ex b/lib/plausible_web/plugs/tracker.ex
index 61a808e20..8252f04c4 100644
--- a/lib/plausible_web/plugs/tracker.ex
+++ b/lib/plausible_web/plugs/tracker.ex
@@ -63,6 +63,7 @@ defmodule PlausibleWeb.Tracker do
conn
|> put_resp_header("content-type", "application/javascript")
|> put_resp_header("cross-origin-resource-policy", "cross-origin")
+ |> put_resp_header("access-control-allow-origin", "*")
|> send_file(200, location)
|> halt()
end
diff --git a/lib/plausible_web/templates/layout/_tracking.html.eex b/lib/plausible_web/templates/layout/_tracking.html.eex
index e46d32836..e4bd69cd1 100644
--- a/lib/plausible_web/templates/layout/_tracking.html.eex
+++ b/lib/plausible_web/templates/layout/_tracking.html.eex
@@ -1,5 +1,5 @@
<%= if !Application.get_env(:plausible, :is_selfhost) && !@conn.assigns[:skip_plausible_tracking] do %>
-
+
<% end %>
diff --git a/priv/repo/migrations/20210629124428_cascade_site_deletion_to_invitations.exs b/priv/repo/migrations/20210629124428_cascade_site_deletion_to_invitations.exs
new file mode 100644
index 000000000..94982953e
--- /dev/null
+++ b/priv/repo/migrations/20210629124428_cascade_site_deletion_to_invitations.exs
@@ -0,0 +1,11 @@
+defmodule Plausible.Repo.Migrations.CascadeSiteDeletionToInvitations do
+ use Ecto.Migration
+
+ def change do
+ drop constraint("invitations", "invitations_site_id_fkey")
+
+ alter table(:invitations) do
+ modify :site_id, references(:sites, on_delete: :delete_all), null: false
+ end
+ end
+end