Skip to content

Commit

Permalink
feat: Update connect profile Admin UI - MEED-2409 - Meeds-io/MIPs#64 (#…
Browse files Browse the repository at this point in the history
…96)

This PR will improve the admin github connector UI
  • Loading branch information
AzmiTouil committed Sep 18, 2023
1 parent 0902705 commit 3cb8344
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,34 @@ githubWebhookManagement.search=Search
githubConnector.label.profile=Github Profile
githubConnector.label.description=Connect your Github account so your actions from there can be gamified and recognized
githubConnector.admin.label.description=Connect your Github account so your actions from there can be gamified and recognized
githubConnector.admin.label.summary=GitHub summary
githubConnector.admin.label.configuration=GitHub configuration
githubConnector.admin.label.connect=Connect Github
githubConnector.admin.label.allow.connect=Allow users to connect their GitHub account
githubConnector.admin.label.instructions=To allow your users connecting their GitHub profile, please follow those instructions:
githubConnector.admin.label.instructions.stepOne=1.Ask your GitHub Project administrator to create a Oauth application
githubConnector.admin.label.instructions.stepOne=1.Create a Oauth application
githubConnector.admin.label.instructions.stepTwo=2.Once done, fill these fields below with the generated API Key, Secret Key, and Redirect URL defined in the OAuth application
githubConnector.admin.label.seeMore=See more

githubConnector.admin.label.addOrganization=Add a GitHub Organization
githubConnector.admin.label.editOrganization=Edit GitHub Organization
githubConnector.admin.label.enableWatch=Enable to watch events from a GitHub organization.
githubConnector.admin.label.organization=GitHub Organization
githubConnector.admin.label.organization.placeholder=Enter the GitHub organization name
githubConnector.admin.label.accessToken=Personal access token
githubConnector.admin.label.addAccessToken=Add a personal access token
githubConnector.admin.label.accessToken.placeholder=Enter the GitHub personal access token
githubConnector.admin.label.Webhook=Webhook
githubConnector.admin.label.accessToken.instructions.stepOne=Generate an access token from your GitHub settings
githubConnector.admin.label.accessToken.instructions.stepTwo=Be aware that your token can expire so ensure yourself the expiration is set as expected
githubConnector.admin.label.accessToken.instructions.stepThree=When creating the token, please make sure these scopes are selected

githubConnector.admin.label.organizationToWatch=You have set organizations to watch.
githubConnector.admin.label.letEnableConnection=Now, let's enable the connection
githubConnector.admin.label.enableConnection=Enable connection
githubConnector.admin.label.letAllowConnection=Now, let's allow your contributors to connect their profile
githubConnector.admin.label.allowConnection=Allow connection
githubConnector.admin.label.connectProfile=Connect GitHub profile

githubConnector.admin.label.identifyOrganization=Identify the organization to watch

githubConnector.admin.label.repositories=Repositories
githubConnector.admin.label.repositories.placeholder=Monitor repositories to be watched
Expand All @@ -44,10 +57,13 @@ githubConnector.admin.label.watchScope.placeholder=When creating an action, prog
githubConnector.webhook.form.label.button.next=Next
githubConnector.webhook.form.label.button.back=Back
githubConnector.webhook.label.watchedBy=Project watched from {0} by
githubConnector.webhook.label.watchProject=Watch project
githubConnector.webhook.label.watchProject=Connect GitHub Organization to watch
githubConnector.webhook.label.watchProject.placeholder=Connect your Organization and give your contributors way to start earning points thanks to their actions
githubConnector.webhook.label.addOrganization=Add Organization
githubConnector.webhook.label.loadMore=Load More
githubConnector.webhook.title.confirmDeleteProject=Delete github project?
githubConnector.webhook.message.confirmDeleteConnectorHook=Are you sure you want to delete this github project?
githubConnector.webhook.message.confirmBeforeProceeding=Please confirm before proceeding

githubConnector.webhook.details.repository=Repository
githubConnector.webhook.details.event=Event
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2023 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<template>
<exo-drawer
ref="githubConnectionSettingDrawer"
v-model="drawer"
right
@closed="clear">
<template #title>
{{ $t('githubConnector.admin.label.connectProfile') }}
</template>
<template v-if="drawer" #content>
<v-form
ref="ConnectionSettingForm"
v-model="isValidForm"
class="form-horizontal pt-0 pb-4"
flat />
<div class="d-flex flex-column">
<div class="ps-4 pb-4 d-flex flex-column dark-grey-color">
<v-card-text class="pb-3 ps-0">
{{ $t('githubConnector.admin.label.instructions') }}
</v-card-text>
<v-card-text class="pb-0 ps-0 dark-grey-color">
{{ $t('githubConnector.admin.label.instructions.stepOne') }} (<a href="https://github.com/settings/applications/new" target="_blank">
{{ $t('githubConnector.admin.label.seeMore') }}
<v-icon size="14" class="pb-1 pe-1">fas fa-external-link-alt</v-icon>
</a>)
</v-card-text>
<v-card-text class="pt-0 ps-0 dark-grey-color">
{{ $t('githubConnector.admin.label.instructions.stepTwo') }}
</v-card-text>
</div>
<v-card-text class="text-left py-0 dark-grey-color">
{{ $t('gamification.connectors.settings.apiKey') }}
</v-card-text>
<v-card-text>
<input
ref="connectorApiKey"
v-model="apiKey"
:placeholder="$t('gamification.connectors.settings.apiKey.placeholder')"
type="text"
class="ignore-vuetify-classes full-width"
required
@input="disabled = false"
@change="disabled = false">
</v-card-text>
<v-card-text class="text-left py-0 dark-grey-color">
{{ $t('gamification.connectors.settings.secretKey') }}
</v-card-text>
<v-card-text>
<input
ref="connectorSecretKey"
v-model="secretKey"
:placeholder="$t('gamification.connectors.settings.secretKey.placeholder')"
type="text"
class="ignore-vuetify-classes full-width"
required
@input="disabled = false"
@change="disabled = false">
</v-card-text>
<v-card-text class="text-left py-0 dark-grey-color">
{{ $t('gamification.connectors.settings.redirectUrl') }}
</v-card-text>
<v-card-text>
<input
ref="connectorRedirectUrl"
v-model="redirectUrl"
:placeholder="$t('gamification.connectors.settings.redirectUrl.placeholder')"
type="text"
class="ignore-vuetify-classes full-width"
required
@input="disabled = false"
@change="disabled = false">
</v-card-text>
</div>
</template>
<template #footer>
<div class="d-flex">
<v-spacer />
<v-btn
class="btn me-2"
@click="close">
{{ $t('githubWebhookManagement.cancel') }}
</v-btn>
<v-btn
:disabled="disabledSave"
class="btn btn-primary"
@click="saveConnectorSetting">
{{ $t('githubWebhookManagement.save') }}
</v-btn>
</div>
</template>
</exo-drawer>
</template>

