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

feat(editor): Adjust Google sign-in button to adhere to the guidelines #5248

Merged
merged 5 commits into from
Jan 25, 2023
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/editor-ui/public/google-auth/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/editor-ui/public/google-auth/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/editor-ui/public/google-auth/pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions packages/editor-ui/src/components/Banner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
</div>
</div>

<slot name="button" v-if="$slots.button" />
<n8n-button
v-if="buttonLabel"
v-else-if="buttonLabel"
:label="buttonLoading && buttonLoadingLabel ? buttonLoadingLabel : buttonLabel"
:title="buttonTitle"
:type="theme"
Expand Down Expand Up @@ -85,7 +86,9 @@ export default Vue.extend({
.icon {
position: absolute;
left: 14px;
top: 18px;
top: 0;
bottom: 0;
margin: auto 0;
}

.dangerIcon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@
:buttonLabel="$locale.baseText('credentialEdit.credentialConfig.reconnect')"
:buttonTitle="$locale.baseText('credentialEdit.credentialConfig.reconnectOAuth2Credential')"
@click="$emit('oauth')"
/>
>
<template #button>
<p
v-text="`${$locale.baseText('credentialEdit.credentialConfig.reconnect')}:`"
:class="$style.googleReconnectLabel"
/>
<GoogleAuthButton v-if="isGoogleOAuthType" @click="$emit('oauth')" />
</template>
</banner>

<banner
v-show="testedSuccessfully && !showValidationWarning"
Expand Down Expand Up @@ -132,6 +140,7 @@ import { useWorkflowsStore } from '@/stores/workflows';
import { useRootStore } from '@/stores/n8nRootStore';
import { useNDVStore } from '@/stores/ndv';
import { useCredentialsStore } from '@/stores/credentials';
import GoogleAuthButton from './GoogleAuthButton.vue';

export default mixins(restApi).extend({
name: 'CredentialConfig',
Expand All @@ -140,6 +149,7 @@ export default mixins(restApi).extend({
CopyInput,
CredentialInputs,
OauthButton,
GoogleAuthButton,
},
props: {
credentialType: {
Expand Down Expand Up @@ -305,4 +315,7 @@ export default mixins(restApi).extend({
margin-bottom: var(--spacing-l);
}
}
.googleReconnectLabel {
margin-right: var(--spacing-3xs);
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<button
:class="$style.googleAuthBtn"
:title="$locale.baseText('credentialEdit.oAuthButton.signInWithGoogle')"
@click.stop.prevent="$emit('click')"
:style="googleAuthButtons"
/>
</template>

<script lang="ts" setup>
import { useRootStore } from '@/stores/n8nRootStore';

const { baseUrl } = useRootStore();
const googleAuthButtons = {
'--google-auth-btn-normal': `url(${baseUrl}google-auth/normal.png`,
'--google-auth-btn-focus': `url(${baseUrl}google-auth/focus.png`,
'--google-auth-btn-pressed': `url(${baseUrl}google-auth/pressed.png`,
'--google-auth-btn-disabled': `url(${baseUrl}google-auth/disabled.png`,
};
</script>

<style module lang="scss">
.googleAuthBtn {
--google-auth-btn-height: 46px;
cursor: pointer;
border: none;
padding: 0;
background-image: var(--google-auth-btn-normal);
background-repeat: no-repeat;
background-color: transparent;
background-size: 100% 100%;
border-radius: 4px;
height: var(--google-auth-btn-height);
// We have to preserve exact google button ratio
width: calc(var(--google-auth-btn-height) * 4.15217391);

&:focus,
&:hover {
outline: none;
background-image: var(--google-auth-btn-focus);
}
&:active {
background-image: var(--google-auth-btn-pressed);
}
&:disabled {
background-image: var(--google-auth-btn-disabled);
}
}
</style>
38 changes: 10 additions & 28 deletions packages/editor-ui/src/components/CredentialEdit/OauthButton.vue
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
<template>
<span>
<img
v-if="isGoogleOAuthType"
:src="basePath + 'google-signin-light.png'"
:class="$style.googleIcon"
:alt="$locale.baseText('credentialEdit.oAuthButton.signInWithGoogle')"
@click.stop="$emit('click')"
/>
<div :class="$style.container">
<GoogleAuthButton v-if="isGoogleOAuthType" @click="$emit('click')" />
<n8n-button
v-else
:label="$locale.baseText('credentialEdit.oAuthButton.connectMyAccount')"
size="large"
@click.stop="$emit('click')"
/>
</span>
</div>
</template>

<script lang="ts">
import { useRootStore } from '@/stores/n8nRootStore';
import { mapStores } from 'pinia';
<script lang="ts" setup>
import GoogleAuthButton from './GoogleAuthButton.vue';
import Vue from 'vue';

export default Vue.extend({
props: {
isGoogleOAuthType: {
type: Boolean,
},
},
computed: {
...mapStores(useRootStore),
basePath(): string {
return this.rootStore.baseUrl;
},
},
});
defineProps<{
isGoogleOAuthType: boolean;
}>();
</script>

<style module lang="scss">
.googleIcon {
width: 191px;
cursor: pointer;
.container {
display: inline-block;
}
</style>