Merge branch 'newstate/collections' into main
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<SmartModal v-if="show" @close="hideModal">
|
<SmartModal v-if="show" @close="hideModal">
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
<h3 class="title">Export</h3>
|
<h3 class="title">{{ $t("import_export") }} {{ $t("collections") }}</h3>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
v-if="mode != 'import_export'"
|
v-if="mode != 'import_export'"
|
||||||
@@ -67,23 +67,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div slot="body" class="flex flex-col">
|
<div slot="body" class="flex flex-col">
|
||||||
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
|
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: !fb.currentUser
|
|
||||||
? $t('login_first')
|
|
||||||
: $t('replace_current'),
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
v-if="collectionsType.type == 'my-collections'"
|
|
||||||
:disabled="!fb.currentUser"
|
|
||||||
class="icon"
|
|
||||||
@click="syncCollections"
|
|
||||||
>
|
|
||||||
<i class="material-icons">folder_shared</i>
|
|
||||||
<span>{{ $t("import_from_sync") }}</span>
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
<button
|
<button
|
||||||
v-tooltip="$t('replace_current')"
|
v-tooltip="$t('replace_current')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@@ -194,8 +177,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import { fb } from "~/helpers/fb"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import * as teamUtils from "~/helpers/teams/utils"
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
|
import {
|
||||||
|
restCollections$,
|
||||||
|
setRESTCollections,
|
||||||
|
appendRESTCollections,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -204,25 +191,18 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
fb,
|
|
||||||
showJsonCode: false,
|
showJsonCode: false,
|
||||||
mode: "import_export",
|
mode: "import_export",
|
||||||
mySelectedCollectionID: undefined,
|
mySelectedCollectionID: undefined,
|
||||||
collectionJson: "",
|
collectionJson: "",
|
||||||
|
fb,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
subscriptions() {
|
||||||
return {
|
return {
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
myCollections: restCollections$,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
myCollections() {
|
|
||||||
return fb.currentUser !== null
|
|
||||||
? fb.currentCollections
|
|
||||||
: this.$store.state.postwoman.collections
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async createCollectionGist() {
|
async createCollectionGist() {
|
||||||
await this.$axios
|
await this.$axios
|
||||||
@@ -266,12 +246,8 @@ export default {
|
|||||||
})
|
})
|
||||||
.then(({ files }) => {
|
.then(({ files }) => {
|
||||||
const collections = JSON.parse(Object.values(files)[0].content)
|
const collections = JSON.parse(Object.values(files)[0].content)
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
setRESTCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.failedImport()
|
this.failedImport()
|
||||||
@@ -330,12 +306,8 @@ export default {
|
|||||||
this.failedImport()
|
this.failedImport()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
setRESTCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
||||||
@@ -388,11 +360,7 @@ export default {
|
|||||||
this.failedImport()
|
this.failedImport()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit("postwoman/importCollections", {
|
appendRESTCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.syncToFBCollections()
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,11 +389,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async getJSONCollection() {
|
async getJSONCollection() {
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.collectionJson = JSON.stringify(
|
this.collectionJson = JSON.stringify(this.myCollections, null, 2)
|
||||||
this.$store.state.postwoman.collections,
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
this.collectionJson = await teamUtils.exportAsJSON(
|
this.collectionJson = await teamUtils.exportAsJSON(
|
||||||
this.$apollo,
|
this.$apollo,
|
||||||
@@ -452,21 +416,6 @@ export default {
|
|||||||
icon: "done",
|
icon: "done",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
|
||||||
data: fb.currentCollections,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
|
||||||
},
|
|
||||||
syncToFBCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fileImported() {
|
fileImported() {
|
||||||
this.$toast.info(this.$t("file_imported"), {
|
this.$toast.info(this.$t("file_imported"), {
|
||||||
icon: "folder_shared",
|
icon: "folder_shared",
|
||||||
|
|||||||
@@ -20,7 +20,18 @@
|
|||||||
/>
|
/>
|
||||||
<label for="selectLabel">Select location</label>
|
<label for="selectLabel">Select location</label>
|
||||||
<!-- <input readonly :value="path" /> -->
|
<!-- <input readonly :value="path" /> -->
|
||||||
|
|
||||||
|
<CollectionsGraphql
|
||||||
|
v-if="mode === 'graphql'"
|
||||||
|
:doc="false"
|
||||||
|
:show-coll-actions="false"
|
||||||
|
:picked="picked"
|
||||||
|
:saving-mode="true"
|
||||||
|
@select="onSelect"
|
||||||
|
/>
|
||||||
|
|
||||||
<Collections
|
<Collections
|
||||||
|
v-else
|
||||||
:picked="picked"
|
:picked="picked"
|
||||||
:save-request="true"
|
:save-request="true"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
@@ -45,12 +56,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
import { getSettingSubject } from "~/newstore/settings"
|
||||||
import * as teamUtils from "~/helpers/teams/utils"
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
|
import {
|
||||||
|
saveRESTRequestAs,
|
||||||
|
editRESTRequest,
|
||||||
|
editGraphqlRequest,
|
||||||
|
saveGraphqlRequestAs,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
// mode can be either "graphql" or "rest"
|
||||||
|
mode: { type: String, default: "rest" },
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
editingRequest: { type: Object, default: () => {} },
|
editingRequest: { type: Object, default: () => {} },
|
||||||
},
|
},
|
||||||
@@ -138,14 +156,6 @@ export default {
|
|||||||
onSelect({ picked }) {
|
onSelect({ picked }) {
|
||||||
this.picked = picked
|
this.picked = picked
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveRequestAs() {
|
saveRequestAs() {
|
||||||
if (this.picked == null) {
|
if (this.picked == null) {
|
||||||
this.$toast.error(this.$t("select_collection"), {
|
this.$toast.error(this.$t("select_collection"), {
|
||||||
@@ -163,36 +173,25 @@ export default {
|
|||||||
const requestUpdated = {
|
const requestUpdated = {
|
||||||
...this.$props.editingRequest,
|
...this.$props.editingRequest,
|
||||||
name: this.$data.requestData.name,
|
name: this.$data.requestData.name,
|
||||||
collection: this.$data.requestData.collectionIndex,
|
}
|
||||||
|
|
||||||
|
// Filter out all REST file inputs
|
||||||
|
if (this.mode === "rest" && requestUpdated.bodyParams) {
|
||||||
|
requestUpdated.bodyParams = requestUpdated.bodyParams.map((param) =>
|
||||||
|
param?.value?.[0] instanceof File ? { ...param, value: "" } : param
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.picked.pickedType === "my-request") {
|
if (this.picked.pickedType === "my-request") {
|
||||||
this.$store.commit("postwoman/saveRequestAs", {
|
editRESTRequest(
|
||||||
request: requestUpdated,
|
this.picked.folderPath,
|
||||||
collectionIndex: this.picked.collectionIndex,
|
this.picked.requestIndex,
|
||||||
folderName: this.picked.folderName,
|
requestUpdated
|
||||||
requestIndex: this.picked.requestIndex,
|
)
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (this.picked.pickedType === "my-folder") {
|
} else if (this.picked.pickedType === "my-folder") {
|
||||||
this.$store.commit("postwoman/saveRequestAs", {
|
saveRESTRequestAs(this.picked.folderPath, requestUpdated)
|
||||||
request: requestUpdated,
|
|
||||||
collectionIndex: this.picked.collectionIndex,
|
|
||||||
folderName: this.picked.folderName,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (this.picked.pickedType === "my-collection") {
|
} else if (this.picked.pickedType === "my-collection") {
|
||||||
this.$store.commit("postwoman/saveRequestAs", {
|
saveRESTRequestAs(`${this.picked.collectionIndex}`, requestUpdated)
|
||||||
request: requestUpdated,
|
|
||||||
collectionIndex: this.picked.collectionIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (this.picked.pickedType === "teams-request") {
|
} else if (this.picked.pickedType === "teams-request") {
|
||||||
teamUtils.overwriteRequestTeams(
|
teamUtils.overwriteRequestTeams(
|
||||||
this.$apollo,
|
this.$apollo,
|
||||||
@@ -216,6 +215,16 @@ export default {
|
|||||||
this.collectionsType.selectedTeam.id,
|
this.collectionsType.selectedTeam.id,
|
||||||
this.picked.collectionID
|
this.picked.collectionID
|
||||||
)
|
)
|
||||||
|
} else if (this.picked.pickedType === "gql-my-request") {
|
||||||
|
editGraphqlRequest(
|
||||||
|
this.picked.folderPath,
|
||||||
|
this.picked.requestIndex,
|
||||||
|
requestUpdated
|
||||||
|
)
|
||||||
|
} else if (this.picked.pickedType === "gql-my-folder") {
|
||||||
|
saveGraphqlRequestAs(this.picked.folderPath, requestUpdated)
|
||||||
|
} else if (this.picked.pickedType === "gql-my-collection") {
|
||||||
|
saveGraphqlRequestAs(`${this.picked.collectionIndex}`, requestUpdated)
|
||||||
}
|
}
|
||||||
this.$toast.success("Requested added", {
|
this.$toast.success("Requested added", {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
|
|||||||
@@ -36,41 +36,32 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { addGraphqlCollection } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: null,
|
name: null as string | null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addNewCollection() {
|
addNewCollection() {
|
||||||
if (!this.$data.name) {
|
if (!this.name) {
|
||||||
this.$toast.info(this.$t("invalid_collection_name"))
|
this.$toast.info(this.$t("invalid_collection_name").toString())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$store.commit("postwoman/addNewCollection", {
|
|
||||||
name: this.$data.name,
|
addGraphqlCollection({
|
||||||
flag: "graphql",
|
name: this.name,
|
||||||
|
folders: [],
|
||||||
|
requests: [],
|
||||||
})
|
})
|
||||||
this.syncCollections()
|
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
@@ -78,5 +69,5 @@ export default {
|
|||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,13 +36,12 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
folder: { type: Object, default: () => {} },
|
|
||||||
folderPath: { type: String, default: null },
|
folderPath: { type: String, default: null },
|
||||||
collectionIndex: { type: Number, default: null },
|
collectionIndex: { type: Number, default: null },
|
||||||
},
|
},
|
||||||
@@ -52,25 +51,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addFolder() {
|
addFolder() {
|
||||||
|
// TODO: Blocking when name is null ?
|
||||||
|
|
||||||
this.$emit("add-folder", {
|
this.$emit("add-folder", {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
folder: this.folder,
|
|
||||||
path: this.folderPath || `${this.collectionIndex}`,
|
path: this.folderPath || `${this.collectionIndex}`,
|
||||||
})
|
})
|
||||||
this.syncCollections()
|
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
@@ -78,5 +65,5 @@ export default {
|
|||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -19,7 +19,12 @@
|
|||||||
<i v-show="showChildren || isFiltered" class="material-icons"
|
<i v-show="showChildren || isFiltered" class="material-icons"
|
||||||
>arrow_drop_down</i
|
>arrow_drop_down</i
|
||||||
>
|
>
|
||||||
<i class="material-icons">folder</i>
|
|
||||||
|
<i v-if="isSelected" class="mx-3 text-green-400 material-icons"
|
||||||
|
>check_circle</i
|
||||||
|
>
|
||||||
|
|
||||||
|
<i v-else class="material-icons">folder</i>
|
||||||
<span>{{ collection.name }}</span>
|
<span>{{ collection.name }}</span>
|
||||||
</button>
|
</button>
|
||||||
<div>
|
<div>
|
||||||
@@ -31,7 +36,7 @@
|
|||||||
>
|
>
|
||||||
<i class="material-icons">topic</i>
|
<i class="material-icons">topic</i>
|
||||||
</button>
|
</button>
|
||||||
<v-popover>
|
<v-popover v-if="!savingMode">
|
||||||
<button v-tooltip.left="$t('more')" class="tooltip-target icon">
|
<button v-tooltip.left="$t('more')" class="tooltip-target icon">
|
||||||
<i class="material-icons">more_vert</i>
|
<i class="material-icons">more_vert</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -42,7 +47,6 @@
|
|||||||
class="icon"
|
class="icon"
|
||||||
@click="
|
@click="
|
||||||
$emit('add-folder', {
|
$emit('add-folder', {
|
||||||
folder: collection,
|
|
||||||
path: `${collectionIndex}`,
|
path: `${collectionIndex}`,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
@@ -83,6 +87,8 @@
|
|||||||
class="ml-8 border-l border-brdColor"
|
class="ml-8 border-l border-brdColor"
|
||||||
>
|
>
|
||||||
<CollectionsGraphqlFolder
|
<CollectionsGraphqlFolder
|
||||||
|
:picked="picked"
|
||||||
|
:saving-mode="savingMode"
|
||||||
:folder="folder"
|
:folder="folder"
|
||||||
:folder-index="index"
|
:folder-index="index"
|
||||||
:folder-path="`${collectionIndex}/${index}`"
|
:folder-path="`${collectionIndex}/${index}`"
|
||||||
@@ -92,6 +98,7 @@
|
|||||||
@add-folder="$emit('add-folder', $event)"
|
@add-folder="$emit('add-folder', $event)"
|
||||||
@edit-folder="$emit('edit-folder', $event)"
|
@edit-folder="$emit('edit-folder', $event)"
|
||||||
@edit-request="$emit('edit-request', $event)"
|
@edit-request="$emit('edit-request', $event)"
|
||||||
|
@select="$emit('select', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -102,13 +109,17 @@
|
|||||||
class="ml-8 border-l border-brdColor"
|
class="ml-8 border-l border-brdColor"
|
||||||
>
|
>
|
||||||
<CollectionsGraphqlRequest
|
<CollectionsGraphqlRequest
|
||||||
|
:picked="picked"
|
||||||
|
:saving-mode="savingMode"
|
||||||
:request="request"
|
:request="request"
|
||||||
:collection-index="collectionIndex"
|
:collection-index="collectionIndex"
|
||||||
:folder-index="-1"
|
:folder-index="-1"
|
||||||
:folder-name="collection.name"
|
:folder-name="collection.name"
|
||||||
|
:folder-path="`${collectionIndex}`"
|
||||||
:request-index="index"
|
:request-index="index"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
@edit-request="$emit('edit-request', $event)"
|
@edit-request="$emit('edit-request', $event)"
|
||||||
|
@select="$emit('select', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -135,11 +146,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import {
|
||||||
|
removeGraphqlCollection,
|
||||||
|
moveGraphqlRequest,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
picked: { type: Object, default: null },
|
||||||
|
// Whether the viewing context is related to picking (activates 'select' events)
|
||||||
|
savingMode: { type: Boolean, default: false },
|
||||||
collectionIndex: { type: Number, default: null },
|
collectionIndex: { type: Number, default: null },
|
||||||
collection: { type: Object, default: () => {} },
|
collection: { type: Object, default: () => {} },
|
||||||
doc: Boolean,
|
doc: Boolean,
|
||||||
@@ -153,51 +171,46 @@ export default {
|
|||||||
confirmRemove: false,
|
confirmRemove: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isSelected(): boolean {
|
||||||
|
return (
|
||||||
|
this.picked &&
|
||||||
|
this.picked.pickedType === "gql-my-collection" &&
|
||||||
|
this.picked.collectionIndex === this.collectionIndex
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
pick() {
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
this.$emit("select", {
|
||||||
if (fb.currentSettings[0].value) {
|
picked: {
|
||||||
fb.writeCollections(
|
pickedType: "gql-my-collection",
|
||||||
JSON.parse(
|
collectionIndex: this.collectionIndex,
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
},
|
||||||
),
|
})
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
toggleShowChildren() {
|
toggleShowChildren() {
|
||||||
|
if (this.savingMode) {
|
||||||
|
this.pick()
|
||||||
|
}
|
||||||
|
|
||||||
this.showChildren = !this.showChildren
|
this.showChildren = !this.showChildren
|
||||||
},
|
},
|
||||||
removeCollection() {
|
removeCollection() {
|
||||||
this.$store.commit("postwoman/removeCollection", {
|
removeGraphqlCollection(this.collectionIndex)
|
||||||
collectionIndex: this.collectionIndex,
|
|
||||||
flag: "graphql",
|
this.$toast.error(this.$t("deleted").toString(), {
|
||||||
})
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }: any) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "graphql"
|
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
moveGraphqlRequest(folderPath, requestIndex, `${this.collectionIndex}`)
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: -1,
|
|
||||||
newFolderName: this.$props.collection.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,10 +36,11 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { editGraphqlCollection } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
editingCollection: { type: Object, default: () => {} },
|
editingCollection: { type: Object, default: () => {} },
|
||||||
@@ -47,37 +48,21 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: null,
|
name: null as string | null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveCollection() {
|
saveCollection() {
|
||||||
if (!this.$data.name) {
|
if (!this.name) {
|
||||||
this.$toast.info(this.$t("invalid_collection_name"))
|
this.$toast.info(this.$t("invalid_collection_name").toString())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const collectionUpdated = {
|
const collectionUpdated = {
|
||||||
...this.$props.editingCollection,
|
...this.$props.editingCollection,
|
||||||
name: this.$data.name,
|
name: this.name,
|
||||||
}
|
}
|
||||||
this.$store.commit("postwoman/editCollection", {
|
|
||||||
collection: collectionUpdated,
|
editGraphqlCollection(this.editingCollectionIndex, collectionUpdated)
|
||||||
collectionIndex: this.$props.editingCollectionIndex,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
@@ -85,5 +70,5 @@ export default {
|
|||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,15 +36,15 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { editGraphqlFolder } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
collectionIndex: { type: Number, default: null },
|
|
||||||
folder: { type: Object, default: () => {} },
|
folder: { type: Object, default: () => {} },
|
||||||
folderIndex: { type: Number, default: null },
|
folderPath: { type: String, default: null },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -52,27 +52,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
editFolder() {
|
editFolder() {
|
||||||
this.$store.commit("postwoman/editFolder", {
|
editGraphqlFolder(this.folderPath, { ...this.folder, name: this.name })
|
||||||
collectionIndex: this.$props.collectionIndex,
|
|
||||||
folder: { ...this.$props.folder, name: this.$data.name },
|
|
||||||
folderIndex: this.$props.folderIndex,
|
|
||||||
folderName: this.$props.folder.name,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
@@ -80,5 +61,5 @@ export default {
|
|||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,53 +36,33 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { editGraphqlRequest } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
collectionIndex: { type: Number, default: null },
|
folderPath: { type: String, default: null },
|
||||||
folderIndex: { type: Number, default: null },
|
|
||||||
folderName: { type: String, default: null },
|
|
||||||
request: { type: Object, default: () => {} },
|
request: { type: Object, default: () => {} },
|
||||||
requestIndex: { type: Number, default: null },
|
requestIndex: { type: Number, default: null },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
requestUpdateData: {
|
requestUpdateData: {
|
||||||
name: null,
|
name: null as any | null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveRequest() {
|
saveRequest() {
|
||||||
const requestUpdated = {
|
const requestUpdated = {
|
||||||
...this.$props.request,
|
...this.$props.request,
|
||||||
name: this.$data.requestUpdateData.name || this.$props.request.name,
|
name: this.$data.requestUpdateData.name || this.$props.request.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit("postwoman/editRequest", {
|
editGraphqlRequest(this.folderPath, this.requestIndex, requestUpdated)
|
||||||
requestCollectionIndex: this.$props.collectionIndex,
|
|
||||||
requestFolderName: this.$props.folderName,
|
|
||||||
requestFolderIndex: this.$props.folderIndex,
|
|
||||||
requestNew: requestUpdated,
|
|
||||||
requestIndex: this.$props.requestIndex,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
@@ -90,5 +70,5 @@ export default {
|
|||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -20,11 +20,15 @@
|
|||||||
<i v-show="showChildren || isFiltered" class="material-icons"
|
<i v-show="showChildren || isFiltered" class="material-icons"
|
||||||
>arrow_drop_down</i
|
>arrow_drop_down</i
|
||||||
>
|
>
|
||||||
<i class="material-icons">folder_open</i>
|
<i v-if="isSelected" class="mx-3 text-green-400 material-icons"
|
||||||
|
>check_circle</i
|
||||||
|
>
|
||||||
|
|
||||||
|
<i v-else class="material-icons">folder_open</i>
|
||||||
<span>{{ folder.name }}</span>
|
<span>{{ folder.name }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<v-popover>
|
<v-popover v-if="!savingMode">
|
||||||
<button v-tooltip.left="$t('more')" class="tooltip-target icon">
|
<button v-tooltip.left="$t('more')" class="tooltip-target icon">
|
||||||
<i class="material-icons">more_vert</i>
|
<i class="material-icons">more_vert</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -43,9 +47,7 @@
|
|||||||
<button
|
<button
|
||||||
v-close-popover
|
v-close-popover
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="
|
@click="$emit('edit-folder', { folder, folderPath })"
|
||||||
$emit('edit-folder', { folder, folderIndex, collectionIndex })
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">edit</i>
|
<i class="material-icons">edit</i>
|
||||||
<span>{{ $t("edit") }}</span>
|
<span>{{ $t("edit") }}</span>
|
||||||
@@ -68,6 +70,8 @@
|
|||||||
class="ml-8 border-l border-brdColor"
|
class="ml-8 border-l border-brdColor"
|
||||||
>
|
>
|
||||||
<CollectionsGraphqlFolder
|
<CollectionsGraphqlFolder
|
||||||
|
:picked="picked"
|
||||||
|
:saving-mode="savingMode"
|
||||||
:folder="subFolder"
|
:folder="subFolder"
|
||||||
:folder-index="subFolderIndex"
|
:folder-index="subFolderIndex"
|
||||||
:folder-path="`${folderPath}/${subFolderIndex}`"
|
:folder-path="`${folderPath}/${subFolderIndex}`"
|
||||||
@@ -77,6 +81,7 @@
|
|||||||
@add-folder="$emit('add-folder', $event)"
|
@add-folder="$emit('add-folder', $event)"
|
||||||
@edit-folder="$emit('edit-folder', $event)"
|
@edit-folder="$emit('edit-folder', $event)"
|
||||||
@edit-request="$emit('edit-request', $event)"
|
@edit-request="$emit('edit-request', $event)"
|
||||||
|
@select="$emit('select', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -87,13 +92,17 @@
|
|||||||
class="flex ml-8 border-l border-brdColor"
|
class="flex ml-8 border-l border-brdColor"
|
||||||
>
|
>
|
||||||
<CollectionsGraphqlRequest
|
<CollectionsGraphqlRequest
|
||||||
|
:picked="picked"
|
||||||
|
:saving-mode="savingMode"
|
||||||
:request="request"
|
:request="request"
|
||||||
:collection-index="collectionIndex"
|
:collection-index="collectionIndex"
|
||||||
:folder-index="folderIndex"
|
:folder-index="folderIndex"
|
||||||
|
:folder-path="folderPath"
|
||||||
:folder-name="folder.name"
|
:folder-name="folder.name"
|
||||||
:request-index="index"
|
:request-index="index"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
@edit-request="$emit('edit-request', $event)"
|
@edit-request="$emit('edit-request', $event)"
|
||||||
|
@select="$emit('select', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -122,12 +131,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { removeGraphqlFolder, moveGraphqlRequest } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
name: "Folder",
|
name: "Folder",
|
||||||
props: {
|
props: {
|
||||||
|
picked: { type: Object, default: null },
|
||||||
|
// Whether the request is in a selectable mode (activates 'select' event)
|
||||||
|
savingMode: { type: Boolean, default: false },
|
||||||
folder: { type: Object, default: () => {} },
|
folder: { type: Object, default: () => {} },
|
||||||
folderIndex: { type: Number, default: null },
|
folderIndex: { type: Number, default: null },
|
||||||
collectionIndex: { type: Number, default: null },
|
collectionIndex: { type: Number, default: null },
|
||||||
@@ -142,54 +155,44 @@ export default {
|
|||||||
confirmRemove: false,
|
confirmRemove: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isSelected(): boolean {
|
||||||
|
return (
|
||||||
|
this.picked &&
|
||||||
|
this.picked.pickedType === "gql-my-folder" &&
|
||||||
|
this.picked.folderPath === this.folderPath
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
pick() {
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
this.$emit("select", {
|
||||||
if (fb.currentSettings[0].value) {
|
picked: {
|
||||||
fb.writeCollections(
|
pickedType: "gql-my-folder",
|
||||||
JSON.parse(
|
folderPath: this.folderPath,
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
},
|
||||||
),
|
})
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
toggleShowChildren() {
|
toggleShowChildren() {
|
||||||
|
if (this.savingMode) {
|
||||||
|
this.pick()
|
||||||
|
}
|
||||||
|
|
||||||
this.showChildren = !this.showChildren
|
this.showChildren = !this.showChildren
|
||||||
},
|
},
|
||||||
removeFolder() {
|
removeFolder() {
|
||||||
this.$store.commit("postwoman/removeFolder", {
|
removeGraphqlFolder(this.folderPath)
|
||||||
collectionIndex: this.$props.collectionIndex,
|
this.$toast.error(this.$t("deleted").toString(), {
|
||||||
folderName: this.$props.folder.name,
|
|
||||||
folderIndex: this.$props.folderIndex,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }: any) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "graphql"
|
|
||||||
|
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
moveGraphqlRequest(folderPath, requestIndex, this.folderPath)
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: this.$props.folderIndex,
|
|
||||||
newFolderName: this.$props.folder.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -54,22 +54,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div slot="body" class="flex flex-col">
|
<div slot="body" class="flex flex-col">
|
||||||
<div class="flex flex-col items-start p-2">
|
<div class="flex flex-col items-start p-2">
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: !fb.currentUser
|
|
||||||
? $t('login_first')
|
|
||||||
: $t('replace_current'),
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
:disabled="!fb.currentUser"
|
|
||||||
class="icon"
|
|
||||||
@click="syncCollections"
|
|
||||||
>
|
|
||||||
<i class="material-icons">folder_shared</i>
|
|
||||||
<span>{{ $t("import_from_sync") }}</span>
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
<button
|
<button
|
||||||
v-tooltip="$t('replace_current')"
|
v-tooltip="$t('replace_current')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@@ -131,6 +115,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import { fb } from "~/helpers/fb"
|
||||||
|
import {
|
||||||
|
graphqlCollections$,
|
||||||
|
setGraphqlCollections,
|
||||||
|
appendGraphqlCollections,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -142,13 +131,14 @@ export default {
|
|||||||
showJsonCode: false,
|
showJsonCode: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
subscriptions() {
|
||||||
|
return {
|
||||||
|
collections: graphqlCollections$,
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
collectionJson() {
|
collectionJson() {
|
||||||
return JSON.stringify(
|
return JSON.stringify(this.collections, null, 2)
|
||||||
this.$store.state.postwoman.collectionsGraphql,
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -194,12 +184,8 @@ export default {
|
|||||||
})
|
})
|
||||||
.then(({ files }) => {
|
.then(({ files }) => {
|
||||||
const collections = JSON.parse(Object.values(files)[0].content)
|
const collections = JSON.parse(Object.values(files)[0].content)
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
setGraphqlCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.failedImport()
|
this.failedImport()
|
||||||
@@ -238,12 +224,8 @@ export default {
|
|||||||
this.failedImport()
|
this.failedImport()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
setGraphqlCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
}
|
}
|
||||||
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
||||||
this.$refs.inputChooseFileToReplaceWith.value = ""
|
this.$refs.inputChooseFileToReplaceWith.value = ""
|
||||||
@@ -275,12 +257,8 @@ export default {
|
|||||||
this.failedImport()
|
this.failedImport()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$store.commit("postwoman/importCollections", {
|
appendGraphqlCollections(collections)
|
||||||
data: collections,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
}
|
}
|
||||||
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0])
|
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0])
|
||||||
this.$refs.inputChooseFileToImportFrom.value = ""
|
this.$refs.inputChooseFileToImportFrom.value = ""
|
||||||
@@ -303,25 +281,6 @@ export default {
|
|||||||
icon: "done",
|
icon: "done",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
this.$store.commit("postwoman/replaceCollections", {
|
|
||||||
data: fb.currentGraphqlCollections,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.fileImported()
|
|
||||||
},
|
|
||||||
syncToFBCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fileImported() {
|
fileImported() {
|
||||||
this.$toast.info(this.$t("file_imported"), {
|
this.$toast.info(this.$t("file_imported"), {
|
||||||
icon: "folder_shared",
|
icon: "folder_shared",
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
class="icon"
|
class="icon"
|
||||||
@click="!doc ? selectRequest() : {}"
|
@click="!doc ? selectRequest() : {}"
|
||||||
>
|
>
|
||||||
<i class="material-icons">description</i>
|
<i v-if="isSelected" class="mx-3 text-green-400 material-icons"
|
||||||
|
>check_circle</i
|
||||||
|
>
|
||||||
|
|
||||||
|
<i v-else class="material-icons">description</i>
|
||||||
<span>{{ request.name }}</span>
|
<span>{{ request.name }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<v-popover>
|
<v-popover v-if="!savingMode">
|
||||||
<button v-tooltip="$t('more')" class="tooltip-target icon">
|
<button v-tooltip="$t('more')" class="tooltip-target icon">
|
||||||
<i class="material-icons">more_vert</i>
|
<i class="material-icons">more_vert</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -32,11 +36,9 @@
|
|||||||
class="icon"
|
class="icon"
|
||||||
@click="
|
@click="
|
||||||
$emit('edit-request', {
|
$emit('edit-request', {
|
||||||
collectionIndex,
|
|
||||||
folderIndex,
|
|
||||||
folderName,
|
|
||||||
request,
|
request,
|
||||||
requestIndex,
|
requestIndex,
|
||||||
|
folderPath,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -62,15 +64,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { fb } from "~/helpers/fb"
|
import Vue from "vue"
|
||||||
|
import { removeGraphqlRequest } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
// Whether the object is selected (show the tick mark)
|
||||||
|
picked: { type: Object, default: null },
|
||||||
|
// Whether the request is being saved (activate 'select' event)
|
||||||
|
savingMode: { type: Boolean, default: false },
|
||||||
request: { type: Object, default: () => {} },
|
request: { type: Object, default: () => {} },
|
||||||
collectionIndex: { type: Number, default: null },
|
folderPath: { type: String, default: null },
|
||||||
folderIndex: { type: Number, default: null },
|
|
||||||
folderName: { type: String, default: null },
|
|
||||||
requestIndex: { type: Number, default: null },
|
requestIndex: { type: Number, default: null },
|
||||||
doc: Boolean,
|
doc: Boolean,
|
||||||
},
|
},
|
||||||
@@ -80,44 +85,49 @@ export default {
|
|||||||
confirmRemove: false,
|
confirmRemove: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isSelected(): boolean {
|
||||||
|
return (
|
||||||
|
this.picked &&
|
||||||
|
this.picked.pickedType === "gql-my-request" &&
|
||||||
|
this.picked.folderPath === this.folderPath &&
|
||||||
|
this.picked.requestIndex === this.requestIndex
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
pick() {
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
this.$emit("select", {
|
||||||
if (fb.currentSettings[0].value) {
|
picked: {
|
||||||
fb.writeCollections(
|
pickedType: "gql-my-request",
|
||||||
JSON.parse(
|
folderPath: this.folderPath,
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
requestIndex: this.requestIndex,
|
||||||
),
|
},
|
||||||
"collectionsGraphql"
|
})
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
selectRequest() {
|
selectRequest() {
|
||||||
|
if (this.savingMode) {
|
||||||
|
this.pick()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.$store.commit("postwoman/selectGraphqlRequest", {
|
this.$store.commit("postwoman/selectGraphqlRequest", {
|
||||||
request: this.request,
|
request: this.request,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dragStart({ dataTransfer }) {
|
dragStart({ dataTransfer }: any) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex)
|
|
||||||
dataTransfer.setData("oldFolderIndex", this.$props.folderIndex)
|
dataTransfer.setData("folderPath", this.folderPath)
|
||||||
dataTransfer.setData("oldFolderName", this.$props.folderName)
|
dataTransfer.setData("requestIndex", this.requestIndex)
|
||||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
|
||||||
},
|
},
|
||||||
removeRequest() {
|
removeRequest() {
|
||||||
this.$store.commit("postwoman/removeRequest", {
|
removeGraphqlRequest(this.folderPath, this.requestIndex)
|
||||||
collectionIndex: this.$props.collectionIndex,
|
this.$toast.error(this.$t("deleted").toString(), {
|
||||||
folderName: this.$props.folderName,
|
|
||||||
requestIndex: this.$props.requestIndex,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
this.confirmRemove = false
|
this.confirmRemove = false
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,253 +0,0 @@
|
|||||||
<template>
|
|
||||||
<SmartModal v-if="show" @close="hideModal">
|
|
||||||
<div slot="header">
|
|
||||||
<div class="row-wrapper">
|
|
||||||
<h3 class="title">{{ $t("save_request_as") }}</h3>
|
|
||||||
<div>
|
|
||||||
<button class="icon" @click="hideModal">
|
|
||||||
<i class="material-icons">close</i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div slot="body" class="flex flex-col">
|
|
||||||
<label for="selectLabel">{{ $t("token_req_name") }}</label>
|
|
||||||
<input
|
|
||||||
id="selectLabel"
|
|
||||||
v-model="requestData.name"
|
|
||||||
type="text"
|
|
||||||
@keyup.enter="saveRequestAs"
|
|
||||||
/>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<label for="selectCollection">{{ $t("collection") }}</label>
|
|
||||||
<span class="select-wrapper">
|
|
||||||
<select
|
|
||||||
id="selectCollection"
|
|
||||||
v-model="requestData.collectionIndex"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
:key="undefined"
|
|
||||||
:value="undefined"
|
|
||||||
hidden
|
|
||||||
disabled
|
|
||||||
selected
|
|
||||||
>
|
|
||||||
{{ $t("select_collection") }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="(collection, index) in $store.state.postwoman
|
|
||||||
.collectionsGraphql"
|
|
||||||
:key="index"
|
|
||||||
:value="index"
|
|
||||||
>
|
|
||||||
{{ collection.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<label>{{ $t("folder") }}</label>
|
|
||||||
<SmartAutoComplete
|
|
||||||
v-model="requestData.folderName"
|
|
||||||
:placeholder="$t('search')"
|
|
||||||
:source="folders"
|
|
||||||
:spellcheck="false"
|
|
||||||
/>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<label for="selectRequest">{{ $t("request") }}</label>
|
|
||||||
<span class="select-wrapper">
|
|
||||||
<select
|
|
||||||
id="selectRequest"
|
|
||||||
v-model="requestData.requestIndex"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
<option :key="undefined" :value="undefined">/</option>
|
|
||||||
<option
|
|
||||||
v-for="(folder, index) in requests"
|
|
||||||
:key="index"
|
|
||||||
:value="index"
|
|
||||||
>
|
|
||||||
{{ folder.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div slot="footer">
|
|
||||||
<div class="row-wrapper">
|
|
||||||
<span></span>
|
|
||||||
<span>
|
|
||||||
<button class="icon" @click="hideModal">
|
|
||||||
{{ $t("cancel") }}
|
|
||||||
</button>
|
|
||||||
<button class="icon primary" @click="saveRequestAs">
|
|
||||||
{{ $t("save") }}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</SmartModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
show: Boolean,
|
|
||||||
editingRequest: { type: Object, default: () => {} },
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
defaultRequestName: "Untitled Request",
|
|
||||||
requestData: {
|
|
||||||
name: undefined,
|
|
||||||
collectionIndex: undefined,
|
|
||||||
folderName: undefined,
|
|
||||||
requestIndex: undefined,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
folders() {
|
|
||||||
const collections = this.$store.state.postwoman.collectionsGraphql
|
|
||||||
const collectionIndex = this.$data.requestData.collectionIndex
|
|
||||||
const userSelectedAnyCollection = collectionIndex !== undefined
|
|
||||||
if (!userSelectedAnyCollection) return []
|
|
||||||
|
|
||||||
const noCollectionAvailable = collections[collectionIndex] !== undefined
|
|
||||||
if (!noCollectionAvailable) return []
|
|
||||||
|
|
||||||
return getFolderNames(collections[collectionIndex].folders, [])
|
|
||||||
},
|
|
||||||
requests() {
|
|
||||||
const collections = this.$store.state.postwoman.collectionsGraphql
|
|
||||||
const collectionIndex = this.$data.requestData.collectionIndex
|
|
||||||
const folderName = this.$data.requestData.folderName
|
|
||||||
|
|
||||||
const userSelectedAnyCollection = collectionIndex !== undefined
|
|
||||||
if (!userSelectedAnyCollection) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
const userSelectedAnyFolder =
|
|
||||||
folderName !== undefined && folderName !== ""
|
|
||||||
|
|
||||||
if (userSelectedAnyFolder) {
|
|
||||||
const collection = collections[collectionIndex]
|
|
||||||
const folder = findFolder(folderName, collection)
|
|
||||||
return folder.requests
|
|
||||||
} else {
|
|
||||||
const collection = collections[collectionIndex]
|
|
||||||
const noCollectionAvailable = collection !== undefined
|
|
||||||
|
|
||||||
if (!noCollectionAvailable) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return collection.requests
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
"requestData.collectionIndex": function resetFolderAndRequestIndex() {
|
|
||||||
// if user has chosen some folder, than selected other collection, which doesn't have any folders
|
|
||||||
// than `requestUpdateData.folderName` won't be reseted
|
|
||||||
this.$data.requestData.folderName = undefined
|
|
||||||
this.$data.requestData.requestIndex = undefined
|
|
||||||
},
|
|
||||||
"requestData.folderName": function resetRequestIndex() {
|
|
||||||
this.$data.requestData.requestIndex = undefined
|
|
||||||
},
|
|
||||||
editingRequest({ name }) {
|
|
||||||
this.$data.requestData.name = name || this.$data.defaultRequestName
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveRequestAs() {
|
|
||||||
const userDidntSpecifyCollection =
|
|
||||||
this.$data.requestData.collectionIndex === undefined
|
|
||||||
if (userDidntSpecifyCollection) {
|
|
||||||
this.$toast.error(this.$t("select_collection"), {
|
|
||||||
icon: "error",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.$data.requestData.name.length === 0) {
|
|
||||||
this.$toast.error(this.$t("empty_req_name"), {
|
|
||||||
icon: "error",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestUpdated = {
|
|
||||||
...this.$props.editingRequest,
|
|
||||||
name: this.$data.requestData.name,
|
|
||||||
collection: this.$data.requestData.collectionIndex,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.commit("postwoman/saveRequestAs", {
|
|
||||||
request: requestUpdated,
|
|
||||||
collectionIndex: this.$data.requestData.collectionIndex,
|
|
||||||
folderName: this.$data.requestData.folderName,
|
|
||||||
requestIndex: this.$data.requestData.requestIndex,
|
|
||||||
flag: "graphql",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.hideModal()
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
|
||||||
hideModal() {
|
|
||||||
this.$emit("hide-modal")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFolderNames(folders, namesList) {
|
|
||||||
if (folders.length) {
|
|
||||||
folders.forEach((folder) => {
|
|
||||||
namesList.push(folder.name)
|
|
||||||
if (folder.folders && folder.folders.length) {
|
|
||||||
getFolderNames(folder.folders, namesList)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return namesList
|
|
||||||
}
|
|
||||||
|
|
||||||
function findFolder(folderName, currentFolder) {
|
|
||||||
let selectedFolder
|
|
||||||
let result
|
|
||||||
|
|
||||||
if (folderName === currentFolder.name) {
|
|
||||||
return currentFolder
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < currentFolder.folders.length; i++) {
|
|
||||||
selectedFolder = currentFolder.folders[i]
|
|
||||||
|
|
||||||
result = findFolder(folderName, selectedFolder)
|
|
||||||
|
|
||||||
if (result !== false) {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
/>
|
/>
|
||||||
<CollectionsGraphqlAddFolder
|
<CollectionsGraphqlAddFolder
|
||||||
:show="showModalAddFolder"
|
:show="showModalAddFolder"
|
||||||
:folder="editingFolder"
|
|
||||||
:folder-path="editingFolderPath"
|
:folder-path="editingFolderPath"
|
||||||
@add-folder="onAddFolder($event)"
|
@add-folder="onAddFolder($event)"
|
||||||
@hide-modal="displayModalAddFolder(false)"
|
@hide-modal="displayModalAddFolder(false)"
|
||||||
@@ -36,13 +35,12 @@
|
|||||||
:collection-index="editingCollectionIndex"
|
:collection-index="editingCollectionIndex"
|
||||||
:folder="editingFolder"
|
:folder="editingFolder"
|
||||||
:folder-index="editingFolderIndex"
|
:folder-index="editingFolderIndex"
|
||||||
|
:folder-path="editingFolderPath"
|
||||||
@hide-modal="displayModalEditFolder(false)"
|
@hide-modal="displayModalEditFolder(false)"
|
||||||
/>
|
/>
|
||||||
<CollectionsGraphqlEditRequest
|
<CollectionsGraphqlEditRequest
|
||||||
:show="showModalEditRequest"
|
:show="showModalEditRequest"
|
||||||
:collection-index="editingCollectionIndex"
|
:folder-path="editingFolderPath"
|
||||||
:folder-index="editingFolderIndex"
|
|
||||||
:folder-name="editingFolderName"
|
|
||||||
:request="editingRequest"
|
:request="editingRequest"
|
||||||
:request-index="editingRequestIndex"
|
:request-index="editingRequestIndex"
|
||||||
@hide-modal="displayModalEditRequest(false)"
|
@hide-modal="displayModalEditRequest(false)"
|
||||||
@@ -52,11 +50,19 @@
|
|||||||
@hide-modal="displayModalImportExport(false)"
|
@hide-modal="displayModalImportExport(false)"
|
||||||
/>
|
/>
|
||||||
<div class="border-b row-wrapper border-brdColor">
|
<div class="border-b row-wrapper border-brdColor">
|
||||||
<button class="icon" @click="displayModalAdd(true)">
|
<button
|
||||||
|
v-if="showCollActions"
|
||||||
|
class="icon"
|
||||||
|
@click="displayModalAdd(true)"
|
||||||
|
>
|
||||||
<i class="material-icons">add</i>
|
<i class="material-icons">add</i>
|
||||||
<span>{{ $t("new") }}</span>
|
<span>{{ $t("new") }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="icon" @click="displayModalImportExport(true)">
|
<button
|
||||||
|
v-if="showCollActions"
|
||||||
|
class="icon"
|
||||||
|
@click="displayModalImportExport(true)"
|
||||||
|
>
|
||||||
{{ $t("import_export") }}
|
{{ $t("import_export") }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,16 +77,19 @@
|
|||||||
:key="collection.name"
|
:key="collection.name"
|
||||||
>
|
>
|
||||||
<CollectionsGraphqlCollection
|
<CollectionsGraphqlCollection
|
||||||
|
:picked="picked"
|
||||||
:name="collection.name"
|
:name="collection.name"
|
||||||
:collection-index="index"
|
:collection-index="index"
|
||||||
:collection="collection"
|
:collection="collection"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
:is-filtered="filterText.length > 0"
|
:is-filtered="filterText.length > 0"
|
||||||
|
:saving-mode="savingMode"
|
||||||
@edit-collection="editCollection(collection, index)"
|
@edit-collection="editCollection(collection, index)"
|
||||||
@add-folder="addFolder($event)"
|
@add-folder="addFolder($event)"
|
||||||
@edit-folder="editFolder($event)"
|
@edit-folder="editFolder($event)"
|
||||||
@edit-request="editRequest($event)"
|
@edit-request="editRequest($event)"
|
||||||
@select-collection="$emit('use-collection', collection)"
|
@select-collection="$emit('use-collection', collection)"
|
||||||
|
@select="$emit('select', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -94,11 +103,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import { graphqlCollections$, addGraphqlFolder } from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
doc: Boolean,
|
// Whether to activate the ability to pick items (activates 'select' events)
|
||||||
|
savingMode: { type: Boolean, default: false },
|
||||||
|
doc: { type: Boolean, default: false },
|
||||||
|
picked: { type: Object, default: null },
|
||||||
|
// Whether to show the 'New' and 'Import/Export' actions
|
||||||
|
showCollActions: { type: Boolean, default: true },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -119,17 +133,14 @@ export default {
|
|||||||
filterText: "",
|
filterText: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
subscriptions() {
|
||||||
|
return {
|
||||||
|
collections: graphqlCollections$,
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
collections() {
|
|
||||||
return fb.currentUser !== null
|
|
||||||
? fb.currentGraphqlCollections
|
|
||||||
: this.$store.state.postwoman.collectionsGraphql
|
|
||||||
},
|
|
||||||
filteredCollections() {
|
filteredCollections() {
|
||||||
const collections =
|
const collections = this.collections
|
||||||
fb.currentUser !== null
|
|
||||||
? fb.currentGraphqlCollections
|
|
||||||
: this.$store.state.postwoman.collectionsGraphql
|
|
||||||
|
|
||||||
if (!this.filterText) return collections
|
if (!this.filterText) return collections
|
||||||
|
|
||||||
@@ -216,32 +227,21 @@ export default {
|
|||||||
this.$data.editingCollection = collection
|
this.$data.editingCollection = collection
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
this.$data.editingCollectionIndex = collectionIndex
|
||||||
this.displayModalEdit(true)
|
this.displayModalEdit(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
onAddFolder({ name, path }) {
|
onAddFolder({ name, path }) {
|
||||||
const flag = "graphql"
|
addGraphqlFolder(name, path)
|
||||||
this.$store.commit("postwoman/addFolder", {
|
|
||||||
name,
|
|
||||||
path,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
|
|
||||||
this.displayModalAddFolder(false)
|
this.displayModalAddFolder(false)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
addFolder(payload) {
|
addFolder(payload) {
|
||||||
const { folder, path } = payload
|
const { path } = payload
|
||||||
this.$data.editingFolder = folder
|
|
||||||
this.$data.editingFolderPath = path
|
this.$data.editingFolderPath = path
|
||||||
this.displayModalAddFolder(true)
|
this.displayModalAddFolder(true)
|
||||||
},
|
},
|
||||||
editFolder(payload) {
|
editFolder(payload) {
|
||||||
const { collectionIndex, folder, folderIndex } = payload
|
const { folder, folderPath } = payload
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
this.editingFolder = folder
|
||||||
this.$data.editingFolder = folder
|
this.editingFolderPath = folderPath
|
||||||
this.$data.editingFolderIndex = folderIndex
|
|
||||||
this.displayModalEditFolder(true)
|
this.displayModalEditFolder(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
editRequest(payload) {
|
editRequest(payload) {
|
||||||
const {
|
const {
|
||||||
@@ -257,7 +257,6 @@ export default {
|
|||||||
this.$data.editingRequest = request
|
this.$data.editingRequest = request
|
||||||
this.$data.editingRequestIndex = requestIndex
|
this.$data.editingRequestIndex = requestIndex
|
||||||
this.displayModalEditRequest(true)
|
this.displayModalEditRequest(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
resetSelectedData() {
|
resetSelectedData() {
|
||||||
this.$data.editingCollection = undefined
|
this.$data.editingCollection = undefined
|
||||||
@@ -267,18 +266,6 @@ export default {
|
|||||||
this.$data.editingRequest = undefined
|
this.$data.editingRequest = undefined
|
||||||
this.$data.editingRequestIndex = undefined
|
this.$data.editingRequestIndex = undefined
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && fb.currentSettings[0]) {
|
|
||||||
if (fb.currentSettings[0].value) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(
|
|
||||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
|
||||||
),
|
|
||||||
"collectionsGraphql"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -141,9 +141,18 @@
|
|||||||
import gql from "graphql-tag"
|
import gql from "graphql-tag"
|
||||||
import cloneDeep from "lodash/cloneDeep"
|
import cloneDeep from "lodash/cloneDeep"
|
||||||
import { fb } from "~/helpers/fb"
|
import { fb } from "~/helpers/fb"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
||||||
import * as teamUtils from "~/helpers/teams/utils"
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
|
import {
|
||||||
|
restCollections$,
|
||||||
|
addRESTCollection,
|
||||||
|
editRESTCollection,
|
||||||
|
addRESTFolder,
|
||||||
|
removeRESTCollection,
|
||||||
|
editRESTFolder,
|
||||||
|
removeRESTRequest,
|
||||||
|
editRESTRequest,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -179,7 +188,7 @@ export default {
|
|||||||
},
|
},
|
||||||
subscriptions() {
|
subscriptions() {
|
||||||
return {
|
return {
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
collections: restCollections$,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -189,21 +198,11 @@ export default {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
collections() {
|
|
||||||
return fb.currentUser !== null
|
|
||||||
? fb.currentCollections
|
|
||||||
: this.$store.state.postwoman.collections
|
|
||||||
},
|
|
||||||
filteredCollections() {
|
filteredCollections() {
|
||||||
let collections = null
|
const collections =
|
||||||
if (this.collectionsType.type === "my-collections") {
|
this.collectionsType.type === "my-collections"
|
||||||
collections =
|
? this.collections
|
||||||
fb.currentUser !== null
|
: this.teamCollectionsNew
|
||||||
? fb.currentCollections
|
|
||||||
: this.$store.state.postwoman.collections
|
|
||||||
} else {
|
|
||||||
collections = this.teamCollectionsNew
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.filterText) {
|
if (!this.filterText) {
|
||||||
return collections
|
return collections
|
||||||
@@ -301,12 +300,11 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/addNewCollection", {
|
addRESTCollection({
|
||||||
name,
|
name,
|
||||||
flag: "rest",
|
folders: [],
|
||||||
|
requests: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (
|
} else if (
|
||||||
this.collectionsType.type === "team-collections" &&
|
this.collectionsType.type === "team-collections" &&
|
||||||
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
@@ -342,12 +340,8 @@ export default {
|
|||||||
...this.editingCollection,
|
...this.editingCollection,
|
||||||
name: newName,
|
name: newName,
|
||||||
}
|
}
|
||||||
this.$store.commit("postwoman/editCollection", {
|
|
||||||
collection: collectionUpdated,
|
editRESTCollection(this.editingCollectionIndex, collectionUpdated)
|
||||||
collectionIndex: this.editingCollectionIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (
|
} else if (
|
||||||
this.collectionsType.type === "team-collections" &&
|
this.collectionsType.type === "team-collections" &&
|
||||||
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
@@ -372,14 +366,7 @@ export default {
|
|||||||
// Intended to be called by CollectionEditFolder modal submit event
|
// Intended to be called by CollectionEditFolder modal submit event
|
||||||
updateEditingFolder(name) {
|
updateEditingFolder(name) {
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/editFolder", {
|
editRESTFolder(this.editingFolderPath, { ...this.editingFolder, name })
|
||||||
collectionIndex: this.editingCollectionIndex,
|
|
||||||
folder: { ...this.editingFolder, name },
|
|
||||||
folderIndex: this.editingFolderIndex,
|
|
||||||
folderName: this.editingFolder.name,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (
|
} else if (
|
||||||
this.collectionsType.type === "team-collections" &&
|
this.collectionsType.type === "team-collections" &&
|
||||||
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
@@ -411,15 +398,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/editRequest", {
|
editRESTRequest(
|
||||||
requestCollectionIndex: this.editingCollectionIndex,
|
this.editingFolderPath,
|
||||||
requestFolderName: this.editingFolderName,
|
this.editingRequestIndex,
|
||||||
requestFolderIndex: this.editingFolderIndex,
|
requestUpdated
|
||||||
requestNew: requestUpdated,
|
)
|
||||||
requestIndex: this.editingRequestIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (
|
} else if (
|
||||||
this.collectionsType.type === "team-collections" &&
|
this.collectionsType.type === "team-collections" &&
|
||||||
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
@@ -478,17 +461,10 @@ export default {
|
|||||||
this.$data.editingCollection = collection
|
this.$data.editingCollection = collection
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
this.$data.editingCollectionIndex = collectionIndex
|
||||||
this.displayModalEdit(true)
|
this.displayModalEdit(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
onAddFolder({ name, folder, path }) {
|
onAddFolder({ name, folder, path }) {
|
||||||
const flag = "rest"
|
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/addFolder", {
|
addRESTFolder(name, path)
|
||||||
name,
|
|
||||||
path,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
} else if (this.collectionsType.type === "team-collections") {
|
} else if (this.collectionsType.type === "team-collections") {
|
||||||
if (this.collectionsType.selectedTeam.myRole !== "VIEWER") {
|
if (this.collectionsType.selectedTeam.myRole !== "VIEWER") {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
@@ -538,13 +514,13 @@ export default {
|
|||||||
this.displayModalAddFolder(true)
|
this.displayModalAddFolder(true)
|
||||||
},
|
},
|
||||||
editFolder(payload) {
|
editFolder(payload) {
|
||||||
const { collectionIndex, folder, folderIndex } = payload
|
const { collectionIndex, folder, folderIndex, folderPath } = payload
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
this.$data.editingCollectionIndex = collectionIndex
|
||||||
this.$data.editingFolder = folder
|
this.$data.editingFolder = folder
|
||||||
this.$data.editingFolderIndex = folderIndex
|
this.$data.editingFolderIndex = folderIndex
|
||||||
|
this.$data.editingFolderPath = folderPath
|
||||||
this.$data.collectionsType = this.collectionsType
|
this.$data.collectionsType = this.collectionsType
|
||||||
this.displayModalEditFolder(true)
|
this.displayModalEditFolder(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
editRequest(payload) {
|
editRequest(payload) {
|
||||||
const {
|
const {
|
||||||
@@ -553,15 +529,16 @@ export default {
|
|||||||
folderName,
|
folderName,
|
||||||
request,
|
request,
|
||||||
requestIndex,
|
requestIndex,
|
||||||
|
folderPath,
|
||||||
} = payload
|
} = payload
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
this.$data.editingCollectionIndex = collectionIndex
|
||||||
this.$data.editingFolderIndex = folderIndex
|
this.$data.editingFolderIndex = folderIndex
|
||||||
this.$data.editingFolderName = folderName
|
this.$data.editingFolderName = folderName
|
||||||
this.$data.editingRequest = request
|
this.$data.editingRequest = request
|
||||||
this.$data.editingRequestIndex = requestIndex
|
this.$data.editingRequestIndex = requestIndex
|
||||||
|
this.editingFolderPath = folderPath
|
||||||
this.$emit("select-request", requestIndex)
|
this.$emit("select-request", requestIndex)
|
||||||
this.displayModalEditRequest(true)
|
this.displayModalEditRequest(true)
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
resetSelectedData() {
|
resetSelectedData() {
|
||||||
this.$data.editingCollection = undefined
|
this.$data.editingCollection = undefined
|
||||||
@@ -571,27 +548,16 @@ export default {
|
|||||||
this.$data.editingRequest = undefined
|
this.$data.editingRequest = undefined
|
||||||
this.$data.editingRequestIndex = undefined
|
this.$data.editingRequestIndex = undefined
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
expandCollection(collectionID) {
|
expandCollection(collectionID) {
|
||||||
this.teamCollectionAdapter.expandCollection(collectionID)
|
this.teamCollectionAdapter.expandCollection(collectionID)
|
||||||
},
|
},
|
||||||
removeCollection({ collectionsType, collectionIndex, collectionID }) {
|
removeCollection({ collectionsType, collectionIndex, collectionID }) {
|
||||||
if (collectionsType.type === "my-collections") {
|
if (collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/removeCollection", {
|
removeRESTCollection(collectionIndex)
|
||||||
collectionIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
this.$toast.error(this.$t("deleted"), {
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
this.syncCollections()
|
|
||||||
} else if (collectionsType.type === "team-collections") {
|
} else if (collectionsType.type === "team-collections") {
|
||||||
if (collectionsType.selectedTeam.myRole !== "VIEWER") {
|
if (collectionsType.selectedTeam.myRole !== "VIEWER") {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
@@ -623,18 +589,13 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
removeRequest({ requestIndex, folderPath }) {
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.$store.commit("postwoman/removeRequest", {
|
removeRESTRequest(folderPath, requestIndex)
|
||||||
collectionIndex,
|
|
||||||
folderName,
|
|
||||||
requestIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
this.$toast.error(this.$t("deleted"), {
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
this.syncCollections()
|
|
||||||
} else if (this.collectionsType.type === "team-collections") {
|
} else if (this.collectionsType.type === "team-collections") {
|
||||||
teamUtils
|
teamUtils
|
||||||
.deleteRequest(this.$apollo, requestIndex)
|
.deleteRequest(this.$apollo, requestIndex)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
@edit-folder="$emit('edit-folder', $event)"
|
@edit-folder="$emit('edit-folder', $event)"
|
||||||
@edit-request="$emit('edit-request', $event)"
|
@edit-request="$emit('edit-request', $event)"
|
||||||
@select="$emit('select', $event)"
|
@select="$emit('select', $event)"
|
||||||
@remove-request="removeRequest"
|
@remove-request="$emit('remove-request', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
:picked="picked"
|
:picked="picked"
|
||||||
@edit-request="editRequest($event)"
|
@edit-request="editRequest($event)"
|
||||||
@select="$emit('select', $event)"
|
@select="$emit('select', $event)"
|
||||||
@remove-request="removeRequest"
|
@remove-request="$emit('remove-request', $event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -163,8 +163,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import { moveRESTRequest } from "~/newstore/collections"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -188,11 +187,6 @@ export default {
|
|||||||
pageNo: 0,
|
pageNo: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
isSelected() {
|
isSelected() {
|
||||||
return (
|
return (
|
||||||
@@ -206,14 +200,6 @@ export default {
|
|||||||
editRequest(event) {
|
editRequest(event) {
|
||||||
this.$emit("edit-request", event)
|
this.$emit("edit-request", event)
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleShowChildren() {
|
toggleShowChildren() {
|
||||||
if (this.$props.saveRequest)
|
if (this.$props.saveRequest)
|
||||||
this.$emit("select", {
|
this.$emit("select", {
|
||||||
@@ -236,29 +222,9 @@ export default {
|
|||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "rest"
|
moveRESTRequest(folderPath, requestIndex, this.collectionIndex.toString())
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: -1,
|
|
||||||
newFolderName: this.$props.collection.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
|
||||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
|
||||||
this.$emit("remove-request", {
|
|
||||||
collectionIndex,
|
|
||||||
folderName,
|
|
||||||
requestIndex,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,12 @@
|
|||||||
v-close-popover
|
v-close-popover
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="
|
@click="
|
||||||
$emit('edit-folder', { folder, folderIndex, collectionIndex })
|
$emit('edit-folder', {
|
||||||
|
folder,
|
||||||
|
folderIndex,
|
||||||
|
collectionIndex,
|
||||||
|
folderPath,
|
||||||
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<i class="material-icons">edit</i>
|
<i class="material-icons">edit</i>
|
||||||
@@ -99,8 +104,8 @@
|
|||||||
:collection-index="collectionIndex"
|
:collection-index="collectionIndex"
|
||||||
:folder-index="folderIndex"
|
:folder-index="folderIndex"
|
||||||
:folder-name="folder.name"
|
:folder-name="folder.name"
|
||||||
:request-index="index"
|
|
||||||
:folder-path="folderPath"
|
:folder-path="folderPath"
|
||||||
|
:request-index="index"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
:picked="picked"
|
:picked="picked"
|
||||||
:save-request="saveRequest"
|
:save-request="saveRequest"
|
||||||
@@ -137,8 +142,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import {
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
removeRESTFolder,
|
||||||
|
removeRESTRequest,
|
||||||
|
moveRESTRequest,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Folder",
|
name: "Folder",
|
||||||
@@ -162,11 +170,6 @@ export default {
|
|||||||
cursor: "",
|
cursor: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
isSelected() {
|
isSelected() {
|
||||||
return (
|
return (
|
||||||
@@ -177,14 +180,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleShowChildren() {
|
toggleShowChildren() {
|
||||||
if (this.$props.saveRequest)
|
if (this.$props.saveRequest)
|
||||||
this.$emit("select", {
|
this.$emit("select", {
|
||||||
@@ -198,43 +193,20 @@ export default {
|
|||||||
this.showChildren = !this.showChildren
|
this.showChildren = !this.showChildren
|
||||||
},
|
},
|
||||||
removeFolder() {
|
removeFolder() {
|
||||||
this.$store.commit("postwoman/removeFolder", {
|
removeRESTFolder(this.folderPath)
|
||||||
collectionIndex: this.$props.collectionIndex,
|
|
||||||
folderName: this.$props.folder.name,
|
|
||||||
folderIndex: this.$props.folderIndex,
|
|
||||||
flag: "rest",
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
this.$toast.error(this.$t("deleted"), {
|
this.$toast.error(this.$t("deleted"), {
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "rest"
|
moveRESTRequest(folderPath, requestIndex, this.folderPath)
|
||||||
|
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: this.$props.folderIndex,
|
|
||||||
newFolderName: this.$props.folder.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
removeRequest({ requestIndex }) {
|
||||||
this.$emit("remove-request", {
|
removeRESTRequest(this.folderPath, requestIndex)
|
||||||
collectionIndex,
|
|
||||||
folderName,
|
|
||||||
requestIndex,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
folderName,
|
folderName,
|
||||||
request,
|
request,
|
||||||
requestIndex,
|
requestIndex,
|
||||||
|
folderPath,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -123,15 +124,14 @@ export default {
|
|||||||
},
|
},
|
||||||
dragStart({ dataTransfer }) {
|
dragStart({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex)
|
dataTransfer.setData("folderPath", this.folderPath)
|
||||||
dataTransfer.setData("oldFolderIndex", this.$props.folderIndex)
|
dataTransfer.setData("requestIndex", this.requestIndex)
|
||||||
dataTransfer.setData("oldFolderName", this.$props.folderName)
|
|
||||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
|
||||||
},
|
},
|
||||||
removeRequest() {
|
removeRequest() {
|
||||||
this.$emit("remove-request", {
|
this.$emit("remove-request", {
|
||||||
collectionIndex: this.$props.collectionIndex,
|
collectionIndex: this.$props.collectionIndex,
|
||||||
folderName: this.$props.folderName,
|
folderName: this.$props.folderName,
|
||||||
|
folderPath: this.folderPath,
|
||||||
requestIndex: this.$props.requestIndex,
|
requestIndex: this.$props.requestIndex,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,7 +44,12 @@
|
|||||||
v-close-popover
|
v-close-popover
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="
|
@click="
|
||||||
$emit('edit-folder', { folder, folderIndex, collectionIndex })
|
$emit('edit-folder', {
|
||||||
|
folder,
|
||||||
|
folderIndex,
|
||||||
|
collectionIndex,
|
||||||
|
folderPath: '',
|
||||||
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<i class="material-icons">edit</i>
|
<i class="material-icons">edit</i>
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ import {
|
|||||||
setGraphqlHistoryEntries,
|
setGraphqlHistoryEntries,
|
||||||
HISTORY_LIMIT,
|
HISTORY_LIMIT,
|
||||||
} from "~/newstore/history"
|
} from "~/newstore/history"
|
||||||
|
import {
|
||||||
|
restCollectionStore,
|
||||||
|
setRESTCollections,
|
||||||
|
graphqlCollectionStore,
|
||||||
|
setGraphqlCollections,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
// Initialize Firebase, copied from cloud console
|
// Initialize Firebase, copied from cloud console
|
||||||
const firebaseConfig = {
|
const firebaseConfig = {
|
||||||
@@ -39,8 +45,6 @@ export class FirebaseInstance {
|
|||||||
this.idToken = null
|
this.idToken = null
|
||||||
this.currentFeeds = []
|
this.currentFeeds = []
|
||||||
this.currentSettings = []
|
this.currentSettings = []
|
||||||
this.currentCollections = []
|
|
||||||
this.currentGraphqlCollections = []
|
|
||||||
this.currentEnvironments = []
|
this.currentEnvironments = []
|
||||||
|
|
||||||
this.currentUser$ = new ReplaySubject(1)
|
this.currentUser$ = new ReplaySubject(1)
|
||||||
@@ -49,6 +53,28 @@ export class FirebaseInstance {
|
|||||||
let loadedSettings = false
|
let loadedSettings = false
|
||||||
let loadedRESTHistory = false
|
let loadedRESTHistory = false
|
||||||
let loadedGraphqlHistory = false
|
let loadedGraphqlHistory = false
|
||||||
|
let loadedRESTCollections = false
|
||||||
|
let loadedGraphqlCollections = false
|
||||||
|
|
||||||
|
graphqlCollectionStore.subject$.subscribe(({ state }) => {
|
||||||
|
if (
|
||||||
|
loadedGraphqlCollections &&
|
||||||
|
this.currentUser &&
|
||||||
|
settingsStore.value.syncCollections
|
||||||
|
) {
|
||||||
|
this.writeCollections(state, "collectionsGraphql")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
restCollectionStore.subject$.subscribe(({ state }) => {
|
||||||
|
if (
|
||||||
|
loadedRESTCollections &&
|
||||||
|
this.currentUser &&
|
||||||
|
settingsStore.value.syncCollections
|
||||||
|
) {
|
||||||
|
this.writeCollections(state, "collections")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
restHistoryStore.dispatches$.subscribe((dispatch) => {
|
restHistoryStore.dispatches$.subscribe((dispatch) => {
|
||||||
if (
|
if (
|
||||||
@@ -87,15 +113,17 @@ export class FirebaseInstance {
|
|||||||
})
|
})
|
||||||
|
|
||||||
settingsStore.dispatches$.subscribe((dispatch) => {
|
settingsStore.dispatches$.subscribe((dispatch) => {
|
||||||
if (
|
if (this.currentSettings && loadedSettings) {
|
||||||
this.currentSettings &&
|
if (dispatch.dispatcher === "bulkApplySettings") {
|
||||||
loadedSettings &&
|
Object.keys(dispatch.payload).forEach((key) => {
|
||||||
dispatch.dispatcher !== "applySettingFB"
|
this.writeSettings(key, dispatch.payload[key])
|
||||||
) {
|
})
|
||||||
this.writeSettings(
|
} else if (dispatch.dispatcher !== "applySettingFB") {
|
||||||
dispatch.payload.settingKey,
|
this.writeSettings(
|
||||||
settingsStore.value[dispatch.payload.settingKey]
|
dispatch.payload.settingKey,
|
||||||
)
|
settingsStore.value[dispatch.payload.settingKey]
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -220,9 +248,16 @@ export class FirebaseInstance {
|
|||||||
collection.id = doc.id
|
collection.id = doc.id
|
||||||
collections.push(collection)
|
collections.push(collection)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Prevent infinite ping-pong of updates
|
||||||
|
loadedRESTCollections = false
|
||||||
|
|
||||||
|
// TODO: Wth is with collections[0]
|
||||||
if (collections.length > 0) {
|
if (collections.length > 0) {
|
||||||
this.currentCollections = collections[0].collection
|
setRESTCollections(collections[0].collection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadedRESTCollections = true
|
||||||
})
|
})
|
||||||
|
|
||||||
this.usersCollection
|
this.usersCollection
|
||||||
@@ -235,9 +270,16 @@ export class FirebaseInstance {
|
|||||||
collection.id = doc.id
|
collection.id = doc.id
|
||||||
collections.push(collection)
|
collections.push(collection)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Prevent infinite ping-pong of updates
|
||||||
|
loadedGraphqlCollections = false
|
||||||
|
|
||||||
|
// TODO: Wth is with collections[0]
|
||||||
if (collections.length > 0) {
|
if (collections.length > 0) {
|
||||||
this.currentGraphqlCollections = collections[0].collection
|
setGraphqlCollections(collections[0].collection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadedGraphqlCollections = true
|
||||||
})
|
})
|
||||||
|
|
||||||
this.usersCollection
|
this.usersCollection
|
||||||
@@ -458,7 +500,6 @@ export class FirebaseInstance {
|
|||||||
.set(cl)
|
.set(cl)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("error updating", cl, e)
|
console.error("error updating", cl, e)
|
||||||
|
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
579
newstore/collections.ts
Normal file
579
newstore/collections.ts
Normal file
@@ -0,0 +1,579 @@
|
|||||||
|
import { pluck } from "rxjs/operators"
|
||||||
|
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
|
||||||
|
|
||||||
|
interface Collection {
|
||||||
|
name: string
|
||||||
|
folders: Collection[]
|
||||||
|
requests: any[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultRESTCollectionState = {
|
||||||
|
state: [
|
||||||
|
<Collection>{
|
||||||
|
name: "My Collection",
|
||||||
|
folders: [],
|
||||||
|
requests: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultGraphqlCollectionState = {
|
||||||
|
state: [
|
||||||
|
<Collection>{
|
||||||
|
name: "My GraphQL Collection",
|
||||||
|
folders: [],
|
||||||
|
requests: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
type RESTCollectionStoreType = typeof defaultRESTCollectionState
|
||||||
|
type GraphqlCollectionStoreType = typeof defaultGraphqlCollectionState
|
||||||
|
|
||||||
|
type CollectionStoreType = RESTCollectionStoreType | GraphqlCollectionStoreType
|
||||||
|
|
||||||
|
function navigateToFolderWithIndexPath(
|
||||||
|
collections: Collection[],
|
||||||
|
indexPaths: number[]
|
||||||
|
) {
|
||||||
|
if (indexPaths.length === 0) return null
|
||||||
|
|
||||||
|
let target = collections[indexPaths.shift() as number]
|
||||||
|
|
||||||
|
while (indexPaths.length > 0)
|
||||||
|
target = target.folders[indexPaths.shift() as number]
|
||||||
|
|
||||||
|
return target !== undefined ? target : null
|
||||||
|
}
|
||||||
|
|
||||||
|
const collectionDispatchers = defineDispatchers({
|
||||||
|
setCollections(
|
||||||
|
_: CollectionStoreType,
|
||||||
|
{ entries }: { entries: Collection[] }
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
state: entries,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
appendCollections(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ entries }: { entries: Collection[] }
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
state: [...state, ...entries],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addCollection(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ collection }: { collection: Collection }
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
state: [...state, collection],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeCollection(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ collectionIndex }: { collectionIndex: number }
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
state: state.filter((_, i) => i !== collectionIndex),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
editCollection(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{
|
||||||
|
collectionIndex,
|
||||||
|
collection,
|
||||||
|
}: { collectionIndex: number; collection: Collection }
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
state: state.map((col, index) =>
|
||||||
|
index === collectionIndex ? collection : col
|
||||||
|
),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addFolder(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ name, path }: { name: string; path: string }
|
||||||
|
) {
|
||||||
|
const newFolder: Collection = {
|
||||||
|
name,
|
||||||
|
folders: [],
|
||||||
|
requests: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
const newState = state
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const target = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (target === null) {
|
||||||
|
console.log(`Could not parse path '${path}'. Ignoring add folder request`)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.folders.push(newFolder)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
editFolder(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ path, folder }: { path: string; folder: string }
|
||||||
|
) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const target = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (target === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not parse path '${path}'. Ignoring edit folder request`
|
||||||
|
)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(target, folder)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeFolder({ state }: CollectionStoreType, { path }: { path: string }) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
if (indexPaths.length === 0) {
|
||||||
|
console.log(
|
||||||
|
"Given path too short. If this is a collection, use removeCollection dispatcher instead. Skipping request."
|
||||||
|
)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
// We get the index path to the folder itself,
|
||||||
|
// we have to find the folder containing the target folder,
|
||||||
|
// so we pop the last path index
|
||||||
|
const folderIndex = indexPaths.pop() as number
|
||||||
|
|
||||||
|
const containingFolder = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (containingFolder === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve path '${path}'. Skipping removeFolder dispatch.`
|
||||||
|
)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
containingFolder.folders.splice(folderIndex, 1)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
editRequest(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
requestNew,
|
||||||
|
}: { path: string; requestIndex: number; requestNew: any }
|
||||||
|
) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const targetLocation = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (targetLocation === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve path '${path}'. Ignoring editRequest dispatch.`
|
||||||
|
)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetLocation.requests = targetLocation.requests.map((req, index) =>
|
||||||
|
index !== requestIndex ? req : requestNew
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
saveRequestAs(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ path, request }: { path: string; request: any }
|
||||||
|
) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const targetLocation = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (targetLocation === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve path '${path}'. Ignoring saveRequestAs dispatch.`
|
||||||
|
)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetLocation.requests.push(request)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeRequest(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{ path, requestIndex }: { path: string; requestIndex: number }
|
||||||
|
) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const targetLocation = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (targetLocation === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve path '${path}'. Ignoring removeRequest dispatch.`
|
||||||
|
)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetLocation.requests.splice(requestIndex, 1)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
moveRequest(
|
||||||
|
{ state }: CollectionStoreType,
|
||||||
|
{
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
destinationPath,
|
||||||
|
}: { path: string; requestIndex: number; destinationPath: string }
|
||||||
|
) {
|
||||||
|
const newState = state
|
||||||
|
|
||||||
|
const indexPaths = path.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const targetLocation = navigateToFolderWithIndexPath(newState, indexPaths)
|
||||||
|
|
||||||
|
if (targetLocation === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve source path '${path}'. Skipping moveRequest dispatch.`
|
||||||
|
)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const req = targetLocation.requests[requestIndex]
|
||||||
|
|
||||||
|
const destIndexPaths = destinationPath.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
|
const destLocation = navigateToFolderWithIndexPath(newState, destIndexPaths)
|
||||||
|
|
||||||
|
if (destLocation === null) {
|
||||||
|
console.log(
|
||||||
|
`Could not resolve destination path '${destinationPath}'. Skipping moveRequest dispatch.`
|
||||||
|
)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
destLocation.requests.push(req)
|
||||||
|
targetLocation.requests.splice(requestIndex, 1)
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: newState,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export const restCollectionStore = new DispatchingStore(
|
||||||
|
defaultRESTCollectionState,
|
||||||
|
collectionDispatchers
|
||||||
|
)
|
||||||
|
|
||||||
|
export const graphqlCollectionStore = new DispatchingStore(
|
||||||
|
defaultGraphqlCollectionState,
|
||||||
|
collectionDispatchers
|
||||||
|
)
|
||||||
|
|
||||||
|
export function setRESTCollections(entries: Collection[]) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "setCollections",
|
||||||
|
payload: {
|
||||||
|
entries,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const restCollections$ = restCollectionStore.subject$.pipe(
|
||||||
|
pluck("state")
|
||||||
|
)
|
||||||
|
|
||||||
|
export const graphqlCollections$ = graphqlCollectionStore.subject$.pipe(
|
||||||
|
pluck("state")
|
||||||
|
)
|
||||||
|
|
||||||
|
export function appendRESTCollections(entries: Collection[]) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "appendCollections",
|
||||||
|
payload: {
|
||||||
|
entries,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addRESTCollection(collection: Collection) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "addCollection",
|
||||||
|
payload: {
|
||||||
|
collection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeRESTCollection(collectionIndex: number) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeCollection",
|
||||||
|
payload: {
|
||||||
|
collectionIndex,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editRESTCollection(
|
||||||
|
collectionIndex: number,
|
||||||
|
collection: Collection
|
||||||
|
) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "editCollection",
|
||||||
|
payload: {
|
||||||
|
collectionIndex,
|
||||||
|
collection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addRESTFolder(name: string, path: string) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "addFolder",
|
||||||
|
payload: {
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editRESTFolder(path: string, folder: Collection) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "editFolder",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
folder,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeRESTFolder(path: string) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeFolder",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editRESTRequest(
|
||||||
|
path: string,
|
||||||
|
requestIndex: number,
|
||||||
|
requestNew: any
|
||||||
|
) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "editRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
requestNew,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveRESTRequestAs(path: string, request: any) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "saveRequestAs",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
request,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeRESTRequest(path: string, requestIndex: number) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moveRESTRequest(
|
||||||
|
path: string,
|
||||||
|
requestIndex: number,
|
||||||
|
destinationPath: string
|
||||||
|
) {
|
||||||
|
restCollectionStore.dispatch({
|
||||||
|
dispatcher: "moveRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
destinationPath,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setGraphqlCollections(entries: Collection[]) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "setCollections",
|
||||||
|
payload: {
|
||||||
|
entries,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function appendGraphqlCollections(entries: Collection[]) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "appendCollections",
|
||||||
|
payload: {
|
||||||
|
entries,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addGraphqlCollection(collection: Collection) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "addCollection",
|
||||||
|
payload: {
|
||||||
|
collection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeGraphqlCollection(collectionIndex: number) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeCollection",
|
||||||
|
payload: {
|
||||||
|
collectionIndex,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editGraphqlCollection(
|
||||||
|
collectionIndex: number,
|
||||||
|
collection: Collection
|
||||||
|
) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "editCollection",
|
||||||
|
payload: {
|
||||||
|
collectionIndex,
|
||||||
|
collection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addGraphqlFolder(name: string, path: string) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "addFolder",
|
||||||
|
payload: {
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editGraphqlFolder(path: string, folder: Collection) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "editFolder",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
folder,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeGraphqlFolder(path: string) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeFolder",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function editGraphqlRequest(
|
||||||
|
path: string,
|
||||||
|
requestIndex: number,
|
||||||
|
requestNew: any
|
||||||
|
) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "editRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
requestNew,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveGraphqlRequestAs(path: string, request: any) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "saveRequestAs",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
request,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeGraphqlRequest(path: string, requestIndex: number) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "removeRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moveGraphqlRequest(
|
||||||
|
path: string,
|
||||||
|
requestIndex: number,
|
||||||
|
destinationPath: string
|
||||||
|
) {
|
||||||
|
graphqlCollectionStore.dispatch({
|
||||||
|
dispatcher: "moveRequest",
|
||||||
|
payload: {
|
||||||
|
path,
|
||||||
|
requestIndex,
|
||||||
|
destinationPath,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -8,6 +8,12 @@ import {
|
|||||||
setRESTHistoryEntries,
|
setRESTHistoryEntries,
|
||||||
setGraphqlHistoryEntries,
|
setGraphqlHistoryEntries,
|
||||||
} from "./history"
|
} from "./history"
|
||||||
|
import {
|
||||||
|
restCollectionStore,
|
||||||
|
graphqlCollectionStore,
|
||||||
|
setGraphqlCollections,
|
||||||
|
setRESTCollections,
|
||||||
|
} from "./collections"
|
||||||
|
|
||||||
function checkAndMigrateOldSettings() {
|
function checkAndMigrateOldSettings() {
|
||||||
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
|
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
|
||||||
@@ -22,6 +28,22 @@ function checkAndMigrateOldSettings() {
|
|||||||
delete vuexData.postwoman.settings
|
delete vuexData.postwoman.settings
|
||||||
window.localStorage.setItem("vuex", JSON.stringify(vuexData))
|
window.localStorage.setItem("vuex", JSON.stringify(vuexData))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vuexData.postwoman && vuexData.postwoman.collections) {
|
||||||
|
const restColls = vuexData.postwoman.collections
|
||||||
|
window.localStorage.setItem("collections", JSON.stringify(restColls))
|
||||||
|
|
||||||
|
delete vuexData.postwoman.collections
|
||||||
|
window.localStorage.setItem("vuex", JSON.stringify(vuexData))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vuexData.postwoman && vuexData.postwoman.collectionsGraphql) {
|
||||||
|
const gqlColls = vuexData.postwoman.collectionsGraphql
|
||||||
|
window.localStorage.setItem("collectionsGraphql", JSON.stringify(gqlColls))
|
||||||
|
|
||||||
|
delete vuexData.postwoman.collectionsGraphql
|
||||||
|
window.localStorage.setItem("vuex", JSON.stringify(vuexData))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSettingsPersistence() {
|
function setupSettingsPersistence() {
|
||||||
@@ -59,9 +81,31 @@ function setupHistoryPersistence() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupCollectionsPersistence() {
|
||||||
|
const restCollectionData = JSON.parse(
|
||||||
|
window.localStorage.getItem("collections") || "[]"
|
||||||
|
)
|
||||||
|
|
||||||
|
const graphqlCollectionData = JSON.parse(
|
||||||
|
window.localStorage.getItem("collectionsGraphql") || "[]"
|
||||||
|
)
|
||||||
|
|
||||||
|
setRESTCollections(restCollectionData)
|
||||||
|
setGraphqlCollections(graphqlCollectionData)
|
||||||
|
|
||||||
|
restCollectionStore.subject$.subscribe(({ state }) => {
|
||||||
|
window.localStorage.setItem("collections", JSON.stringify(state))
|
||||||
|
})
|
||||||
|
|
||||||
|
graphqlCollectionStore.subject$.subscribe(({ state }) => {
|
||||||
|
window.localStorage.setItem("collectionsGraphql", JSON.stringify(state))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function setupLocalPersistence() {
|
export function setupLocalPersistence() {
|
||||||
checkAndMigrateOldSettings()
|
checkAndMigrateOldSettings()
|
||||||
|
|
||||||
setupSettingsPersistence()
|
setupSettingsPersistence()
|
||||||
setupHistoryPersistence()
|
setupHistoryPersistence()
|
||||||
|
setupCollectionsPersistence()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -467,7 +467,8 @@
|
|||||||
</SmartTabs>
|
</SmartTabs>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
<CollectionsGraphqlSaveRequest
|
<CollectionsSaveRequest
|
||||||
|
mode="graphql"
|
||||||
:show="showSaveRequestModal"
|
:show="showSaveRequestModal"
|
||||||
:editing-request="editRequest"
|
:editing-request="editRequest"
|
||||||
@hide-modal="hideRequestModal"
|
@hide-modal="hideRequestModal"
|
||||||
|
|||||||
@@ -553,6 +553,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CollectionsSaveRequest
|
<CollectionsSaveRequest
|
||||||
|
mode="rest"
|
||||||
:show="showSaveRequestModal"
|
:show="showSaveRequestModal"
|
||||||
@hide-modal="hideRequestModal"
|
@hide-modal="hideRequestModal"
|
||||||
:editing-request="editRequest"
|
:editing-request="editRequest"
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ export default Vue.extend({
|
|||||||
1000
|
1000
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
// TODO: Use the new collection store
|
||||||
syncCollections(): void {
|
syncCollections(): void {
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||||
if (this.$store.state.postwoman.collections)
|
if (this.$store.state.postwoman.collections)
|
||||||
|
|||||||
@@ -42,20 +42,6 @@ export const SETTINGS_KEYS = [
|
|||||||
|
|
||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
settings: {},
|
settings: {},
|
||||||
collections: [
|
|
||||||
{
|
|
||||||
name: "My Collection",
|
|
||||||
folders: [],
|
|
||||||
requests: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
collectionsGraphql: [
|
|
||||||
{
|
|
||||||
name: "My GraphQL Collection",
|
|
||||||
folders: [],
|
|
||||||
requests: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
environments: [
|
environments: [
|
||||||
{
|
{
|
||||||
name: "My Environment Variables",
|
name: "My Environment Variables",
|
||||||
|
|||||||
Reference in New Issue
Block a user