diff --git a/client/.eslintrc.json b/client/.eslintrc.json index 544d01163..47799514f 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -198,6 +198,7 @@ "noreferrer", "nowrap", "nteract", + "ntlm", "nullable", "oauth2", "objectstores", @@ -249,6 +250,7 @@ "serializable", "sftp", "shareability", + "sharepoint", "slugify", "starrers", "statuspage", diff --git a/client/src/features/project/utils/projectCloudStorage.utils.test.ts b/client/src/features/project/utils/projectCloudStorage.utils.test.ts index 3bb33fb87..135544d4b 100644 --- a/client/src/features/project/utils/projectCloudStorage.utils.test.ts +++ b/client/src/features/project/utils/projectCloudStorage.utils.test.ts @@ -1,4 +1,8 @@ -import { storageDefinitionFromConfig } from "./projectCloudStorage.utils"; +import { CloudStorageSchema } from "../components/cloudStorage/projectCloudStorage.types.ts"; +import { + getSchemaOptions, + storageDefinitionFromConfig, +} from "./projectCloudStorage.utils"; describe("storageDefinitionFromConfig", () => { it("should return the correct storage definition", () => { @@ -88,4 +92,222 @@ describe("storageDefinitionFromConfig", () => { target_path: "external_storage/aws", }); }); + + it("should return the correct schema options", () => { + const schema: CloudStorageSchema[] = [ + { + name: "PolyBox", + description: "Polybox", + prefix: "polybox", + options: [ + { + name: "url", + help: "URL of http host to connect to.\n\nE.g. https://example.com.", + provider: "personal", + default: "https://polybox.ethz.ch/remote.php/webdav/", + default_str: "", + required: false, + sensitive: false, + advanced: false, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "user", + help: "User name.\n\nIn case NTLM authentication is used, the username should be in the format 'Domain\\User'.", + provider: "personal", + default: "", + default_str: "", + required: false, + sensitive: false, + advanced: false, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "pass", + help: "Password.", + provider: "", + default: "", + default_str: "", + required: false, + sensitive: true, + advanced: false, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: true, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "bearer_token", + help: "Bearer token instead of user/pass (e.g. a Macaroon).", + provider: "personal", + default: "", + default_str: "", + required: false, + sensitive: true, + advanced: false, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "bearer_token_command", + help: "Command to run to get a bearer token.", + provider: "personal", + default: "", + default_str: "", + required: false, + sensitive: false, + advanced: true, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "encoding", + help: "", + provider: "", + default: "", + default_str: "", + required: false, + sensitive: false, + advanced: true, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "headers", + help: 'Set HTTP headers for all transactions.\n\nUse this to set additional HTTP headers for all transactions\n\nThe input format is comma separated list of key,value pairs. Standard\n[CSV encoding](https://godoc.org/encoding/csv) may be used.\n\nFor example, to set a Cookie use \'Cookie,name=value\', or \'"Cookie","name=value"\'.\n\nYou can set multiple headers, e.g. \'"Cookie","name=value","Authorization","xxx"\'.\n', + provider: "personal", + default: "", + default_str: "", + required: false, + sensitive: false, + advanced: true, + exclusive: false, + type: "CommaSepList", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "pacer_min_sleep", + help: "Minimum time to sleep between API calls.", + provider: "", + default: 10000000, + default_str: "10ms", + required: false, + sensitive: false, + advanced: true, + exclusive: false, + type: "Duration", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "provider", + help: "Choose the mode to access the data source.", + provider: "", + default: "", + default_str: "", + examples: [ + { + value: "personal", + help: "Connect to your personal storage space. This data connector cannot be used to share access to a folder.", + provider: "", + }, + { + value: "shared", + help: "Connect a 'public' folder shared with others. A 'public' folder may or may not be protected with a password.", + provider: "", + }, + ], + required: true, + sensitive: false, + advanced: false, + exclusive: true, + type: "string", + value: "", + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + { + name: "public_link", + help: "Shared folder link. E.g., https://polybox.ethz.ch/index.php/s/8NffJ3rFyHaVyyy", + provider: "shared", + default: "", + default_str: "", + required: true, + sensitive: false, + advanced: false, + exclusive: false, + type: "string", + value: "", + examples: [], + ispassword: false, + datatype: "string", + hide: false, + filteredExamples: [], + }, + ], + }, + ]; + const result = getSchemaOptions(schema, false, "polybox", "shared"); + const passOption = result?.find((o) => o.name === "pass"); + expect(passOption?.help).toEqual( + "If there is a password for the folder, enter that in the password field. Otherwise, leave it blank" + ); + expect(passOption?.friendlyName).toEqual("Password"); + + const resultPersonal = getSchemaOptions( + schema, + false, + "polybox", + "personal" + ); + const passOptionPersonal = resultPersonal?.find((o) => o.name === "pass"); + expect(passOptionPersonal?.friendlyName).toEqual("Token (or password)"); + }); });