refactor: lint

This commit is contained in:
liyasthomas
2021-05-17 17:11:58 +05:30
parent f9821e5f80
commit e424d06026
7 changed files with 127 additions and 228 deletions

View File

@@ -1,19 +1,60 @@
<template>
<div class="page page-error">
<img src="~static/icons/error.svg" :alt="$t('error')" class="error_banner" />
<h2>{{ error.statusCode }}</h2>
<h3>{{ error.message }}</h3>
<p>
<h1 class="mb-4 font-mono text-4xl">{{ statusCode }}</h1>
<h3 class="mb-4 font-mono text-xs">{{ message }}</h3>
<p class="mt-4 border-t border-ttColor">
<nuxt-link to="/">
<button>{{ $t("go_home") }}</button>
<button class="icon">
<i class="material-icons">home</i>
<span>
{{ $t("go_home") }}
</span>
</button>
</nuxt-link>
</p>
<p>
<a href @click.prevent="reloadApplication">{{ $t("reload") }}</a>
<button class="icon" @click="reloadApplication">
<i class="material-icons">refresh</i>
<span>
{{ $t("reload") }}
</span>
</button>
</p>
</div>
</template>
<script>
export default {
props: {
error: {
type: Object,
default: null,
},
},
head() {
return {
bodyAttrs: {
class: "sticky-footer",
},
}
},
computed: {
statusCode() {
return (this.error && this.error.statusCode) || 500
},
message() {
return this.error.message || this.$t("something_went_wrong")
},
},
methods: {
reloadApplication() {
window.location.reload()
},
},
}
</script>
<style scoped lang="scss">
// Center the error page in the viewport.
.page-error {
@@ -25,26 +66,7 @@
}
.error_banner {
width: 256px;
@apply w-24;
@apply mb-12;
}
</style>
<script>
export default {
props: ["error"],
methods: {
reloadApplication() {
this.$router.push("/", () => window.location.reload())
},
},
head() {
return {
bodyAttrs: {
class: "sticky-footer",
},
}
},
}
</script>

View File

