mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-27 03:42:01 +00:00
Use templated strings
This commit is contained in:
parent
5138eedd91
commit
84d323b9b9
6 changed files with 48 additions and 13 deletions
|
|
@ -66,8 +66,8 @@
|
|||
"error-do-account-info": "Failed to get DigitalOcean account information",
|
||||
"error-do-auth": "Authentication with DigitalOcean failed",
|
||||
"error-do-regions": "Failed to get list of available regions",
|
||||
"error-do-limit": "Your DigitalOcean account has reached its Droplet limit. You can request an increase at https://cloud.digitalocean.com/account/team/droplet_limit_increase",
|
||||
"error-do-warning": "DigitalOcean warning:",
|
||||
"error-do-limit": "Your DigitalOcean account has reached its limit of {num} Droplets. You can request an increase at https://cloud.digitalocean.com/account/team/droplet_limit_increase",
|
||||
"error-do-warning": "DigitalOcean warning: \"{message}\" ({detail})",
|
||||
"error-gcp-auth": "Authentication with Google Cloud Platform failed",
|
||||
"error-feedback": "Failed to submit feedback. Please try again.",
|
||||
"error-hostname-invalid": "Must be an IP address or valid hostname.",
|
||||
|
|
|
|||
|
|
@ -320,12 +320,28 @@
|
|||
"description": "This string appears in an error notification toast. It is shown when there is an error retrieving the regions available for server deployment."
|
||||
},
|
||||
"error_do_limit": {
|
||||
"message": "Your DigitalOcean account has reached its Droplet limit. You can request an increase at https://cloud.digitalocean.com/account/team/droplet_limit_increase",
|
||||
"description": "This string appears in an error notification toast. It is shown when the user has created the maximum number of allowed servers."
|
||||
"message": "Your DigitalOcean account has reached its limit of $NUM$ Droplets. You can request an increase at https://cloud.digitalocean.com/account/team/droplet_limit_increase",
|
||||
"description": "This string appears in an error notification toast. It is shown when the user has created the maximum number of allowed servers.",
|
||||
"placeholders": {
|
||||
"NUM": {
|
||||
"content": "{num}",
|
||||
"example": "3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error_do_warning": {
|
||||
"message": "DigitalOcean warning:",
|
||||
"description": "This string appears at the start of an error notification toast. It is followed by an English-language error description in quotes."
|
||||
"message": "DigitalOcean warning: \"$MESSAGE$\" ($DETAIL$)",
|
||||
"description": "This string appears in an error notification toast when login has succeeded but there is a warning message.",
|
||||
"placeholders": {
|
||||
"MESSAGE": {
|
||||
"content": "{message}",
|
||||
"example": "Your team has been locked due to improper use of the platform."
|
||||
},
|
||||
"DETAIL": {
|
||||
"content": "{detail}",
|
||||
"example": "status: \"locked\""
|
||||
}
|
||||
}
|
||||
},
|
||||
"error_gcp_auth": {
|
||||
"message": "Authentication with Google Cloud Platform failed",
|
||||
|
|
|
|||
|
|
@ -43,10 +43,14 @@ export interface Status {
|
|||
readonly needsBillingInfo: boolean;
|
||||
// The account has not had an email address added yet.
|
||||
readonly needsEmailVerification: boolean;
|
||||
// The maximum number of droplets this account can create.
|
||||
readonly dropletLimit: number;
|
||||
// The account cannot add any more droplets.
|
||||
readonly hasReachedLimit: boolean;
|
||||
// A warning message from DigitalOcean.
|
||||
readonly warning?: string;
|
||||
// A string with detailed status info
|
||||
readonly detail?: string;
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ export class App {
|
|||
return [];
|
||||
}
|
||||
if (status.warning) {
|
||||
this.showDigitalOceanWarning(status.warning);
|
||||
this.showDigitalOceanWarning(status);
|
||||
}
|
||||
const servers = await this.digitalOceanAccount.listServers();
|
||||
for (const server of servers) {
|
||||
|
|
@ -373,8 +373,10 @@ export class App {
|
|||
return [];
|
||||
}
|
||||
|
||||
private showDigitalOceanWarning(warning: string) {
|
||||
this.appRoot.showError(`${this.appRoot.localize('error-do-warning')} ${warning}`);
|
||||
private showDigitalOceanWarning(status: digitalocean.Status) {
|
||||
this.appRoot.showError(
|
||||
this.appRoot.localize('error-do-warning', 'message', status.warning, 'detail', status.detail)
|
||||
);
|
||||
}
|
||||
|
||||
private async loadGcpAccount(gcpAccount: gcp.Account): Promise<server.ManagedServer[]> {
|
||||
|
|
@ -524,7 +526,7 @@ export class App {
|
|||
oauthUi.showEmailVerification();
|
||||
} else {
|
||||
if (status.warning) {
|
||||
this.showDigitalOceanWarning(status.warning);
|
||||
this.showDigitalOceanWarning(status);
|
||||
}
|
||||
bringToFront();
|
||||
if (activatingAccount) {
|
||||
|
|
@ -732,7 +734,7 @@ export class App {
|
|||
try {
|
||||
const status = await digitalOceanAccount.getStatus();
|
||||
if (status.hasReachedLimit) {
|
||||
this.appRoot.showError(this.appRoot.localize('error-do-limit'));
|
||||
this.appRoot.showError(this.appRoot.localize('error-do-limit', 'num', status.dropletLimit));
|
||||
return; // Don't proceed to the region picker.
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,15 @@ export class DigitalOceanAccount implements digitalocean.Account {
|
|||
account.status === 'locked' && !needsEmailVerification && droplets.length == 0;
|
||||
const hasReachedLimit = droplets.length >= account.droplet_limit;
|
||||
const warning = account.status !== 'active' ? account.status_message : '';
|
||||
return {needsBillingInfo, needsEmailVerification, warning, hasReachedLimit};
|
||||
const detail = `status: "${account.status}"`;
|
||||
return {
|
||||
needsBillingInfo,
|
||||
needsEmailVerification,
|
||||
dropletLimit: account.droplet_limit,
|
||||
hasReachedLimit,
|
||||
warning,
|
||||
detail,
|
||||
};
|
||||
}
|
||||
|
||||
// Return a list of regions indicating whether they are available and support
|
||||
|
|
|
|||
|
|
@ -29,7 +29,12 @@ export class FakeDigitalOceanAccount implements digitalocean.Account {
|
|||
return 'fake-digitalocean-account-name';
|
||||
}
|
||||
async getStatus(): Promise<digitalocean.Status> {
|
||||
return {needsBillingInfo: false, needsEmailVerification: false, hasReachedLimit: false};
|
||||
return {
|
||||
needsBillingInfo: false,
|
||||
needsEmailVerification: false,
|
||||
dropletLimit: 3,
|
||||
hasReachedLimit: false,
|
||||
};
|
||||
}
|
||||
listServers() {
|
||||
return Promise.resolve(this.servers);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue