Skip to content

Commit

Permalink
Account Name working E2E.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmercier42 committed Dec 1, 2023
1 parent 3635a8f commit 00ea643
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 3 deletions.
15 changes: 14 additions & 1 deletion webapp/app/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,16 @@
"edit": "Edit",
"delete": "Delete",
"data": {
"account_name": "Account Name",
"account_key": "Account Key",
"container_name": "Container Name",
"default_ref": "Default ref",
"repository": "Repository",
"token": "Token",
"url": "URL"
},
"token_how": "How?",
"key_pair_how": "How to obtain a key pair?",
"github_webhook_url_how": "How?",
"github_webhook_accent_cli_1": "You need to have a valid <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/mirego/accent/tree/master/cli\">accent-cli</a> setup for the hook to work.",
"github_webhook_accent_cli_2": "The <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/mirego/accent/blob/master/cli/examples/react/accent.json\">accent.json</a> file at the root of your project will be used.",
Expand All @@ -508,6 +512,14 @@
"new_conflicts": "New strings to review",
"complete_review": "Project is 100% reviewed"
}
},
"target_version": {
"label": "Target Version",
"options": {
"all": "All Versions",
"latest": "Latest Version",
"specific": "Specific Version"
}
}
}
},
Expand Down Expand Up @@ -956,7 +968,8 @@
"DISCORD": "Discord",
"GITHUB": "GitHub",
"SLACK": "Slack",
"MICROSOFT": "Microsoft"
"MICROSOFT": "Microsoft",
"AZURE": "Azure"
},
"search_input_placeholder_text": "Search for a string…"
},
Expand Down
14 changes: 13 additions & 1 deletion webapp/app/locales/fr-ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,15 @@
"edit": "Éditer",
"delete": "Supprimer",
"data": {
"account_name": "Nom du compte",
"account_key": "Clé du compte",
"default_ref": "Réf par défaut",
"repository": "Dépôt",
"token": "Jeton",
"url": "URL"
},
"token_how": "Comment?",
"key_pair_how": "Comment obtenir une paire de clés?",
"github_webhook_url_how": "Comment?",
"github_webhook_accent_cli_1": "Vous devez avoir une configuration <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/mirego/accent/tree/master/cli\">accent-cli</a> valide pour le crochet au travail.",
"github_webhook_accent_cli_2": "Le <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/mirego/accent/blob/master/cli/examples/react/accent.json\">accent.json</a > fichier à la racine de votre projet sera utilisé.",
Expand All @@ -524,6 +527,14 @@
"new_conflicts": "Nouvelles chaîne à réviser",
"complete_review": "Le projet est revu à 100%"
}
},
"target_version": {
"label": "Version Cible",
"options": {
"all": "Toutes les versions",
"latest": "Dernière version",
"specific": "Version spécifique"
}
}
}
},
Expand Down Expand Up @@ -956,7 +967,8 @@
"DISCORD": "Discord",
"GITHUB": "GitHub",
"SLACK": "Slack",
"MICROSOFT": "Microsoft"
"MICROSOFT": "Microsoft",
"AZURE": "Azure"
},
"search_input_placeholder_text": "Rechercher une chaîne…"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import fmt from 'simple-fmt';
import Component from '@glimmer/component';
import {action} from '@ember/object';
import config from 'accent-webapp/config/environment';

interface Args {
accessKey: any;
defaultRef: any;
errors: any;
project: any;
secretKey: any;
targetVersion: any;
specificVersion: any;
url: any;
onChangeAccountName: (token: string) => void;
onChangeSecretKey: (defaultRef: string) => void;
onChangeUrl: (url: string) => void;
onChangeTargetVersion: (url: string) => void;
onChangeSpecificVersion: (url: string) => void;
}

export default class Azure extends Component<Args> {
get webhookUrl() {
const host = window.location.origin;

return `${host}${fmt(
config.API.HOOKS_PATH,
'azure',
this.args.project.id,
'<YOUR_API_TOKEN_HERE>'
)}`;
}

@action
changeAccountName(event: Event) {
const target = event.target as HTMLInputElement;

this.args.onChangeAccountName(target.value);
}

@action
changeSecretKey(event: Event) {
const target = event.target as HTMLInputElement;

this.args.onChangeSecretKey(target.value);
}

@action
changeUrl(event: Event) {
const target = event.target as HTMLInputElement;

this.args.onChangeUrl(target.value);
}

@action
changeTargetVersion(event: Event) {
const target = event.target as HTMLInputElement;

this.args.onChangeTargetVersion(target.value);
}

@action
changeSpecificVersion(event: Event) {
const target = event.target as HTMLInputElement;

this.args.onChangeTargetVersion(target.value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.instructions {
border-top: 1px solid var(--background-light-highlight);
padding-top: 10px;
margin: 20px 0 10px;
}

.instructions-text {
margin-top: 7px;
font-style: italic;
color: #555;

a {
font-family: var(--font-monospace);
color: var(--color-primary);
text-decoration: none;

&:focus,
&:hover {
text-decoration: underline;
opacity: 0.8;
}
}
}

.data-control {
margin-bottom: 15px;
}

.data-title {
display: block;
margin-bottom: 5px;
font-size: 13px;
font-weight: bold;
}

.data-title-help {
margin-left: 4px;
font-size: 11px;
font-weight: normal;
text-decoration: none;
color: var(--color-primary);

&:focus,
&:hover {
text-decoration: underline;
}
}

.textInput {
@extend %textInput;
flex-grow: 1;
flex-shrink: 0;
padding: 8px 10px;
margin-right: 10px;
background: #fafafa;
max-width: 500px;
width: 100%;
font-family: var(--font-monospace);
font-size: 11px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<ProjectSettings::Integrations::Form::DataControlText
@error={{field-error @errors 'data.accountKey'}}
@label={{t 'components.project_settings.integrations.data.account_name'}}
@placeholder='myazureaccount'
@value={{@accountName}}
@onChange={{this.changeAccountName}}
@helpLinkHref='https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html'
@helpLinkTitle={{t 'components.project_settings.integrations.key_pair_how'}}
/>

<ProjectSettings::Integrations::Form::DataControlText
@error={{field-error @errors 'data.token'}}
@label={{t 'components.project_settings.integrations.data.account_key'}}
@placeholder='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='
@value={{@token}}
@onChange={{this.changeSecretKey}}
@helpLinkHref='https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html'
@helpLinkTitle={{t 'components.project_settings.integrations.key_pair_how'}}
/>

<ProjectSettings::Integrations::Form::DataControlText
@error={{field-error @errors 'data.token'}}
@label={{t 'components.project_settings.integrations.data.account_key'}}
@placeholder='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='
@value={{@token}}
@onChange={{this.changeSecretKey}}
@helpLinkHref='https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html'
@helpLinkTitle={{t 'components.project_settings.integrations.key_pair_how'}}
/>

<ProjectSettings::Integrations::Form::DataControlText
@error={{field-error @errors 'data.token'}}
@label={{t 'components.project_settings.integrations.data.url'}}
@placeholder='https://mystorageaccount.blob.core.windows.net/mycontainer/myblob'
@value={{@token}}
@onChange={{this.changeUrl}}
@helpLinkHref='https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob-from-url?tabs=microsoft-entra-id'
@helpLinkTitle={{t 'components.project_settings.integrations.webhook_url_how'}}
/>

<ProjectSettings::Integrations::Form::DataControlRadio
@label={{t 'components.project_settings.integrations.target_version.label'}}
@value={{this.targetVersion}}
@onChange={{this.changeTargetVersion}}
@onChangeTargetVersion={{this.changeTargetVersion}}
@onChangeSpecificVersion={{this.changeSpecificVersion}}
/>

{{#if this.webhookUrl}}
<div local-class='instructions'>
<label local-class='data-title'>
{{t 'components.project_settings.integrations.github_webhook_url'}}
<a local-class='data-title-help' target='_blank' rel='noopener noreferrer' href='https://developer.github.com/webhooks/creating'>
{{t 'components.project_settings.integrations.github_webhook_url_how'}}
</a>
</label>

<input readonly='' onClick='this.select();' local-class='textInput' value={{this.webhookUrl}} />

<div local-class='instructions-text'>
<p>
{{t 'components.project_settings.integrations.github_webhook_accent_cli_1' htmlSafe=true}}
</p>

<p>
{{t 'components.project_settings.integrations.github_webhook_accent_cli_2' htmlSafe=true}}
</p>
</div>
</div>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import IntlService from 'ember-intl/services/intl';
import {tracked} from '@glimmer/tracking';

const LOGOS = {
AZURE: 'assets/services/azure.svg',
DISCORD: 'assets/services/discord.svg',
GITHUB: 'assets/services/github.svg',
SLACK: 'assets/services/slack.svg',
Expand Down Expand Up @@ -62,10 +63,17 @@ export default class IntegrationsForm extends Component<Args> {
@tracked
token: string;

@tracked
accountName: string;

@tracked
targetVersion: string;

@tracked
defaultRef = 'main';

services = ['SLACK', 'GITHUB', 'DISCORD'];
// services = ['SLACK', 'GITHUB', 'DISCORD', 'AZURE'];
services = ['AZURE', 'SLACK', 'GITHUB', 'DISCORD'];

@not('url')
emptyUrl: boolean;
Expand Down Expand Up @@ -131,6 +139,7 @@ export default class IntegrationsForm extends Component<Args> {

@action
setUrl(url: string) {
console.log(url)

Check failure on line 142 in webapp/app/pods/components/project-settings/integrations/form/component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
this.url = url;
}

Expand All @@ -154,6 +163,17 @@ export default class IntegrationsForm extends Component<Args> {
this.defaultRef = defaultRef;
}

@action
setAccountName(accountName: string) {
console.log(accountName)

Check failure on line 168 in webapp/app/pods/components/project-settings/integrations/form/component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
this.accountName = accountName;
}

@action
setTargetVersion(targetVersion: string) {
this.targetVersion = targetVersion;
}

@action
async submit() {
this.isSubmiting = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {inject as service} from '@ember/service';
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
import IntlService from 'ember-intl/services/intl';

interface Args {
title: string;
events: string[];
onChangeTargetVersion: (targetVersion: string) => void;
onChangeSpecificVersion: (specificVersion: string) => void;
}

export default class DataControlRadio extends Component<Args> {
@service('intl')
intl: IntlService;

allTargetVersions = [
{
value: 'LATEST',
label: 'components.project_settings.integrations.target_version.options.latest',
},
{
value: 'SPECIFIC',
label:
'components.project_settings.integrations.target_version.options.specific',
},
{
value: 'ALL',
label:
'components.project_settings.integrations.target_version.options.all',
},
];

@tracked
targetVersion: string = this.allTargetVersions[0].value;
specificVersion: string | null = null;

// @action
// changeTargetVersion(targetVersion: string) {
// this.targetVersion = targetVersion;
// this.args.onChangeTargetVersion(targetVersion);
// }

@action
changeTargetVersion(targetVersion: string) {
this.targetVersion = targetVersion;
if (typeof this.args.onChangeTargetVersion === 'function') {
this.args.onChangeTargetVersion(targetVersion);
}
}

@action
changeSpecificVersion(event: Event) {
const target = event.target as HTMLInputElement;
console.log("Changing specific version")

Check failure on line 56 in webapp/app/pods/components/project-settings/integrations/form/data-control-radio/component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
this.args.onChangeSpecificVersion(target.value);
console.log(this.specificVersion);

Check failure on line 58 in webapp/app/pods/components/project-settings/integrations/form/data-control-radio/component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
}
}
Loading

0 comments on commit 00ea643

Please sign in to comment.