Skip to content

Commit

Permalink
fix(ui): namespace files calls were not including tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p authored and Skraye committed Jun 10, 2024
1 parent ea3ba99 commit 9e4e5f8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ui/src/stores/namespaces.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Utils from "../utils/utils";
import {apiUrl} from "override/utils/route";

const BASE = (namespace) => `${apiUrl(this)}/namespaces/${namespace}`;
function base(namespace) {
return `${apiUrl(this)}/namespaces/${namespace}`;
}
const HEADERS = {headers: {"Content-Type": "multipart/form-data"}};

const slashPrefix = (path) => (path.startsWith("/") ? path : `/${path}`);
Expand All @@ -15,13 +17,13 @@ export default {
actions: {
// Create a directory
async createDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files/directory?path=${slashPrefix(payload.path)}`;
const URL = `${base.call(this, payload.namespace)}/files/directory?path=${slashPrefix(payload.path)}`;
await this.$http.post(URL);
},

// List directory content
async readDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files/directory${payload.path ? `?path=${slashPrefix(safePath(payload.path))}` : ""}`;
const URL = `${base.call(this, payload.namespace)}/files/directory${payload.path ? `?path=${slashPrefix(safePath(payload.path))}` : ""}`;
const request = await this.$http.get(URL);

return request.data ?? [];
Expand All @@ -33,21 +35,21 @@ export default {
const BLOB = new Blob([payload.content], {type: "text/plain"});
DATA.append("fileContent", BLOB);

const URL = `${BASE(payload.namespace)}/files?path=${slashPrefix(payload.path)}`;
const URL = `${base.call(this, payload.namespace)}/files?path=${slashPrefix(payload.path)}`;
await this.$http.post(URL, DATA, HEADERS);
},

// Get namespace file content
async readFile(_, payload) {
const URL = `${BASE(payload.namespace)}/files?path=${slashPrefix(safePath(payload.path))}`;
const URL = `${base.call(this, payload.namespace)}/files?path=${slashPrefix(safePath(payload.path))}`;
const request = await this.$http.get(URL);

return request.data ?? [];
},

// Search for namespace files
async searchFiles(_, payload) {
const URL = `${BASE(payload.namespace)}/files/search?q=${payload.query}`;
const URL = `${base.call(this, payload.namespace)}/files/search?q=${payload.query}`;
const request = await this.$http.get(URL);

return request.data ?? [];
Expand All @@ -59,31 +61,31 @@ export default {
const BLOB = new Blob([payload.content], {type: "text/plain"});
DATA.append("fileContent", BLOB);

const URL = `${BASE(payload.namespace)}/files?path=${slashPrefix(safePath(payload.path))}`;
const URL = `${base.call(this, payload.namespace)}/files?path=${slashPrefix(safePath(payload.path))}`;
await this.$http.post(URL, DATA, HEADERS);
},

// Move a file or directory
async moveFileDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files?from=${slashPrefix(payload.old)}&to=${slashPrefix(payload.new)}`;
const URL = `${base.call(this, payload.namespace)}/files?from=${slashPrefix(payload.old)}&to=${slashPrefix(payload.new)}`;
await this.$http.put(URL);
},

// Rename a file or directory
async renameFileDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files?from=${slashPrefix(payload.old)}&to=${slashPrefix(payload.new)}`;
const URL = `${base.call(this, payload.namespace)}/files?from=${slashPrefix(payload.old)}&to=${slashPrefix(payload.new)}`;
await this.$http.put(URL);
},

// Delete a file or directory
async deleteFileDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files?path=${slashPrefix(payload.path)}`;
const URL = `${base.call(this, payload.namespace)}/files?path=${slashPrefix(payload.path)}`;
await this.$http.delete(URL);
},

// Export namespace files as a ZIP
async exportFileDirectory(_, payload) {
const URL = `${BASE(payload.namespace)}/files/export`;
const URL = `${base.call(this, payload.namespace)}/files/export`;
const request = await this.$http.get(URL);

const name = payload.namespace + "_files.zip";
Expand Down

0 comments on commit 9e4e5f8

Please sign in to comment.