<script>
export default {
data: () => ({
apiKey: null,
secretKey: null,
redirectUrl: null,
isValidForm: false,
drawer: false,
disabled: true,
}),
created() {
this.$root.$on('github-connection-setting-drawer', this.open);
},
computed: {
disabledSave() {
return this.disabled || !this.secretKey || !this.apiKey || !this.redirectUrl;
},
},
methods: {
open(apiKey, secretKey, redirectUrl) {
this.apiKey = apiKey;
this.secretKey = secretKey;
this.redirectUrl = redirectUrl;
if (this.$refs.githubConnectionSettingDrawer) {
this.$refs.githubConnectionSettingDrawer.open();
}
},
close() {
if (this.$refs.githubConnectionSettingDrawer) {
this.$refs.githubConnectionSettingDrawer.close();
}
},
saveConnectorSetting() {
this.$root.$emit('connector-settings-updated', this.apiKey, this.secretKey, this.redirectUrl);
this.close();
},
clear() {
this.apiKey = null;
this.secretKey = null;
this.redirectUrl = null;
this.disabled = true;
},
}
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<v-list-item-title class="align-self-start">
{{ title }}
</v-list-item-title>
<v-list-item-subtitle class="text-truncate d-flex caption mt-1">{{ description }}</v-list-item-subtitle>
<v-list-item-subtitle v-if="description" class="text-truncate d-flex caption mt-1">{{ description }}</v-list-item-subtitle>
<div class="d-flex flex-row">
<span class="text-truncate d-flex caption d-content pt-2px"> {{ watchedByLabel }} </span>
<exo-user-avatar
Expand All @@ -48,18 +48,16 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<v-spacer />
<div class="d-flex align-center px-2">
<v-btn
small
icon
@click="editGithubWebHook">
<v-icon class="primary--text" size="18">fas fa-edit</v-icon>
<v-icon size="20">fas fa-edit</v-icon>
</v-btn>
</div>
<div class="d-flex align-center px-2">
<div class="d-flex align-center">
<v-btn
small
icon
@click="deleteConfirmDialog">
<v-icon class="error-color" size="18">fas fa-trash-alt</v-icon>
<v-icon class="error-color mx-2" size="20">fas fa-trash-alt</v-icon>
</v-btn>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,35 @@ along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<template>
<v-card flat>
<div
class="py-4">
<v-card class="pt-5" flat>
<div class="d-flex flex-row">
<div>
<v-card-text class="px-0 py-0 dark-grey-color font-weight-bold">
{{ $t('githubConnector.webhook.label.watchProject') }}
</v-card-text>
<v-card-text class="dark-grey-color px-0 pt-0">
{{ $t('githubConnector.webhook.label.watchProject.placeholder') }}
</v-card-text>
</div>
<v-spacer />
<v-btn
v-if="!emptyHookList"
class="ma-auto"
icon
@click="createGithubWebHook">
<v-icon class="mx-2 primary--text" size="20">fas fa-plus</v-icon>
</v-btn>
</div>
<div v-if="emptyHookList" class="d-flex align-center py-5">
<v-btn
class="btn btn-primary"
class="btn btn-primary ma-auto"
small
@click="createGithubWebHook">
<v-icon size="14" dark>
fas fa-plus
</v-icon>
<span class="ms-2 d-none d-lg-inline subtitle-1">
{{ $t('githubConnector.webhook.label.watchProject') }}
<span class="ms-2 subtitle-2 font-weight-bold">
{{ $t('githubConnector.webhook.label.addOrganization') }}
</span>
</v-btn>
</div>
Expand Down Expand Up @@ -73,6 +90,9 @@ export default {
hasMore() {
return this.hooksCount > this.limit;
},
emptyHookList() {
return this.hooks?.length === 0;
}
},
created() {
this.$root.$on('github-hooks-updated', this.refreshHooks);
Expand All @@ -88,7 +108,10 @@ export default {
.then(data => {
this.hooks = data.webhooks;
this.hooksCount = data.size || 0;
return this.$nextTick();
return this.$nextTick()
.then(() => {
this.$emit('updated', this.hooks);
});
}).finally(() => this.loading = false);
},
createGithubWebHook() {
Expand Down
Loading

0 comments on commit 3cb8344

Please sign in to comment.