You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2024/08/09 19:37:17 UTC
(camel-karavan) 04/04: UI improvements
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit a7a1df0165874b080c1288f7447c44b8bf44e9ac
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Fri Aug 9 15:37:06 2024 -0400
UI improvements
---
karavan-app/src/main/webui/src/api/KaravanApi.tsx | 13 +++++++++++--
karavan-app/src/main/webui/src/api/ProjectService.ts | 20 ++++++++++++--------
.../src/main/webui/src/project/ProjectPage.tsx | 4 ++--
.../src/main/webui/src/project/files/FilesTab.tsx | 15 +++++++++++++--
.../main/webui/src/project/files/FilesToolbar.tsx | 7 +++++++
.../main/webui/src/project/files/UploadFileModal.tsx | 2 +-
6 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/karavan-app/src/main/webui/src/api/KaravanApi.tsx b/karavan-app/src/main/webui/src/api/KaravanApi.tsx
index 6b283473..9a8e0f34 100644
--- a/karavan-app/src/main/webui/src/api/KaravanApi.tsx
+++ b/karavan-app/src/main/webui/src/api/KaravanApi.tsx
@@ -573,8 +573,17 @@ export class KaravanApi {
});
}
- static async rolloutDeployment(name: string, environment: string, after: (res: AxiosResponse<any>) => void) {
- instance.post('/ui/infrastructure/deployment/rollout/' + environment + '/' + name, "")
+ static async rolloutDeployment(projectId: string, environment: string, after: (res: AxiosResponse<any>) => void) {
+ instance.post('/ui/infrastructure/deployment/rollout/' + environment + '/' + projectId, "")
+ .then(res => {
+ after(res);
+ }).catch(err => {
+ after(err);
+ });
+ }
+
+ static async startDeployment(projectId: string, environment: string, after: (res: AxiosResponse<any>) => void) {
+ instance.post('/ui/infrastructure/deployment/start/' + environment + '/' + projectId, "")
.then(res => {
after(res);
}).catch(err => {
diff --git a/karavan-app/src/main/webui/src/api/ProjectService.ts b/karavan-app/src/main/webui/src/api/ProjectService.ts
index 97a33b3d..62cdfe7a 100644
--- a/karavan-app/src/main/webui/src/api/ProjectService.ts
+++ b/karavan-app/src/main/webui/src/api/ProjectService.ts
@@ -277,6 +277,17 @@ export class ProjectService {
ProjectService.refreshAllCamelStatuses();
}
+ public static refreshProjectFiles(projectId: string) {
+ KaravanApi.getFiles(projectId, (files: ProjectFile[]) => {
+ useFilesStore.setState({files: files});
+ ProjectService.reloadKamelets(projectId);
+ });
+
+ KaravanApi.getFilesDiff(projectId, (diff: any) => {
+ useFilesStore.setState({diff: diff});
+ });
+ }
+
public static refreshProjectData(projectId: string) {
KaravanApi.getProject(projectId, (project: Project) => {
// ProjectEventBus.selectProject(project);
@@ -288,14 +299,7 @@ export class ProjectService {
})
});
});
- KaravanApi.getFiles(projectId, (files: ProjectFile[]) => {
- useFilesStore.setState({files: files});
- ProjectService.reloadKamelets(projectId);
- });
-
- KaravanApi.getFilesDiff(projectId, (diff: any) => {
- useFilesStore.setState({diff: diff});
- });
+ ProjectService.refreshProjectFiles(projectId);
KaravanApi.getConfigMaps((any: []) => {
InfrastructureAPI.setConfigMaps(any);
diff --git a/karavan-app/src/main/webui/src/project/ProjectPage.tsx b/karavan-app/src/main/webui/src/project/ProjectPage.tsx
index ac757f40..06537f5f 100644
--- a/karavan-app/src/main/webui/src/project/ProjectPage.tsx
+++ b/karavan-app/src/main/webui/src/project/ProjectPage.tsx
@@ -24,7 +24,7 @@ import {
import './ProjectPage.css';
import {ProjectToolbar} from "./ProjectToolbar";
import {ProjectLogPanel} from "../log/ProjectLogPanel";
-import {BUILD_IN_PROJECTS, Project, ProjectType} from "../api/ProjectModels";
+import {BUILD_IN_PROJECTS, Project} from "../api/ProjectModels";
import {useAppConfigStore, useFilesStore, useFileStore, useProjectsStore, useProjectStore} from "../api/ProjectStore";
import {MainToolbar} from "../designer/MainToolbar";
import {ProjectTitle} from "./ProjectTitle";
@@ -90,7 +90,7 @@ export function ProjectPage() {
const showFilePanel = file !== undefined && operation === 'select';
const isKubernetes = config.infrastructure === 'kubernetes'
- const containerTabName = isKubernetes ? "Pods" : "Containers"
+ const containerTabName = isKubernetes ? "Deployment" : "Container"
const isDevEnvironment = config.environment === 'dev';
const showBuildTab = isKubernetes || isDevEnvironment;
return (
diff --git a/karavan-app/src/main/webui/src/project/files/FilesTab.tsx b/karavan-app/src/main/webui/src/project/files/FilesTab.tsx
index da6ab20b..86814d6a 100644
--- a/karavan-app/src/main/webui/src/project/files/FilesTab.tsx
+++ b/karavan-app/src/main/webui/src/project/files/FilesTab.tsx
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import React, {useState} from 'react';
+import React, {useEffect, useState} from 'react';
import {
Badge,
Bullseye,
@@ -52,6 +52,7 @@ import {UploadFileModal} from "./UploadFileModal";
import {shallow} from "zustand/shallow";
import {CreateIntegrationModal} from "./CreateIntegrationModal";
import {DiffFileModal} from "./DiffFileModal";
+import {ProjectService} from "../../api/ProjectService";
export function FilesTab () {
@@ -66,7 +67,17 @@ export function FilesTab () {
.map(name => diff[name] === 'DELETED' ? name: '')
.filter(name => name !== '' && !filenames.includes(name));
const deletedFiles: ProjectFile[] = deletedFilenames.map(d => new ProjectFile(d, project.projectId, '', 0))
- const allFiles = files.concat(deletedFiles)
+ const allFiles = files.concat(deletedFiles);
+
+ useEffect(() => {
+ onRefresh();
+ }, []);
+
+ function onRefresh() {
+ if (project.projectId) {
+ ProjectService.refreshProjectFiles(project.projectId);
+ }
+ }
function needCommit(filename: string): boolean {
return diff && diff[filename] !== undefined;
diff --git a/karavan-app/src/main/webui/src/project/files/FilesToolbar.tsx b/karavan-app/src/main/webui/src/project/files/FilesToolbar.tsx
index d2125d32..2ac4c01c 100644
--- a/karavan-app/src/main/webui/src/project/files/FilesToolbar.tsx
+++ b/karavan-app/src/main/webui/src/project/files/FilesToolbar.tsx
@@ -37,6 +37,7 @@ import {useFilesStore, useFileStore, useProjectStore} from "../../api/ProjectSto
import {shallow} from "zustand/shallow";
import {ProjectService} from "../../api/ProjectService";
import PushIcon from "@patternfly/react-icons/dist/esm/icons/code-branch-icon";
+import RefreshIcon from "@patternfly/react-icons/dist/esm/icons/sync-alt-icon";
import {getShortCommit, isEmpty} from "../../util/StringUtils";
export function FileToolbar () {
@@ -163,6 +164,12 @@ export function FileToolbar () {
}
return <Flex className="toolbar" direction={{default: "row"}} justifyContent={{default: "justifyContentFlexEnd"}}>
+ <FlexItem>
+ <Button icon={<RefreshIcon/>}
+ variant={"link"}
+ onClick={() => ProjectService.refreshProjectFiles(project.projectId)}
+ />
+ </FlexItem>
<FlexItem>{getLastUpdatePanel()}</FlexItem>
<FlexItem>
<Tooltip content="Pull from git" position={"bottom-end"}>
diff --git a/karavan-app/src/main/webui/src/project/files/UploadFileModal.tsx b/karavan-app/src/main/webui/src/project/files/UploadFileModal.tsx
index 63cd29c8..2b3e90d8 100644
--- a/karavan-app/src/main/webui/src/project/files/UploadFileModal.tsx
+++ b/karavan-app/src/main/webui/src/project/files/UploadFileModal.tsx
@@ -87,7 +87,7 @@ export function UploadFileModal() {
setFile("none");
}
- const handleFileInputChange = (file: File) => setValue('name',file.name);
+ const handleFileInputChange = (file: File) => setValue('name', file.name);
const handleFileReadStarted = (fileHandle: File) => setIsLoading(true);
const handleFileReadFinished = (fileHandle: File) => setIsLoading(false);
const handleTextOrDataChange = (data: string) => setValue('code', data);