Skip to content

Commit

Permalink
v1.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 authored Jan 20, 2023
2 parents 560db58 + a52782d commit 9e42a23
Show file tree
Hide file tree
Showing 23 changed files with 1,085 additions and 224 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.26.2",
"version": "1.27.0",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,7 +47,7 @@
"@tiptap/vue-3": "^2.0.0-beta.209",
"@viselect/vanilla": "^3.2.4",
"@vue-flow/additional-components": "^1.3.3",
"@vue-flow/core": "^1.12.1",
"@vue-flow/core": "^1.12.5",
"@vueuse/head": "^1.0.22",
"@vueuse/rxjs": "^9.1.1",
"@vuex-orm/core": "^0.36.4",
Expand All @@ -74,7 +74,7 @@
"nanoid": "^4.0.0",
"object-path": "^0.11.8",
"papaparse": "^5.3.1",
"pinia": "^2.0.28",
"pinia": "^2.0.29",
"prosemirror-commands": "^1.5.0",
"prosemirror-dropcursor": "^1.6.1",
"prosemirror-gapcursor": "^1.3.1",
Expand Down Expand Up @@ -104,7 +104,7 @@
"@vue/compiler-sfc": "^3.2.41",
"archiver": "^5.3.1",
"autoprefixer": "^10.4.12",
"babel-loader": "^8.2.2",
"babel-loader": "^9.1.2",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "^11.0.0",
"core-js": "^3.27.1",
Expand All @@ -115,7 +115,7 @@
"eslint-config-prettier": "^8.6.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^9.4.0",
"file-loader": "^6.2.0",
Expand All @@ -134,7 +134,7 @@
"vue-loader": "^17.0.0",
"web-worker": "^1.2.0",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
}
}
4 changes: 2 additions & 2 deletions src/components/block/BlockBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
class="block-menu-container absolute top-0 hidden w-full"
style="transform: translateY(-100%)"
>
<div>
<div class="pointer-events-none">
<p
title="Block id (click to copy)"
class="block-menu text-overflow inline-block px-1 dark:text-gray-300"
class="block-menu pointer-events-auto text-overflow inline-block px-1 dark:text-gray-300"
style="max-width: 96px; margin-bottom: 0"
@click="insertToClipboard"
>
Expand Down
11 changes: 5 additions & 6 deletions src/components/newtab/workflow/edit/EditConditions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ import { ref, watch, onMounted, shallowReactive } from 'vue';
import { useI18n } from 'vue-i18n';
import { nanoid } from 'nanoid';
import Draggable from 'vuedraggable';
import { sleep } from '@/utils/helper';
import { debounce } from '@/utils/helper';
import SharedConditionBuilder from '@/components/newtab/shared/SharedConditionBuilder/index.vue';
const props = defineProps({
Expand Down Expand Up @@ -190,11 +190,10 @@ function deleteCondition(index, id) {
function updateData(value) {
emit('update:data', { ...props.data, ...value });
}
async function onEnd() {
props.editor.addSelectedNodes([]);
await sleep(1000);
props.editor.addSelectedNodes([props.editor.getNode.value(props.blockId)]);
}
const onEnd = debounce(() => {
props.editor.updateNodeInternals([props.blockId]);
}, 500);
watch(
conditions,
Expand Down
138 changes: 138 additions & 0 deletions src/components/newtab/workflow/edit/EditGoogleDrive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<template>
<div>
<div v-if="!store.integrations.googleDrive">
<p>
You haven't
<a
href="https://docs.automa.site/integrations/google-drive.html"
target="_blank"
class="underline"
>connected Automa to Google Drive</a
>.
</p>
</div>
<template v-else>
<ui-textarea
:model-value="data.description"
class="w-full"
:placeholder="t('common.description')"
@change="updateData({ description: $event })"
/>
<ui-select
:model-value="data.action"
class="w-full mt-4"
@change="updateData({ action: $event })"
>
<option v-for="action in actions" :key="action" :value="action">
{{ t(`workflow.blocks.google-drive.actions.${action}`) }}
</option>
</ui-select>
<div class="mt-4">
<ul class="space-y-2">
<li
v-for="(item, index) in filePaths"
:key="item.id"
class="p-2 border rounded-lg"
>
<div class="flex items-center">
<ui-select
v-model="item.type"
class="grow mr-2"
placeholder="File location"
>
<option value="url">URL</option>
<option value="local" :disabled="!hasFileAccess">
Local computer
</option>
<option
value="downloadId"
:disabled="!permissions.has.downloads"
>
Download id
</option>
</ui-select>
<ui-button icon @click="filePaths.splice(index, 1)">
<v-remixicon name="riDeleteBin7Line" />
</ui-button>
</div>
<edit-autocomplete>
<ui-input
v-model="item.name"
placeholder="Filename (optional)"
class="w-full mt-2"
/>
</edit-autocomplete>
<edit-autocomplete>
<ui-input
v-model="item.path"
:placeholder="placeholders[item.type]"
title="File location"
class="w-full mt-2"
/>
</edit-autocomplete>
</li>
</ul>
<ui-button class="mt-4" variant="accent" @click="addFile">
Add file
</ui-button>
</div>
</template>
</div>
</template>
<script setup>
import { ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { nanoid } from 'nanoid/non-secure';
import cloneDeep from 'lodash.clonedeep';
import browser from 'webextension-polyfill';
import { useStore } from '@/stores/main';
import { useHasPermissions } from '@/composable/hasPermissions';
import EditAutocomplete from './EditAutocomplete.vue';
const props = defineProps({
data: {
type: Object,
default: () => ({}),
},
hideBase: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['update:data']);
const { t } = useI18n();
const store = useStore();
store.checkGDriveIntegration();
const actions = ['upload'];
const placeholders = {
downloadId: '0',
local: 'C:\\file.zip',
url: 'https://example.com/file.zip',
};
const permissions = useHasPermissions(['downloads']);
const filePaths = ref(cloneDeep(props.data.filePaths));
const hasFileAccess = ref(true);
function updateData(value) {
emit('update:data', { ...props.data, ...value });
}
function addFile() {
filePaths.value.push({ path: '', type: 'url', name: '', id: nanoid(5) });
}
browser.extension.isAllowedFileSchemeAccess().then((value) => {
hasFileAccess.value = value;
});
watch(
filePaths,
(paths) => {
updateData({ filePaths: paths });
},
{ deep: true }
);
</script>
63 changes: 51 additions & 12 deletions src/components/newtab/workflow/edit/EditGoogleSheets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
{{ t(`workflow.blocks.google-sheets.select.${action}`) }}
</option>
</ui-select>
<edit-autocomplete>
<slot />
<edit-autocomplete
v-if="
!googleDrive ||
(data.inputSpreadsheetId === 'manually' && data.type !== 'create')
"
>
<ui-input
:model-value="data.spreadsheetId"
class="w-full"
Expand Down Expand Up @@ -45,7 +51,7 @@
Automa doesn't have access to the spreadsheet
<v-remixicon name="riInformationLine" size="18" class="inline" />
</a>
<edit-autocomplete>
<edit-autocomplete v-if="data.type !== 'create'">
<ui-input
:model-value="data.range"
class="mt-1 w-full"
Expand Down Expand Up @@ -92,9 +98,13 @@
{{ previewDataState.errorMessage }}
</p>
</template>
<template v-else-if="data.type === 'getRange'">
<template v-else-if="['getRange', 'create'].includes(data.type)">
<p class="mt-4">
{{ t('workflow.blocks.google-sheets.spreadsheetId.label') }}
</p>
<insert-workflow-data :data="data" variables @update="updateData" />
<ui-button
v-if="data.type === 'getRange'"
:loading="previewDataState.status === 'loading'"
variant="accent"
class="mt-4"
Expand Down Expand Up @@ -207,8 +217,10 @@
<script setup>
import { shallowReactive, defineAsyncComponent } from 'vue';
import { useI18n } from 'vue-i18n';
import { googleSheets, fetchApi } from '@/utils/api';
import { useToast } from 'vue-toastification';
import { fetchApi } from '@/utils/api';
import { convert2DArrayToArrayObj, debounce } from '@/utils/helper';
import googleSheetsApi from '@/utils/googleSheetsApi';
import EditAutocomplete from './EditAutocomplete.vue';
import InsertWorkflowData from './InsertWorkflowData.vue';
Expand All @@ -221,12 +233,25 @@ const props = defineProps({
type: Object,
default: () => ({}),
},
googleDrive: Boolean,
additionalActions: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['update:data']);
const { t } = useI18n();
const toast = useToast();
const actions = ['get', 'getRange', 'update', 'append', 'clear'];
const actions = [
'get',
'getRange',
'update',
'append',
'clear',
...props.additionalActions,
];
const dataFrom = ['data-columns', 'custom'];
const valueInputOptions = ['RAW', 'USER_ENTERED'];
const insertDataOptions = ['OVERWRITE', 'INSERT_ROWS'];
Expand Down Expand Up @@ -272,18 +297,32 @@ async function previewData() {
range: props.data.range,
spreadsheetId: props.data.spreadsheetId,
};
if (!props.data.spreadsheetId) {
toast.error(
props.googleDrive
? 'No spreadsheet is selected'
: 'Spreadsheet id is empty'
);
previewDataState.status = 'idle';
return;
}
if (!props.data.range) {
toast.error('Spreadsheet range is empty');
previewDataState.status = 'idle';
return;
}
const response = await (isGetValues
? googleSheets.getValues(params)
: googleSheets.getRange(params));
? googleSheetsApi(props.googleDrive).getValues(params)
: googleSheetsApi(props.googleDrive).getRange(params));
if (!response.ok) {
const error = await response.json();
let result = props.googleDrive ? response : await response.json();
throw new Error(error.message || response.statusText);
if (!response.ok && !props.googleDrive) {
throw new Error(result.message || response.statusText);
}
let result = await response.json();
if (isGetValues) {
const values = result?.values ?? [];
result = props.data.firstRowAsKey
Expand Down
Loading

0 comments on commit 9e42a23

Please sign in to comment.