From 4abf23ea9f11a598479ac0fa9eee114ffa961168 Mon Sep 17 00:00:00 2001
From: Tin Geber <tin@greenhost.nl>
Date: Fri, 9 Jun 2023 12:42:37 +0200
Subject: [PATCH] testing custom app additions

---
 frontend/public/assets/ext-gitlab.svg           |  1 +
 frontend/public/markdown/ext-gitlab.md          | 12 ++++++++++++
 frontend/src/components/UserModal/UserModal.tsx | 17 ++++++++++++++---
 frontend/src/modules/dashboard/Dashboard.tsx    |  2 +-
 frontend/src/services/apps/transformations.ts   |  1 +
 frontend/src/services/apps/types.ts             |  1 +
 6 files changed, 30 insertions(+), 4 deletions(-)
 create mode 100644 frontend/public/assets/ext-gitlab.svg
 create mode 100644 frontend/public/markdown/ext-gitlab.md

diff --git a/frontend/public/assets/ext-gitlab.svg b/frontend/public/assets/ext-gitlab.svg
new file mode 100644
index 00000000..95a22f10
--- /dev/null
+++ b/frontend/public/assets/ext-gitlab.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 380 380"><defs><style>.cls-1{fill:#e24329;}.cls-2{fill:#fc6d26;}.cls-3{fill:#fca326;}</style></defs><g id="LOGO"><path class="cls-1" d="M282.83,170.73l-.27-.69-26.14-68.22a6.81,6.81,0,0,0-2.69-3.24,7,7,0,0,0-8,.43,7,7,0,0,0-2.32,3.52l-17.65,54H154.29l-17.65-54A6.86,6.86,0,0,0,134.32,99a7,7,0,0,0-8-.43,6.87,6.87,0,0,0-2.69,3.24L97.44,170l-.26.69a48.54,48.54,0,0,0,16.1,56.1l.09.07.24.17,39.82,29.82,19.7,14.91,12,9.06a8.07,8.07,0,0,0,9.76,0l12-9.06,19.7-14.91,40.06-30,.1-.08A48.56,48.56,0,0,0,282.83,170.73Z"/><path class="cls-2" d="M282.83,170.73l-.27-.69a88.3,88.3,0,0,0-35.15,15.8L190,229.25c19.55,14.79,36.57,27.64,36.57,27.64l40.06-30,.1-.08A48.56,48.56,0,0,0,282.83,170.73Z"/><path class="cls-3" d="M153.43,256.89l19.7,14.91,12,9.06a8.07,8.07,0,0,0,9.76,0l12-9.06,19.7-14.91S209.55,244,190,229.25C170.45,244,153.43,256.89,153.43,256.89Z"/><path class="cls-2" d="M132.58,185.84A88.19,88.19,0,0,0,97.44,170l-.26.69a48.54,48.54,0,0,0,16.1,56.1l.09.07.24.17,39.82,29.82s17-12.85,36.57-27.64Z"/></g></svg>
\ No newline at end of file
diff --git a/frontend/public/markdown/ext-gitlab.md b/frontend/public/markdown/ext-gitlab.md
new file mode 100644
index 00000000..b0c8e6b8
--- /dev/null
+++ b/frontend/public/markdown/ext-gitlab.md
@@ -0,0 +1,12 @@
+---
+title: 'HedgeDoc'
+tileExcerpt: 'DevOps software package which can develop, secure, and operate software'
+---
+
+## Introduction
+
+> **The DevSecOps Platform:** Deliver better software faster with one platform for your entire software delivery lifecycle
+
+## Signing in
+
+## Using GitLab
diff --git a/frontend/src/components/UserModal/UserModal.tsx b/frontend/src/components/UserModal/UserModal.tsx
index b6ceed73..a023ef2f 100644
--- a/frontend/src/components/UserModal/UserModal.tsx
+++ b/frontend/src/components/UserModal/UserModal.tsx
@@ -6,11 +6,22 @@ import { Banner, Modal, ConfirmationModal, InfoModal } from 'src/components';
 import { Input, Select } from 'src/components/Form';
 import { User, UserRole, useUsers } from 'src/services/users';
 import { useAuth } from 'src/services/auth';
+import { useApps } from 'src/services/apps';
+
 import { HIDDEN_APPS } from 'src/modules/dashboard/consts';
-import { appAccessList, initialUserForm } from './consts';
+import { initialUserForm } from './consts';
+
 import { UserModalProps } from './types';
 
 export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps) => {
+  const { apps, loadApps } = useApps();
+
+  // Tell React to load the apps and system information
+  useEffect(() => {
+    loadApps();
+    return () => {};
+  });
+
   const [deleteModal, setDeleteModal] = useState(false);
   const [passwordLinkModal, setPasswordLinkModal] = useState(false);
   const [isAdminRoleSelected, setAdminRoleSelected] = useState(true);
@@ -275,11 +286,11 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
                                 <div className="flex-shrink-0 flex-1 flex items-center">
                                   <img
                                     className="h-10 w-10 rounded-md overflow-hidden"
-                                    src={_.find(appAccessList, ['name', item.name!])?.image}
+                                    src={_.find(apps, ['slug', item.name!])?.assetSrc}
                                     alt={item.name ?? 'Image'}
                                   />
                                   <h3 className="ml-4 text-md leading-6 font-medium text-gray-900">
-                                    {_.find(appAccessList, ['name', item.name!])?.label}
+                                    {_.find(apps, ['slug', item.name!])?.name}
                                   </h3>
                                 </div>
                                 <div>
diff --git a/frontend/src/modules/dashboard/Dashboard.tsx b/frontend/src/modules/dashboard/Dashboard.tsx
index 9bf8acbc..02af89ad 100644
--- a/frontend/src/modules/dashboard/Dashboard.tsx
+++ b/frontend/src/modules/dashboard/Dashboard.tsx
@@ -49,7 +49,7 @@ export const Dashboard: React.FC = () => {
             .filter((app) => HIDDEN_APPS.concat(UTILITY_APPS).indexOf(app.slug) === -1)
             .filter((app) => app.status !== AppStatusEnum.NotInstalled)
             .map((app) => {
-              const version = appVersions[app.slug as keyof typeof appVersions];
+              const version = app.external ? 'CUSTOM' : appVersions[app.slug as keyof typeof appVersions];
               return <DashboardCard app={app} key={app.name} version={version} />;
             })}
         </div>
diff --git a/frontend/src/services/apps/transformations.ts b/frontend/src/services/apps/transformations.ts
index 6b98a878..a95f3117 100644
--- a/frontend/src/services/apps/transformations.ts
+++ b/frontend/src/services/apps/transformations.ts
@@ -11,6 +11,7 @@ export const transformApp = (response: any): App => {
     id: response.id ?? '',
     name: response.name ?? '',
     slug: response.slug ?? '',
+    external: response.external ?? '',
     status: transformAppStatus(response.status),
     url: response.url,
     automaticUpdates: response.automatic_updates,
diff --git a/frontend/src/services/apps/types.ts b/frontend/src/services/apps/types.ts
index 9c5e0e22..a7e05c34 100644
--- a/frontend/src/services/apps/types.ts
+++ b/frontend/src/services/apps/types.ts
@@ -2,6 +2,7 @@ export interface App {
   id: number;
   name: string;
   slug: string;
+  external: boolean;
   status?: AppStatusEnum;
   url: string;
   automaticUpdates: boolean;
-- 
GitLab