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
The following commit(s) were added to refs/heads/main by this push:
new 8e30936 Rollback errorrously deleted Project Classes (#434)
8e30936 is described below
commit 8e30936b1e771d1d59b08c33730cae0ad229e243
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Thu Jul 28 21:29:11 2022 -0400
Rollback errorrously deleted Project Classes (#434)
---
karavan-app/src/main/webapp/src/Main.tsx | 2 +-
.../src/main/webapp/src/builder/BuilderPage.tsx | 1 -
.../main/webapp/src/components/ComponentCard.tsx | 2 +-
.../src/main/webapp/src/kamelets/KameletCard.tsx | 2 +-
.../src/main/webapp/src/projects/ProjectPage.tsx | 2 +-
karavan-core/src/core/api/ProjectModelApi.ts | 71 ++++++++++++++++++++++
karavan-core/src/core/model/ProjectModel.ts | 43 +++++++++++++
7 files changed, 118 insertions(+), 5 deletions(-)
diff --git a/karavan-app/src/main/webapp/src/Main.tsx
b/karavan-app/src/main/webapp/src/Main.tsx
index 4e718cf..7d2fad7 100644
--- a/karavan-app/src/main/webapp/src/Main.tsx
+++ b/karavan-app/src/main/webapp/src/Main.tsx
@@ -125,7 +125,7 @@ export class Main extends React.Component<Props, State> {
pageNav = () => {
const pages: MenuItem[] = [
- new MenuItem("dashboard", "Dashboard", <TachometerAltIcon/>),
+ // new MenuItem("dashboard", "Dashboard", <TachometerAltIcon/>),
new MenuItem("projects", "Projects", <ProjectsIcon/>),
new MenuItem("eip", "Enterprise Integration Patterns", <EipIcon/>),
new MenuItem("kamelets", "Kamelets", <KameletsIcon/>),
diff --git a/karavan-app/src/main/webapp/src/builder/BuilderPage.tsx
b/karavan-app/src/main/webapp/src/builder/BuilderPage.tsx
index 605521c..43c27d5 100644
--- a/karavan-app/src/main/webapp/src/builder/BuilderPage.tsx
+++ b/karavan-app/src/main/webapp/src/builder/BuilderPage.tsx
@@ -181,7 +181,6 @@ export class BuilderPage extends React.Component<Props,
State> {
}
getHeader() {
- const {project} = this.state;
return (
<PageSection className="tools-section" variant={this.props.dark ?
PageSectionVariants.darker : PageSectionVariants.light}>
<Flex className="tools" direction={{default: 'row'}}
justifyContent={{default: 'justifyContentSpaceBetween'}} spaceItems={{default:
'spaceItemsLg'}}>
diff --git a/karavan-app/src/main/webapp/src/components/ComponentCard.tsx
b/karavan-app/src/main/webapp/src/components/ComponentCard.tsx
index 6d465f3..1fe5269 100644
--- a/karavan-app/src/main/webapp/src/components/ComponentCard.tsx
+++ b/karavan-app/src/main/webapp/src/components/ComponentCard.tsx
@@ -16,7 +16,7 @@
*/
import React from 'react';
import {
- CardHeader, Card, CardTitle, CardBody, CardActions, CardFooter,Badge
+ CardHeader, Card, CardTitle, CardBody, CardFooter,Badge
} from '@patternfly/react-core';
import '../designer/karavan.css';
import {camelIcon, CamelUi} from "../designer/utils/CamelUi";
diff --git a/karavan-app/src/main/webapp/src/kamelets/KameletCard.tsx
b/karavan-app/src/main/webapp/src/kamelets/KameletCard.tsx
index 31ac3c6..2bae9fc 100644
--- a/karavan-app/src/main/webapp/src/kamelets/KameletCard.tsx
+++ b/karavan-app/src/main/webapp/src/kamelets/KameletCard.tsx
@@ -16,7 +16,7 @@
*/
import React from 'react';
import {
- CardHeader, Card, CardTitle, CardBody, CardActions, CardFooter,Badge
+ CardHeader, Card, CardTitle, CardBody, CardFooter,Badge
} from '@patternfly/react-core';
import '../designer/karavan.css';
import {KameletModel} from "karavan-core/lib/model/KameletModels";
diff --git a/karavan-app/src/main/webapp/src/projects/ProjectPage.tsx
b/karavan-app/src/main/webapp/src/projects/ProjectPage.tsx
index a96ca7f..2af988a 100644
--- a/karavan-app/src/main/webapp/src/projects/ProjectPage.tsx
+++ b/karavan-app/src/main/webapp/src/projects/ProjectPage.tsx
@@ -21,7 +21,7 @@ import {
ToggleGroup,
ToggleGroupItem,
CodeBlockCode,
- CodeBlock, Skeleton, Switch, Checkbox, Tabs, Tab
+ CodeBlock, Skeleton, Checkbox, Tabs, Tab
} from '@patternfly/react-core';
import '../designer/karavan.css';
import {MainToolbar} from "../MainToolbar";
diff --git a/karavan-core/src/core/api/ProjectModelApi.ts
b/karavan-core/src/core/api/ProjectModelApi.ts
new file mode 100644
index 0000000..c6dbe7d
--- /dev/null
+++ b/karavan-core/src/core/api/ProjectModelApi.ts
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {ProjectModel, ProjectProperty} from "../model/ProjectModel";
+
+export class ProjectModelApi {
+
+ static propertiesToProject = (properties: string): ProjectModel => {
+ const lines = properties.split(/\r?\n/).filter(text =>
text.trim().length > 0 && !text.trim().startsWith("#"));
+ const project = new ProjectModel();
+
+ project.properties = lines.map(value => this.stringToProperty(value));
+ return project;
+ }
+
+ static stringToProperty = (line: string): ProjectProperty => {
+ const pair = line.split("=");
+ const value = pair[1];
+ return ProjectProperty.createNew(pair[0], value);
+ }
+
+ static propertiesToString = (properties: ProjectProperty[]): string => {
+ const result: string[] = [];
+ properties.forEach((p, key) => {
+ if (p !== undefined) result.push(p.key + "=" + p.value);
+ })
+ return result.join("\n");
+ }
+
+ static getProfiles = (properties: ProjectProperty[]): string[] => {
+ const result: string[] = [];
+ properties.forEach((p, key) => {
+ if (p.key.startsWith("%")) {
+ const profile = p.key.substring(1, p.key.indexOf("."));
+ if (!result.includes(profile)) result.push(profile);
+ }
+ })
+ return result;
+ }
+
+ static updateProperties = (properties: string, project: ProjectModel):
string => {
+ const mapFromProject = this.projectToMap(project);
+ const result: string[] = [];
+ mapFromProject.forEach((value, key) => {
+ if (value !== undefined) result.push(key + "=" + value);
+ })
+ return result.join("\n");
+ }
+
+ static projectToMap = (project: ProjectModel): Map<string, any> => {
+ const map = new Map<string, any>();
+
+ if (project.properties && project.properties.length > 0) {
+ project.properties.forEach(p => map.set(p.key, p.value));
+ }
+ return map;
+ }
+}
diff --git a/karavan-core/src/core/model/ProjectModel.ts
b/karavan-core/src/core/model/ProjectModel.ts
new file mode 100644
index 0000000..396fd3c
--- /dev/null
+++ b/karavan-core/src/core/model/ProjectModel.ts
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {v4 as uuidv4} from "uuid";
+
+export class ProjectProperty {
+ id: string = ''
+ key: string = ''
+ value: any
+
+ public constructor(init?: Partial<ProjectProperty>) {
+ Object.assign(this, init);
+ }
+
+ static createNew(key: string, value: any): ProjectProperty {
+ return new ProjectProperty({id: uuidv4(), key: key, value: value})
+ }
+}
+
+export class ProjectModel {
+ properties: ProjectProperty[] = []
+
+ public constructor(init?: Partial<ProjectModel>) {
+ Object.assign(this, init);
+ }
+
+ static createNew(init?: Partial<ProjectModel>): ProjectModel {
+ return new ProjectModel(init ? init : {})
+ }
+}
\ No newline at end of file