Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/oauth2/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('clients', $result);
$this->initialState->provideInitialState('oauth2-doc-link', $this->urlGenerator->linkToDocs('admin-oauth2'));

\OCP\Util::addStyle('oauth2', 'settings-admin');
\OCP\Util::addScript('oauth2', 'settings-admin', 'core');
return new TemplateResponse(
'oauth2',
'admin',
Expand Down
173 changes: 0 additions & 173 deletions apps/oauth2/src/App.vue

This file was deleted.

153 changes: 52 additions & 101 deletions apps/oauth2/src/components/OAuthItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,120 +2,71 @@
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

<script setup lang="ts">
import type { IOauthClient } from '../views/AdminSettings.vue'

import { t } from '@nextcloud/l10n'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcPasswordField from '@nextcloud/vue/components/NcPasswordField'
import IconTrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'

defineProps<{
/**
* The OAuth client to display
*/
client: IOauthClient
}>()

defineEmits<{
delete: []
}>()
</script>

<template>
<tr>
<td>{{ name }}</td>
<td>{{ redirectUri }}</td>
<td><code>{{ clientId }}</code></td>
<td>{{ client.name }}</td>
<td>
<div class="action-secret">
<code>{{ renderedSecret }}</code>
<NcButton
v-if="clientSecret !== ''"
variant="tertiary-no-background"
:aria-label="toggleAriaLabel"
@click="toggleSecret">
<template #icon>
<EyeOutline :size="20" />
</template>
</NcButton>
</div>
<code :class="$style.oAuthItem__code">{{ client.redirectUri }}</code>
</td>
<td class="action-column">
<td>
<code :class="$style.oAuthItem__code">{{ client.clientId }}</code>
</td>
<td>
<NcPasswordField
v-if="client.clientSecret"
:class="$style.oAuthItem__clientSecret"
:aria-label="t('oauth2', 'Secret key')"
as-text
:model-value="client.clientSecret"
show-trailing-button />
<span v-else>*****</span>
</td>
<td>
<NcButton
variant="tertiary-no-background"
:aria-label="t('oauth2', 'Delete')"
@click="$emit('delete', id)">
:title="t('oauth2', 'Delete')"
variant="error"
@click="$emit('delete')">
<template #icon>
<Delete
:size="20"
:title="t('oauth2', 'Delete')" />
<IconTrashCanOutline :size="20" />
</template>
</NcButton>
</td>
</tr>
</template>

<script>

import NcButton from '@nextcloud/vue/components/NcButton'
import EyeOutline from 'vue-material-design-icons/EyeOutline.vue'
import Delete from 'vue-material-design-icons/TrashCanOutline.vue'

export default {
name: 'OAuthItem',
components: {
Delete,
NcButton,
EyeOutline,
},

props: {
client: {
type: Object,
required: true,
},
},

data() {
return {
id: this.client.id,
name: this.client.name,
redirectUri: this.client.redirectUri,
clientId: this.client.clientId,
clientSecret: this.client.clientSecret,
renderSecret: false,
}
},

computed: {
renderedSecret() {
if (this.renderSecret) {
return this.clientSecret
} else {
return '****'
}
},

toggleAriaLabel() {
if (!this.renderSecret) {
return t('oauth2', 'Show client secret')
}
return t('oauth2', 'Hide client secret')
},
},

methods: {
toggleSecret() {
this.renderSecret = !this.renderSecret
},
},
<style module>
.oAuthItem__code {
display: inline-block;
overflow-x: scroll;
padding-block: var(--default-grid-baseline);
text-wrap: nowrap;
vertical-align: middle;
width: 100%;
}
</script>

<style scoped>
.action-secret {
display: flex;
align-items: center;
}

.action-secret code {
padding-top: 5px;
}

td code {
display: inline-block;
vertical-align: middle;
}

table.inline td {
border: none;
padding: 5px;
}

.action-column {
display: flex;
justify-content: flex-end;
padding-inline-end: 0;
}
.oAuthItem__clientSecret {
min-width: 200px;
}
</style>
16 changes: 6 additions & 10 deletions apps/oauth2/src/main.js → apps/oauth2/src/settings-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
*/

import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'
import App from './App.vue'
import { createApp } from 'vue'
import AdminSettings from './views/AdminSettings.vue'

Vue.prototype.t = t
Vue.prototype.OC = OC
import 'vite/modulepreload-polyfill'

const clients = loadState('oauth2', 'clients')

const View = Vue.extend(App)
const oauth = new View({
propsData: {
clients,
},
const app = createApp(AdminSettings, {
modelValue: clients,
})
oauth.$mount('#oauth2')
app.mount('#oauth2')
Loading
Loading