Skip to content

Commit 41c2075

Browse files
authored
Dropbox Usability Updates (#12858)
* update sources * actions updates (wip) * updates * updates to create-update-share-link * simplify hidden field * updates to create-update-share-link
1 parent c89a0ed commit 41c2075

File tree

23 files changed

+206
-115
lines changed

23 files changed

+206
-115
lines changed

components/dropbox/actions/create-a-text-file/create-a-text-file.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "Create a Text File",
5-
description: "Creates a brand new text file from plain text content you specify. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
5+
description: "Creates a brand new text file from plain text content you specify. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
66
key: "dropbox-create-a-text-file",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
dropbox,
1111
name: {
1212
type: "string",
13-
label: "File name",
14-
description: "Your new file name.",
13+
label: "File Name",
14+
description: "Your new file name. Example: `textfile.txt`",
1515
},
1616
path: {
1717
propDefinition: [
@@ -36,9 +36,13 @@ export default {
3636
path,
3737
} = this;
3838

39+
const filename = name.includes(".txt")
40+
? name
41+
: `${name}.txt`;
42+
3943
const res = await this.dropbox.uploadFile({
4044
contents: Buffer.from(content),
41-
path: this.dropbox.getNormalizedPath(path, true) + name,
45+
path: this.dropbox.getNormalizedPath(path, true) + filename,
4246
autorename: true,
4347
});
4448

components/dropbox/actions/create-folder/create-folder.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "Create folder",
5-
description: "Create a folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
5+
description: "Create a Folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
66
key: "dropbox-create-folder",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
dropbox,
1111
name: {
1212
type: "string",
13-
label: "Folder name",
13+
label: "Folder Name",
1414
description: "Your new folder name.",
1515
},
1616
path: {

components/dropbox/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "Create or Append to a Text File",
5-
description: "Adds a new line to an existing text file, or creates a file if it doesn't exist. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
5+
description: "Adds a new line to an existing text file, or creates a file if it doesn't exist. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
66
key: "dropbox-create-or-append-to-a-text-file",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
dropbox,
1111
name: {
1212
type: "string",
13-
label: "File name",
13+
label: "File Name",
1414
description: "Your new file name",
1515
},
1616
path: {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import dropbox from "../../dropbox.app.mjs";
2+
3+
export default {
4+
props: {
5+
dropbox: {
6+
...dropbox,
7+
reloadProps: true,
8+
},
9+
},
10+
};

components/dropbox/actions/create-update-share-link/create-update-share-link.mjs

Lines changed: 66 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import dropbox from "../../dropbox.app.mjs";
1+
import common from "./common.mjs";
22
import consts from "../../common/consts.mjs";
33

44
export default {
55
name: "Create/Update a Share Link",
6-
description: "Creates or updates a public share link to the file or folder (It allows to share the file or folder with anyone). [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
6+
description: "Creates or updates a public share link to the file or folder (It allows you to share the file or folder with anyone). [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
77
key: "dropbox-create-update-share-link",
8-
version: "0.0.9",
8+
version: "0.0.10",
99
type: "action",
1010
props: {
11-
dropbox,
11+
...common.props,
12+
alert: {
13+
type: "alert",
14+
alertType: "warning",
15+
content: `Dropbox Free and Basic users are able to create a publicly-available share link which allows downloads.
16+
\nIn order to utilize advanced link sharing functionality, you must be on a Dropbox Essentials plan or higher. See the Dropbox pricing [page](https://www.dropbox.com/plans?trigger=nr#:~:text=Collaborative%20sharing) for more details.`,
17+
},
1218
path: {
1319
propDefinition: [
14-
dropbox,
20+
common.props.dropbox,
1521
"path",
1622
() => ({
1723
initialOptions: [],
@@ -23,42 +29,52 @@ export default {
2329
],
2430
description: "Type the file or folder name to search for it in the user's Dropbox.",
2531
},
26-
requirePassword: {
27-
type: "boolean",
28-
label: "Require password",
29-
description: "Boolean flag to enable or disable password protection.",
30-
default: false,
31-
},
32-
linkPassword: {
33-
type: "string",
34-
label: "Link password",
35-
description: "If `require_password` is `true`, this is needed to specify the password to access the link.",
36-
optional: true,
37-
},
38-
allowDownload: {
39-
type: "boolean",
40-
label: "Allow downloads",
41-
description: "Boolean flag to allow or not allow capabilities for shared links.",
42-
},
43-
expires: {
44-
type: "string",
45-
label: "Expires",
46-
description: "Expiration time of the shared link. By default the link never expires. Make sure to use a valid [timestamp](https://dropbox.github.io/dropbox-sdk-js/global.html#Timestamp) value.",
47-
optional: true,
48-
},
49-
audience: {
50-
type: "string",
51-
label: "Audience",
52-
description: "The new audience who can benefit from the access level specified by the link's access level specified in the `link_access_level` field of `LinkPermissions`. This is used in conjunction with team policies and shared folder policies to determine the final effective audience type in the `effective_audience` field of `LinkPermissions.",
53-
optional: true,
54-
options: consts.CREATE_SHARED_LINK_AUDIENCE_OPTIONS,
55-
},
56-
access: {
57-
type: "string",
58-
label: "Access",
59-
description: "Requested access level you want the audience to gain from this link. Note, modifying access level for an existing link is not supported.",
60-
optional: true,
61-
options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
32+
},
33+
async additionalProps() {
34+
const props = {};
35+
36+
const accountType = await this.getCurrentAccount();
37+
if (accountType !== "basic") {
38+
props.requirePassword = {
39+
type: "boolean",
40+
label: "Require Password",
41+
description: "Boolean flag to enable or disable password protection.",
42+
default: false,
43+
reloadProps: true,
44+
};
45+
props.linkPassword = {
46+
type: "string",
47+
label: "Link Password",
48+
description: "If `require_password` is `true`, this is needed to specify the password to access the link.",
49+
hidden: !this.requirePassword,
50+
};
51+
props.allowDownload = {
52+
type: "boolean",
53+
label: "Allow Downloads",
54+
description: "Boolean flag to allow or not allow capabilities for shared links.",
55+
};
56+
props.expires = {
57+
type: "string",
58+
label: "Expires",
59+
description: "Expiration time of the shared link. By default the link never expires. Make sure to use a valid [timestamp](https://dropbox.github.io/dropbox-sdk-js/global.html#Timestamp) value. Example: `2024-07-18T20:00:00Z`",
60+
optional: true,
61+
};
62+
props.access = {
63+
type: "string",
64+
label: "Access",
65+
description: "Requested access level you want the audience to gain from this link. Note, modifying access level for an existing link is not supported.",
66+
optional: true,
67+
options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
68+
};
69+
}
70+
71+
return props;
72+
},
73+
methods: {
74+
async getCurrentAccount() {
75+
const dpx = await this.dropbox.sdk();
76+
const { result: { account_type: accountType } } = await dpx.usersGetCurrentAccount();
77+
return accountType[".tag"];
6278
},
6379
},
6480
async run({ $ }) {
@@ -67,29 +83,31 @@ export default {
6783
requirePassword,
6884
linkPassword,
6985
expires,
70-
audience,
7186
access,
72-
requestedVisibility,
73-
allowDownload,
74-
removeExpiration,
7587
} = this;
7688

89+
const accountType = await this.getCurrentAccount();
90+
const allowDownload = accountType === "basic"
91+
? true
92+
: this.allowDownload;
93+
7794
if (requirePassword && !linkPassword) {
7895
throw new Error("Since the password is required, please add a linkPassword");
7996
}
8097

98+
if (expires && Date.parse(expires) < Date.now()) {
99+
throw new Error("Expire date must be later than the current datetime");
100+
}
101+
81102
const res = await this.dropbox.createSharedLink({
82103
path: this.dropbox.getPath(path),
83104
settings: {
84105
require_password: requirePassword,
85106
link_password: linkPassword,
86107
expires,
87-
audience,
88108
access,
89-
requested_visibility: requestedVisibility,
90109
allow_download: allowDownload,
91110
},
92-
remove_expiration: removeExpiration,
93111
});
94112
$.export("$summary", `Shared link for "${path?.label || path}" successfully created`);
95113
return res;

components/dropbox/actions/delete-file-folder/delete-file-folder.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "Delete a File/Folder",
5-
description: "Permanently removes a file/folder from the server. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
5+
description: "Permanently removes a file/folder from the server. [See documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
66
key: "dropbox-delete-file-folder",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
dropbox,

components/dropbox/actions/download-file-to-tmp/download-file-to-tmp.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "Download File to TMP",
77
description: "Download a specific file to the temporary directory. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor).",
88
key: "dropbox-download-file-to-tmp",
9-
version: "0.0.5",
9+
version: "0.0.6",
1010
type: "action",
1111
props: {
1212
dropbox,
@@ -21,7 +21,7 @@ export default {
2121
},
2222
name: {
2323
type: "string",
24-
label: "File name",
24+
label: "File Name",
2525
description: "The new name of the file to be saved, including it's extension. e.g: `myFile.csv`",
2626
optional: true,
2727
},
@@ -35,16 +35,18 @@ export default {
3535
path, cleanup,
3636
} = await file();
3737

38+
const extension = result.name.split(".").pop();
39+
3840
const tmpPath = this.name
3941
? `/tmp/${this.name}`
40-
: path;
42+
: `${path}.${extension}`;
4143

4244
await fs.promises.appendFile(tmpPath, Buffer.from(result.fileBinary));
4345
await cleanup();
4446

4547
delete result.fileBinary;
4648

47-
$.export("$summary", `File successfully saved in "/tmp/${this.name}"`);
49+
$.export("$summary", `File successfully saved in "${tmpPath}"`);
4850

4951
return {
5052
tmpPath,

components/dropbox/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "List All Files/Subfolders in a Folder",
5-
description: "Retrieves a list of files or subfolders in a specified folder [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor)",
5+
description: "Retrieves a list of files or subfolders in a specified folder [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor)",
66
key: "dropbox-list-file-folders-in-a-folder",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
dropbox,
@@ -13,6 +13,7 @@ export default {
1313
dropbox,
1414
"path",
1515
() => ({
16+
initialOptions: [],
1617
filter: ({ metadata: { metadata: { [".tag"]: type } } }) => type === "folder",
1718
}),
1819
],
@@ -26,7 +27,7 @@ export default {
2627
},
2728
includeDeleted: {
2829
type: "boolean",
29-
label: "Include deleted",
30+
label: "Include Deleted",
3031
description: "If `true`, the results will include files and folders that used to exist but were deleted.",
3132
default: false,
3233
},

components/dropbox/actions/list-file-revisions/list-file-revisions.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import dropbox from "../../dropbox.app.mjs";
33

44
export default {
55
name: "List File Revisions",
6-
description: "Retrieves a list of file revisions needed to recover previous content. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListRevisions__anchor)",
6+
description: "Retrieves a list of file revisions needed to recover previous content. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListRevisions__anchor)",
77
key: "dropbox-list-file-revisions",
8-
version: "0.0.9",
8+
version: "0.0.10",
99
type: "action",
1010
props: {
1111
dropbox,
@@ -21,7 +21,7 @@ export default {
2121
mode: {
2222
type: "string",
2323
label: "Mode",
24-
description: "Determines the behavior of the API in listing the revisions for a given file path or id.",
24+
description: "Determines the behavior of the API in listing the revisions for a given file path or id. In `path` (default) mode, all revisions at the same file path as the latest file entry are returned. If revisions with the same file id are desired, then mode must be set to `id`.",
2525
optional: true,
2626
options: consts.LIST_FILE_REVISIONS_OPTIONS,
2727
},

components/dropbox/actions/move-file-folder/move-file-folder.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
22

33
export default {
44
name: "Move a File/Folder",
5-
description: "Moves a file or folder to a different location in the user's Dropbox [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
5+
description: "Moves a file or folder to a different location in the user's Dropbox [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
66
key: "dropbox-move-file-folder",
7-
version: "0.0.10",
7+
version: "0.0.11",
88
type: "action",
99
props: {
1010
dropbox,
@@ -20,16 +20,19 @@ export default {
2020
].includes(type),
2121
}),
2222
],
23-
label: "Path from",
23+
label: "Path From",
2424
description: "Type the file or folder name to search for it in the user's Dropbox.",
2525
},
2626
pathTo: {
2727
propDefinition: [
2828
dropbox,
2929
"path",
30+
() => ({
31+
filter: ({ metadata: { metadata: { [".tag"]: type } } }) => type === "folder",
32+
}),
3033
],
31-
label: "Path to",
32-
description: "Type the folder name to search for it in the user's Dropbox. If not filled, it will be moved in the root folder.",
34+
label: "Path To",
35+
description: "Type the folder name to search for it in the user's Dropbox.",
3336
},
3437
autorename: {
3538
type: "boolean",
@@ -39,7 +42,7 @@ export default {
3942
},
4043
allowOwnershipTransfer: {
4144
type: "boolean",
42-
label: "Allow ownership transfer",
45+
label: "Allow Ownership Transfer",
4346
description: "Allow moves by owner even if it would result in an ownership transfer for the content being moved. This does not apply to copies.",
4447
optional: true,
4548
},

0 commit comments

Comments
 (0)