Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link swagger in navbar #1984

Merged
merged 16 commits into from
Jul 13, 2023
Merged

Link swagger in navbar #1984

merged 16 commits into from
Jul 13, 2023

Conversation

pat-s
Copy link
Contributor

@pat-s pat-s commented Jul 11, 2023

(testing)

fix point 1 from #1944

@pat-s
Copy link
Contributor Author

pat-s commented Jul 11, 2023

@anbraten Tagging you as I saw you edited the vue files at some point.

I wanted to add a link in the navbar pointing to the swagger UI interface. Couldn't quite get it working by just trying to bake something together without Vue knowledge. If you like the idea, it might be a small thing for you to finalize the idea?

@6543
Copy link
Member

6543 commented Jul 12, 2023

@pat-s ref = #1944

@pat-s pat-s mentioned this pull request Jul 12, 2023
@qwerty287
Copy link
Contributor

@pat-s I implemented this directly in GitHub's web editor so the is completely untested (also there are probably issues with prettier).

Diff
diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json
index b8f421204f..c3dd57dea6 100644
--- a/web/src/assets/locales/en.json
+++ b/web/src/assets/locales/en.json
@@ -5,6 +5,7 @@
     "repos": "Repos",
     "repositories": "Repositories",
     "docs": "Docs",
+    "api": "API",
     "logout": "Logout",
     "search": "Search…",
     "username": "Username",
diff --git a/web/src/components/atomic/APILink.vue b/web/src/components/atomic/APILink.vue
deleted file mode 100644
index cbdcd3cf07..0000000000
--- a/web/src/components/atomic/APILink.vue
+++ /dev/null
@@ -1,25 +0,0 @@
-<template>
-  <a
-    :href="`${apiUrl}`"
-    :title="$t('documentation_for', { topic: topic })"
-    target="_blank"
-    class="text-blue-500 hover:text-blue-600 cursor-pointer mt-1"
-    ><Icon name="question" class="!w-4 !h-4"
-  /></a>
-</template>
-
-<script lang="ts" setup>
-import { computed, toRef } from 'vue';
-
-import Icon from '~/components/atomic/Icon.vue';
-
-const props = defineProps<{
-  url: string;
-  topic: string;
-}>();
-
-const apiBaseUrl = FIXME:;
-const url = FIXME:;
-const topic = toRef(props, 'topic');
-const apiUrl = computed(() => (url.value.startsWith('http') ? url.value : `${apiBaseUrl}${url.value}`));
-</script>
diff --git a/web/src/components/layout/header/Navbar.vue b/web/src/components/layout/header/Navbar.vue
index e1f100a089..e39cf5b35d 100644
--- a/web/src/components/layout/header/Navbar.vue
+++ b/web/src/components/layout/header/Navbar.vue
@@ -71,7 +71,8 @@ export default defineComponent({
     const route = useRoute();
     const authentication = useAuthentication();
     const { darkMode } = useDarkMode();
-    const docsUrl = window.WOODPECKER_DOCS;
+    const docsUrl = config.docs;
+    const apiUrl = `${config.rootURL}/swagger/index.html`;
 
     function doLogin() {
       authentication.authenticate(route.fullPath);
@@ -79,7 +80,7 @@ export default defineComponent({
 
     const version = config.version?.startsWith('next') ? 'next' : config.version;
 
-    return { darkMode, user: authentication.user, doLogin, docsUrl, version };
+    return { darkMode, user: authentication.user, doLogin, docsUrl, version, apiUrl };
   },
 });
 </script>

@pat-s pat-s added this to the 1.1.0 milestone Jul 12, 2023
@woodpecker-bot
Copy link
Collaborator

woodpecker-bot commented Jul 12, 2023

Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-1984.surge.sh

@6543 6543 added the ui frontend related label Jul 12, 2023
@pat-s
Copy link
Contributor Author

pat-s commented Jul 13, 2023

The navbar item is there

image

but the link is still faulty, for some reason it expands to $INSTANCE/null/swagger/index.html (the inserted null is the issue)

@qwerty287 qwerty287 mentioned this pull request Jul 7, 2023
3 tasks
@pat-s
Copy link
Contributor Author

pat-s commented Jul 13, 2023

Working now!

@pat-s pat-s marked this pull request as ready for review July 13, 2023 08:06
@pat-s pat-s requested a review from a team July 13, 2023 08:07
@6543 6543 merged commit 004d72a into main Jul 13, 2023
@6543 6543 deleted the link-swagger branch July 13, 2023 18:34
@6543 6543 modified the milestones: 1.1.0, 1.0.0 Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui frontend related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants