Skip to content

Commit

Permalink
Fix aws us-east-1 subdomain and fix slow projects list
Browse files Browse the repository at this point in the history
  • Loading branch information
simonprev committed Apr 4, 2024
1 parent bd4f855 commit 210c7d2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 101 deletions.
9 changes: 8 additions & 1 deletion lib/accent/integrations/execute/aws_s3.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ defmodule Accent.IntegrationManager.Execute.AWSS3 do

def upload_translations(integration, user, params) do
{uploads, version_tag} = Accent.IntegrationManager.Execute.UploadDocuments.all(integration, params)
base_url = "https://s3-#{integration.data.aws_s3_region}.amazonaws.com/#{integration.data.aws_s3_bucket}"

# To support bucket with '.' in the name, we need to use the region subdomain.
# The us-east-1 subdomain is not s3-us-east-1. It’s s3 only.
base_url =
case integration.data.aws_s3_region do
"us-east-1" -> "https://s3.amazonaws.com/#{integration.data.aws_s3_bucket}"
region -> "https://s3-#{region}.amazonaws.com/#{integration.data.aws_s3_bucket}"
end

url =
Path.join([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import ApolloMutate from 'accent-webapp/services/apollo-mutate';
import executeIntegration from 'accent-webapp/queries/execute-integration';

const FLASH_MESSAGE_CREATE_SUCCESS =
'pods.versions.new.flash_messages.create_success';
'pods.project.edit.flash_messages.integration_execute_success';
const FLASH_MESSAGE_CREATE_ERROR =
'pods.versions.new.flash_messages.create_error';
'pods.project.edit.flash_messages.integration_execute_error';

interface Args {
close: () => void;
Expand Down
43 changes: 2 additions & 41 deletions webapp/app/components/projects-list/item/component.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@
import Component from '@glimmer/component';
import {lt, gte} from '@ember/object/computed';
import percentage from 'accent-webapp/component-helpers/percentage';

const LOW_PERCENTAGE = 50;
const HIGH_PERCENTAGE = 90;

interface Args {
project: any;
}

export default class ProjectsListItem extends Component<Args> {
@lt('correctedKeysPercentage', LOW_PERCENTAGE)
lowPercentage: boolean; // Lower than low percentage

@gte('correctedKeysPercentage', LOW_PERCENTAGE)
mediumPercentage: boolean; // higher or equal than low percentage

@gte('correctedKeysPercentage', HIGH_PERCENTAGE)
highPercentage: boolean; // higher or equal than high percentage

get colors() {
return `
.projectId-${this.args.project.id} {
--color-primary: ${this.args.project.mainColor};
}
`;
}

get totalStrings() {
return this.args.project.translationsCount;
}

get totalConflicts() {
return this.args.project.conflictsCount;
}

get totalReviewed() {
return (
this.args.project.translationsCount - this.args.project.conflictsCount
);
}

get correctedKeysPercentage() {
return percentage(
this.totalStrings - this.totalConflicts,
this.totalStrings
);
get colorPrimary() {
return `--color-primary: ${this.args.project.mainColor}`;
}
}
2 changes: 2 additions & 0 deletions webapp/app/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,8 @@
"collaborator_update_success": "The collaborator has been updated with success",
"integration_add_error": "The integration could not be added",
"integration_add_success": "The integration has been added with success",
"integration_execute_error": "The integration could not be executed",
"integration_execute_success": "The integration has been executed with success",
"integration_update_error": "The integration could not be updated",
"integration_update_success": "The integration has been updated with success",
"integration_remove_error": "The integration could not be removed",
Expand Down
2 changes: 0 additions & 2 deletions webapp/app/queries/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export default gql`
lastSyncedAt
mainColor
logo
translationsCount
conflictsCount
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/app/queries/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default gql`
id
translations(
query: $query
pageSize: 50
pageSize: 20
page: $page
document: $document
version: $version
Expand Down
4 changes: 2 additions & 2 deletions webapp/app/styles/components/projects-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
}

.item {
flex: 1 1 calc(50% - 10px);
max-width: 50%;
flex: 1 1 calc(33.3% - 10px);
max-width: 33.3%;
}

.item-link {
Expand Down
48 changes: 9 additions & 39 deletions webapp/app/styles/components/projects-list/item.scss
Original file line number Diff line number Diff line change
@@ -1,44 +1,22 @@
.projects-list-item.low-percentage {
.language-reviewedPercentage {
color: var(--color-error);
}

.progress {
color: var(--color-error);
}
}

.projects-list-item.medium-percentage {
.language-reviewedPercentage {
color: var(--color-warning);
}

.progress {
color: var(--color-warning);
}
}

.projects-list-item.high-percentage {
.language-reviewedPercentage {
color: var(--color-success);
}

.progress {
color: var(--color-success);
}
}

.projects-list-item {
padding: 12px 15px;
transition: 0.2s ease-in-out;
transition-property: box-shadow;
transition-property: box-shadow, border-color;
border-radius: var(--border-radius);
border: 1px solid var(--content-background-border);
background: var(--content-background);
color: var(--color-black);

&:focus,
&:hover {
box-shadow: 0 4px 15px var(--shadow-color);
border-color: color-mix(in srgb, var(--color-primary) 20%, transparent);
border-bottom-color: color-mix(
in srgb,
var(--color-primary) 25%,
transparent
);

.projectName {
color: var(--color-primary);
}
Expand Down Expand Up @@ -87,12 +65,4 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
}

.numberStat-totals {
padding: 2px 0 1px 7px;
color: var(--color-black);
font-size: 12px;
font-family: var(--font-monospace);
}
14 changes: 1 addition & 13 deletions webapp/app/templates/components/projects-list/item.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div local-class='projects-list-item {{if this.lowPercentage "low-percentage"}} {{if this.mediumPercentage "medium-percentage"}} {{if this.highPercentage "high-percentage"}}'>
<div local-class='projects-list-item' style='{{this.colorPrimary}}'>
<div local-class='projectHeader' class='projectId-{{@project.id}}'>
{{#if @project.logo}}
<span local-class='projectLogo'>
Expand All @@ -9,9 +9,6 @@
<span local-class='projectName' data-test-project-name>
{{@project.name}}
</span>
<style>
{{{this.colors}}}
</style>
</div>

<div local-class='numberStat'>
Expand All @@ -27,14 +24,5 @@
{{t 'components.projects_list.never_synced'}}
{{/if}}
</span>

<span local-class='numberStat-totals'>
{{this.totalStrings}}
{{t 'components.dashboard_revisions.strings'}}
</span>
</div>

<div local-class='progress'>
<ReviewProgressBar @correctedKeysPercentage={{this.correctedKeysPercentage}} />
</div>
</div>

0 comments on commit 210c7d2

Please sign in to comment.