@@ -1,7 +1,7 @@
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
import clone from "lodash/clone"
import assign from "lodash/assign"
import eq from "lodash/eq"
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
function checkAndMigrateOldSettings() {
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
@@ -19,7 +19,9 @@ function checkAndMigrateOldSettings() {
}
function setupSettingsPersistence() {
const settingsData = JSON.parse(window.localStorage.getItem("settings") || "{}")
const settingsData = JSON.parse(
window.localStorage.getItem("settings") || "{}"
)
if (settingsData) {
bulkApplySettings(settingsData)

View File

@@ -1,8 +1,8 @@
import { pluck, distinctUntilChanged } from "rxjs/operators"
import has from "lodash/has"
import { Observable } from "rxjs"
import DispatchingStore from "./DispatchingStore"
import type { Dispatchers } from "./DispatchingStore"
import { Observable } from "rxjs"
import type { KeysMatching } from "~/types/ts-utils"
export const defaultSettings = {
@@ -32,9 +32,14 @@ const dispatchers: Dispatchers<SettingsType> = {
bulkApplySettings(_currentState, payload: Partial<SettingsType>) {
return payload
},
toggleSetting(currentState, { settingKey }: { settingKey: KeysMatching<SettingsType, boolean> }) {
toggleSetting(
currentState,
{ settingKey }: { settingKey: KeysMatching<SettingsType, boolean> }
) {
if (!has(currentState, settingKey)) {
console.log(`Toggling of a non-existent setting key '${settingKey}' ignored.`)
console.log(
`Toggling of a non-existent setting key '${settingKey}' ignored.`
)
return {}
}
@@ -48,7 +53,9 @@ const dispatchers: Dispatchers<SettingsType> = {
{ settingKey, value }: { settingKey: K; value: SettingsType[K] }
) {
if (!validKeys.includes(settingKey)) {
console.log(`Ignoring non-existent setting key '${settingKey}' assignment`)
console.log(
`Ignoring non-existent setting key '${settingKey}' assignment`
)
return {}
}
@@ -83,7 +90,10 @@ export function toggleSetting(settingKey: KeysMatching<SettingsType, boolean>) {
})
}
export function applySetting<K extends keyof SettingsType>(settingKey: K, value: SettingsType[K]) {
export function applySetting<K extends keyof SettingsType>(
settingKey: K,
value: SettingsType[K]
) {
settingsStore.dispatch({
dispatcher: "applySetting",
payload: {

View File

@@ -165,8 +165,8 @@ export default {
// ESLint module configuration (https://github.com/nuxt-community/eslint-module)
eslint: {
// fix: true,
// emitWarning: true,
// quiet: true,
emitWarning: true,
quiet: true,
},
// Toast module configuration (https://github.com/nuxt-community/modules/tree/master/packages/toast)

View File

@@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="f698cf57-4f6b-4529-a39c-70592e247574"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 840 726.8"
style="enable-background:new 0 0 840 726.8;" xml:space="preserve">
<style type="text/css">
.st0{opacity:0.8;}
.st1{fill:url(#SVGID_1_);}
.st2{fill:#38D39F;}
.st3{opacity:0.1;fill:#FFFFFF;enable-background:new ;}
.st4{opacity:0.3;}
.st5{fill:url(#SVGID_2_);}
.st6{fill:#FFFFFF;}
.st7{opacity:0.2;enable-background:new ;}
.st8{fill:#E0E0E0;}
.st9{opacity:0.5;}
.st10{fill:url(#SVGID_3_);}
.st11{opacity:0.1;enable-background:new ;}
.st12{fill:url(#SVGID_4_);}
.st13{opacity:5.000000e-02;enable-background:new ;}
.st14{opacity:0.5;fill:#4D8AF0;enable-background:new ;}
.st15{fill:#47E6B1;}
.st16{opacity:0.5;fill:#F55F44;enable-background:new ;}
</style>
<title>Taken</title>
<g class="st0">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="432" y1="482.23" x2="432" y2="709.15" gradientTransform="matrix(1 0 0 -1 0 728)">
<stop offset="0" style="stop-color:#808080;stop-opacity:0.25"/>
<stop offset="0.54" style="stop-color:#808080;stop-opacity:0.12"/>
<stop offset="1" style="stop-color:#808080;stop-opacity:0.1"/>
</linearGradient>
<ellipse class="st1" cx="432" cy="132.3" rx="146.5" ry="113.5"/>
</g>
<ellipse class="st2" cx="432" cy="132.3" rx="143.2" ry="110.9"/>
<path class="st3" d="M311.9,144.6c0-61.3,64.1-110.9,143.2-110.9c24.6-0.1,48.9,4.9,71.4,14.7c-25.2-17-58.1-27.3-94.1-27.3
c-79.1,0-143.2,49.7-143.2,110.9c0,41.1,28.9,77,71.9,96.2C330.9,207.9,311.9,178,311.9,144.6z"/>
<g class="st4">
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="463.2171" y1="-1222.5638" x2="463.2171" y2="-1037.1338" gradientTransform="matrix(0.95 0.32 0.32 -0.95 335.21 -678.07)">
<stop offset="0" style="stop-color:#808080;stop-opacity:0.25"/>
<stop offset="0.54" style="stop-color:#808080;stop-opacity:0.12"/>
<stop offset="1" style="stop-color:#808080;stop-opacity:0.1"/>
</linearGradient>
<path class="st5" d="M469.7,566.2l12.3-36.6c8.7-26.2-0.7-54.9-23.2-70.9l0.1-0.1c-4.8-3.4-10.2-6.1-15.8-8l0,0l-0.2-0.1l-0.2-0.1
l0,0c-5.5-1.8-11.1-2.9-16.9-3.2c-2-0.1-4.1-0.1-6.1,0c-3.5,0.2-7,0.7-10.5,1.5c-1,0.2-2,0.5-2.9,0.7s-1.9,0.6-2.9,0.9
c-1.9,0.6-3.8,1.3-5.6,2.2c-0.9,0.4-1.8,0.8-2.7,1.3c-2.7,1.3-5.3,2.9-7.8,4.6c-0.8,0.6-1.6,1.2-2.4,1.8
c-9.9,7.5-17.3,17.8-21.2,29.6l-19.4,57.6c-3.1,9-4,18.7-2.7,28.1c0.2,1.5,0.5,2.9,0.7,4.3s0.7,2.8,1,4.2c0.3,0.9,0.5,1.9,0.9,2.8
c0.5,1.4,1,2.7,1.5,4.1c0.4,0.9,0.8,1.8,1.2,2.7c0.8,1.8,1.7,3.5,2.7,5.1s2,3.3,3.2,4.9c0.8,1.2,1.7,2.3,2.7,3.5
c1.2,1.5,2.5,3,3.9,4.3c6,6,13.1,10.7,21,13.9l0,0l0,0l0.3,0.1c0.4-0.8,0.9-1.5,1.4-2.2c3-4.1,8.2-7,13.2-5.9
c0.4,0.1,0.7,0.2,1.1,0.3c2.5,0.9,5,2.5,7.4,3.3c1.8,0.8,3.8,0.8,5.6-0.1c4.9-2.6,3.1-10.8,7.2-14.3c0.2-0.2,0.4-0.3,0.6-0.5
c-0.1-0.1-0.1-0.1-0.2-0.2c3.2-2,7.7-0.7,11.4,0.6c4,1.4,9.2,2.4,12-0.9c1.9-2.2,1.7-5.7,3.5-8c2.1-2.7,6-3,9.4-2.5l0.2,0
c6.5,2.7,13.6-1.8,13.1-8.8C466.1,576.9,469,568.1,469.7,566.2z"/>
</g>
<path class="st6" d="M383.2,620.2c2.9-4,7.9-6.8,12.7-5.7s9.3,5.7,13.6,3.4c5.8-3.1,1.7-14.6,11.2-15.4c2-0.1,4,0.2,5.8,1
c4,1.6,10.3,3.5,13.3-0.2c1.8-2.2,1.7-5.5,3.4-7.7c2-2.6,5.8-2.9,9.1-2.4l0.2,0c6.3,2.6,13.1-1.7,12.6-8.5c-0.6-9,2.2-17.5,2.8-19.3
l11.9-35.3c10.5-31.5-6.4-65.6-37.8-76.3l0,0c-31.5-10.5-65.6,6.4-76.3,37.9L347,547.2c-10.1,30.3,5.2,63.3,34.8,75.2
C382.2,621.6,382.7,620.9,383.2,620.2z"/>
<circle class="st7" cx="405.4" cy="486.1" r="6.5"/>
<circle class="st7" cx="442.4" cy="498.5" r="6.5"/>
<ellipse transform="matrix(0.319 -0.9478 0.9478 0.319 -207.0136 746.0052)" class="st8" cx="415.6" cy="517" rx="9.8" ry="6.5"/>
<circle class="st6" cx="552.5" cy="487.5" r="9.8"/>
<circle class="st6" cx="583.5" cy="472.2" r="4.9"/>
<g class="st9">
<g class="st4">
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="350.3521" y1="-845.9339" x2="350.3521" y2="-660.5038" gradientTransform="matrix(0.95 0.32 0.32 -0.95 335.21 -678.07)">
<stop offset="0" style="stop-color:#808080;stop-opacity:0.25"/>
<stop offset="0.54" style="stop-color:#808080;stop-opacity:0.12"/>
<stop offset="1" style="stop-color:#808080;stop-opacity:0.1"/>
</linearGradient>
<path class="st10" d="M482.7,173.2l12.3-36.6c8.7-26.2-0.7-54.9-23.2-70.9l0.1-0.1c-4.8-3.4-10.2-6.1-15.8-8l0,0l-0.2-0.1
l-0.2-0.1l0,0c-5.5-1.8-11.1-2.9-16.9-3.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9-35.3c10.5-31.5-6.4-65.6-37.8-76.3l0,0c-31.5-10.5-65.6,6.4-76.3,37.9L360,154.2
c-10.1,30.3,5.2,63.3,34.8,75.1C395.2,228.6,395.7,227.9,396.2,227.2z"/>
<circle class="st7" cx="418.4" cy="93.1" r="6.5"/>
<circle class="st7" cx="455.4" cy="105.5" r="6.5"/>
</g>
<path class="st11" d="M569.5,99.4c1.9,7.2,2.8,14.6,2.8,22c0,61.3-64.1,110.9-143.2,110.9c-64.7,0-119.4-33.3-137.1-78.9
c13.1,50.8,71,89,140.4,89c79.1,0,143.2-49.7,143.2-110.9C575.6,120.5,573.5,109.6,569.5,99.4z"/>
<g class="st0">
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="432" y1="469.91" x2="432" y2="624.73" gradientTransform="matrix(1 0 0 -1 0 728)">
<stop offset="0" style="stop-color:#808080;stop-opacity:0.25"/>
<stop offset="0.54" style="stop-color:#808080;stop-opacity:0.12"/>
<stop offset="1" style="stop-color:#808080;stop-opacity:0.1"/>
</linearGradient>
<ellipse class="st12" cx="432" cy="180.7" rx="296.2" ry="77.4"/>
</g>
<path class="st6" d="M432,105.8c-158.2,0-286.4,33.5-286.4,74.9h572.8C718.4,139.3,590.2,105.8,432,105.8z"/>
<path class="st6" d="M432,255.5c158.2,0,286.4-33.5,286.4-74.9H145.6C145.6,222,273.8,255.5,432,255.5z"/>
<path class="st13" d="M432,255.5c158.2,0,286.4-33.5,286.4-74.9H145.6C145.6,222,273.8,255.5,432,255.5z"/>
<path class="st13" d="M312.5,161.1h239c9.5,0,17.2,7.7,17.2,17.2v4.6c0,9.5-7.7,17.2-17.2,17.2h-239c-9.5,0-17.2-7.7-17.2-17.2v-4.6
C295.3,168.9,303,161.1,312.5,161.1z"/>
<path class="st14" d="M133.9,57.8c-1.7-0.7-2.6-2.7-2-4.4c0-0.1,0.1-0.3,0.1-0.4l0,0c0.1-1-0.7-1.9-1.7-2c-0.6,0-1.2,0.2-1.6,0.7
l0,0c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2.6-4.4,2c-0.1,0-0.3-0.1-0.4-0.1l0,0c-1-0.2-2,0.4-2.2,1.4c-0.2,0.8,0.2,1.6,0.9,2l0,0
c0.1,0.1,0.2,0.2,0.4,0.2c1.7,0.8,2.5,2.7,2,4.4c0,0.1-0.1,0.3-0.1,0.4l0,0c-0.1,1,0.6,1.9,1.6,2c0.7,0.1,1.4-0.3,1.7-0.8l0,0
c0.1-0.1,0.1-0.2,0.2-0.4c0.8-1.7,2.7-2.6,4.4-2c0.1,0,0.3,0.1,0.4,0.1l0,0c1,0.1,1.9-0.7,2-1.7c0-0.6-0.2-1.2-0.7-1.6l0,0
C633.2,7,633,6.9,632.9,6.8z"/>
<g class="st9">
<rect x="110" y="257.9" class="st15" width="3" height="17"/>
<rect x="103" y="264.9" class="st15" width="17" height="3"/>
</g>
<g class="st9">
<rect x="830" y="177.9" class="st15" width="3" height="17"/>
<rect x="823" y="184.8" class="st15" width="17" height="3"/>
</g>
<g class="st9">
<rect x="730" y="456.9" class="st15" width="3" height="17"/>
<rect x="723" y="463.9" class="st15" width="17" height="3"/>
</g>
<circle class="st16" cx="723" cy="81.8" r="6"/>
<circle class="st16" cx="6" cy="12.9" r="6"/>
<circle class="st16" cx="186" cy="357.9" r="6"/>
<ellipse class="st13" cx="234" cy="154.4" rx="34" ry="7"/>
<ellipse class="st13" cx="234" cy="207.4" rx="34" ry="7"/>
<ellipse class="st13" cx="621" cy="154.4" rx="34" ry="7"/>
<ellipse class="st13" cx="621" cy="207.4" rx="34" ry="7"/>
<ellipse class="st13" cx="432" cy="124.4" rx="34" ry="7"/>
<ellipse class="st13" cx="457" cy="51.4" rx="34" ry="7"/>
<ellipse class="st13" cx="392" cy="81.4" rx="34" ry="7"/>
<ellipse class="st13" cx="517" cy="94.4" rx="34" ry="7"/>
<ellipse class="st13" cx="432" cy="228.4" rx="34" ry="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -70,8 +70,14 @@ export const state = () => ({
export const mutations = {
applySetting({ settings }, setting) {
if (setting === null || !(setting instanceof Array) || setting.length !== 2) {
throw new Error("You must provide a setting (array in the form [key, value])")
if (
setting === null ||
!(setting instanceof Array) ||
setting.length !== 2
) {
throw new Error(
"You must provide a setting (array in the form [key, value])"
)
}
const [key, value] = setting
@@ -127,7 +133,7 @@ export const mutations = {
state.environments = [...state.environments, ...environments]
let index = 0
for (let environment of state.environments) {
for (const environment of state.environments) {
environment.environmentIndex = index
index += 1
}
@@ -159,20 +165,22 @@ export const mutations = {
},
replaceCollections(state, item) {
let collections = item.data
const collections = item.data
const flag = item.flag
if (flag == "rest") state.collections = collections
if (flag === "rest") state.collections = collections
else state.collectionsGraphql = collections
},
importCollections(state, item) {
let collections = item.data
const collections = item.data
const flag = item.flag
if (flag == "rest") state.collections = [...state.collections, ...collections]
else state.collectionsGraphql = [...state.collectionsGraphql, ...collections]
if (flag === "rest")
state.collections = [...state.collections, ...collections]
else
state.collectionsGraphql = [...state.collectionsGraphql, ...collections]
let index = 0
for (let collection of collections) {
for (const collection of collections) {
collection.collectionIndex = index
index += 1
}
@@ -182,7 +190,7 @@ export const mutations = {
const name = collection.name
const flag = collection.flag
let duplicateCollection = null
if (flag == "rest") {
if (flag === "rest") {
duplicateCollection = collections.some(
(item) => item.name.toLowerCase() === name.toLowerCase()
)
@@ -195,7 +203,7 @@ export const mutations = {
this.$toast.info("Duplicate collection")
return
}
if (flag == "rest") {
if (flag === "rest") {
collections.push({
name: "",
folders: [],
@@ -214,7 +222,7 @@ export const mutations = {
removeCollection({ collections, collectionsGraphql }, payload) {
const { collectionIndex, flag } = payload
if (flag == "rest") collections.splice(collectionIndex, 1)
if (flag === "rest") collections.splice(collectionIndex, 1)
else collectionsGraphql.splice(collectionIndex, 1)
},
@@ -222,7 +230,7 @@ export const mutations = {
const { collection, collectionIndex, flag } = payload
const { name } = collection
let duplicateCollection = null
if (flag == "rest") {
if (flag === "rest") {
duplicateCollection = collections.some(
(item) => item.name.toLowerCase() === name.toLowerCase()
)
@@ -235,14 +243,14 @@ export const mutations = {
this.$toast.info("Duplicate collection")
return
}
if (flag == "rest") collections[collectionIndex] = collection
if (flag === "rest") collections[collectionIndex] = collection
else collectionsGraphql[collectionIndex] = collection
},
addFolder({ collections, collectionsGraphql }, payload) {
const { name, path, flag } = payload
const newFolder = {
name: name,
name,
requests: [],
folders: [],
}
@@ -251,7 +259,7 @@ export const mutations = {
const indexPaths = path.split("/").map((x) => parseInt(x))
let target = null
if (flag == "rest") target = collections[indexPaths.shift()]
if (flag === "rest") target = collections[indexPaths.shift()]
else target = collectionsGraphql[indexPaths.shift()]
while (indexPaths.length > 0) target = target.folders[indexPaths.shift()]
@@ -262,10 +270,10 @@ export const mutations = {
editFolder({ collections, collectionsGraphql }, payload) {
const { collectionIndex, folder, folderIndex, folderName, flag } = payload
let collection = null
if (flag == "rest") collection = collections[collectionIndex]
if (flag === "rest") collection = collections[collectionIndex]
else collection = collectionsGraphql[collectionIndex]
let parentFolder = findFolder(folderName, collection, true)
const parentFolder = findFolder(folderName, collection, true)
if (parentFolder && parentFolder.folders) {
Vue.set(parentFolder.folders, folderIndex, folder)
}
@@ -274,10 +282,10 @@ export const mutations = {
removeFolder({ collections, collectionsGraphql }, payload) {
const { collectionIndex, folderIndex, folderName, flag } = payload
let collection = null
if (flag == "rest") collection = collections[collectionIndex]
if (flag === "rest") collection = collections[collectionIndex]
else collection = collectionsGraphql[collectionIndex]
let parentFolder = findFolder(folderName, collection, true)
const parentFolder = findFolder(folderName, collection, true)
if (parentFolder && parentFolder.folders) {
parentFolder.folders.splice(folderIndex, 1)
}
@@ -293,7 +301,7 @@ export const mutations = {
flag,
} = payload
let collection = null
if (flag == "rest") collection = collections[requestCollectionIndex]
if (flag === "rest") collection = collections[requestCollectionIndex]
else collection = collectionsGraphql[requestCollectionIndex]
if (requestFolderIndex === -1) {
@@ -301,14 +309,15 @@ export const mutations = {
return
}
let folder = findFolder(requestFolderName, collection, false)
const folder = findFolder(requestFolderName, collection, false)
Vue.set(folder.requests, requestIndex, requestNew)
},
saveRequestAs({ collections, collectionsGraphql }, payload) {
let { request, collectionIndex, folderName, requestIndex, flag } = payload
let { request } = payload
const { collectionIndex, folderName, requestIndex, flag } = payload
if (flag == "rest") {
if (flag === "rest") {
// Filter out all file inputs
request = {
...request,
@@ -325,26 +334,30 @@ export const mutations = {
if (specifiedCollection && specifiedFolder && specifiedRequest) {
const folder = findFolder(
folderName,
flag == "rest" ? collections[collectionIndex] : collectionsGraphql[collectionIndex]
flag === "rest"
? collections[collectionIndex]
: collectionsGraphql[collectionIndex]
)
Vue.set(folder.requests, requestIndex, request)
} else if (specifiedCollection && specifiedFolder && !specifiedRequest) {
const folder = findFolder(
folderName,
flag == "rest" ? collections[collectionIndex] : collectionsGraphql[collectionIndex]
flag === "rest"
? collections[collectionIndex]
: collectionsGraphql[collectionIndex]
)
const requests = folder.requests
const lastRequestIndex = requests.length - 1
Vue.set(requests, lastRequestIndex + 1, request)
} else if (specifiedCollection && !specifiedFolder && specifiedRequest) {
const requests =
flag == "rest"
flag === "rest"
? collections[collectionIndex].requests
: collectionsGraphql[collectionIndex].requests
Vue.set(requests, requestIndex, request)
} else if (specifiedCollection && !specifiedFolder && !specifiedRequest) {
const requests =
flag == "rest"
flag === "rest"
? collections[collectionIndex].requests
: collectionsGraphql[collectionIndex].requests
const lastRequestIndex = requests.length - 1
@@ -355,14 +368,14 @@ export const mutations = {
removeRequest({ collections, collectionsGraphql }, payload) {
const { collectionIndex, folderName, requestIndex, flag } = payload
let collection = null
if (flag == "rest") collection = collections[collectionIndex]
if (flag === "rest") collection = collections[collectionIndex]
else collection = collectionsGraphql[collectionIndex]
if (collection.name === folderName) {
collection.requests.splice(requestIndex, 1)
return
}
let folder = findFolder(folderName, collection, false)
const folder = findFolder(folderName, collection, false)
if (folder) {
folder.requests.splice(requestIndex, 1)
@@ -389,10 +402,10 @@ export const mutations = {
} = payload
const isCollection = newFolderIndex === -1
let oldCollection = null
if (flag == "rest") oldCollection = collections[oldCollectionIndex]
if (flag === "rest") oldCollection = collections[oldCollectionIndex]
else oldCollection = collectionsGraphql[oldCollectionIndex]
let newCollection = null
if (flag == "rest") newCollection = collections[newCollectionIndex]
if (flag === "rest") newCollection = collections[newCollectionIndex]
else newCollection = collectionsGraphql[newCollectionIndex]
const request = findRequest(oldFolderName, oldCollection, requestIndex)
@@ -405,7 +418,6 @@ export const mutations = {
const folder = findFolder(newFolderName, newCollection, false)
if (folder) {
folder.requests.push(request)
return
}
}
},
@@ -424,7 +436,7 @@ function findRequest(folderName, currentFolder, requestIndex) {
let selectedFolder, result
if (folderName === currentFolder.name) {
let request = currentFolder.requests[requestIndex]
const request = currentFolder.requests[requestIndex]
currentFolder.requests.splice(requestIndex, 1)
return request
} else {
@@ -452,7 +464,12 @@ function findFolder(folderName, currentFolder, returnParent, parentFolder) {
for (let i = 0; i < currentFolder.folders.length; i++) {
selectedFolder = currentFolder.folders[i]
result = findFolder(folderName, selectedFolder, returnParent, currentFolder)
result = findFolder(
folderName,
selectedFolder,
returnParent,
currentFolder
)
if (result !== false) {
return result

4
types/ts-utils.d.ts vendored
View File

@@ -1 +1,3 @@
export type KeysMatching<T, V> = { [K in keyof T]-?: T[K] extends V ? K : never }[keyof T]
export type KeysMatching<T, V> = {
[K in keyof T]-?: T[K] extends V ? K : never
}[keyof T]