Skip to content

Commit

Permalink
fix(ui): properly pass namespace parameter for fetching files (#4351)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic committed Jul 17, 2024
1 parent d2db856 commit 6c43645
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
6 changes: 5 additions & 1 deletion ui/src/components/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</el-tabs>

<section data-component="FILENAME_PLACEHOLDER#container" ref="container" v-bind="$attrs" :class="{...containerClass, 'd-flex flex-row': isEditorActiveTab, 'namespace-editor': isNamespaceEditor}">
<EditorSidebar v-if="isEditorActiveTab" ref="sidebar" :style="`flex: 0 0 calc(${explorerWidth}% - 11px);`" />
<EditorSidebar v-if="isEditorActiveTab" ref="sidebar" :style="`flex: 0 0 calc(${explorerWidth}% - 11px);`" :current-n-s="namespace" />
<div v-if="isEditorActiveTab && explorerVisible" @mousedown.prevent.stop="dragSidebar" class="slider" />
<div :style="`flex: 1 1 ${100 - (isEditorActiveTab && explorerVisible ? explorerWidth : 0)}%;`">
<component
Expand Down Expand Up @@ -62,6 +62,10 @@
type: String,
required: false,
default: undefined
},
namespace: {
type: String,
default: null
}
},
emits: [
Expand Down
28 changes: 17 additions & 11 deletions ui/src/components/inputs/EditorSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@
};
export default {
props: {
currentNS: {
type: String,
default: null
}
},
components: {
Magnify,
FilePlus,
Expand Down Expand Up @@ -445,7 +451,7 @@
},
async loadNodes(node, resolve) {
if (node.level === 0) {
const payload = {namespace: this.$route.params.namespace};
const payload = {namespace: this.currentNS ?? this.$route.params.namespace};
const items = await this.readDirectory(payload);
this.renderNodes(items);
Expand All @@ -454,7 +460,7 @@
if (node.level >= 1) {
const payload = {
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
path: this.getPath(node),
};
Expand Down Expand Up @@ -492,7 +498,7 @@
async searchFilesList(value) {
if(!value) return;
const results = await this.searchFiles({namespace: this.$route.params.namespace, query: value});
const results = await this.searchFiles({namespace: this.currentNS ?? this.$route.params.namespace, query: value});
this.searchResults = results.map(result => result.replace(/^\/*/, ""));
},
chooseSearchResults(item){
Expand Down Expand Up @@ -559,7 +565,7 @@
const start = path.substring(0, path.lastIndexOf("/") + 1);
this.renameFileDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
old: `${start}${this.renameDialog.old}`,
new: `${start}${this.renameDialog.name}`,
type: this.renameDialog.type,
Expand All @@ -572,7 +578,7 @@
async nodeMoved(draggedNode) {
try {
await this.moveFileDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
old: this.nodeBeforeDrag.path,
new: this.getPath(draggedNode.data.id),
type: draggedNode.data.type,
Expand Down Expand Up @@ -649,7 +655,7 @@
const content = await this.readFile(file);
this.importFileDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
content,
path: `${folderPath}/${fileName}`,
});
Expand All @@ -669,7 +675,7 @@
const [name, extension] = file.name.split(".");
this.importFileDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
content,
path: file.name,
});
Expand Down Expand Up @@ -698,7 +704,7 @@
}
},
exportFiles() {
this.exportFileDirectory({namespace: this.$route.params.namespace});
this.exportFileDirectory({namespace: this.currentNS ?? this.$route.params.namespace});
},
async addFile({file, creation, shouldReset = true}) {
let FILE;
Expand Down Expand Up @@ -739,7 +745,7 @@
this.dialog.folder ? `${this.dialog.folder}/` : ""
}${NAME}`;
await this.createFile({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
path,
content,
name: NAME,
Expand Down Expand Up @@ -790,7 +796,7 @@
const {node, node: {data}} = this.confirmation;
await this.deleteFileDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
path: this.getPath(node),
name: data.fileName,
type: data.type,
Expand Down Expand Up @@ -831,7 +837,7 @@
}${fileName}`;
await this.createDirectory({
namespace: this.$route.params.namespace,
namespace: this.currentNS ?? this.$route.params.namespace,
path,
name: fileName,
});
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/namespace/Namespace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ul>
</template>
</top-nav-bar>
<tabs :route-name="$route.param && $route.param.id ? 'namespaces/update' : ''" :tabs="tabs" id="namespaces" />
<tabs :route-name="$route.param && $route.param.id ? 'namespaces/update' : ''" :tabs="tabs" :namespace="$route.params.id" id="namespaces" />
</template>

<script setup>
Expand Down Expand Up @@ -98,6 +98,7 @@
props: {
tab: "editor",
isNamespace: true,
namespace: this.$route.params.id,
isReadOnly: false,
},
query: {
Expand Down

0 comments on commit 6c43645

Please sign in to comment.