Skip to content

Commit

Permalink
Switch to a more class-like global domain/org name for generation con…
Browse files Browse the repository at this point in the history
…venience
  • Loading branch information
azimux committed Dec 23, 2023
1 parent 51356cd commit f2a4eda
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/remote_generator/services/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ def ts_instance_path
def domain_path
path = []

if organization_name != "global_organization"
if organization_name != "GlobalOrganization"
path << organization_name
end

if domain_name != "global_domain"
if domain_name != "GlobalDomain"
path << domain_name
end

Expand Down
20 changes: 20 additions & 0 deletions src/remote_generator/services/domain_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ def entity_generators
def dependencies
[*command_generators, *entity_generators, *organization]
end

def domain_name
s = super

if s == "global_domain"
s = "GlobalDomain"
end

s
end

def organization_name
s = super

if s == "global_organization"
s = "GlobalOrganization"
end

s
end
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions src/remote_generator/services/organization_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def domain_generators
def dependencies
domain_generators
end

def organization_name
s = super

if s == "global_organization"
s = "GlobalOrganization"
end

s
end
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion src/remote_generator/templates/base/Domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class Domain {
this.organizationName = organizationName
this.domainName = domainName
this.isGlobal = isGlobal

this.organization.addDomain(this)
}

get urlBase(): string {
Expand All @@ -25,4 +27,4 @@ export class Domain {
}
}

export const globalDomain = new Domain("global_organization", "global_domain", true)
export const globalDomain = new Domain("GlobalOrganization", "GlobalDomain", true)
12 changes: 9 additions & 3 deletions src/remote_generator/templates/base/Organization.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Domain} from "./Domain";

export abstract class Organization {
export class Organization {
static all: {[organizationName: string]: Organization} = {}
static forName(organizationName: string): Organization {
return this.all[organizationName]
Expand All @@ -17,7 +17,13 @@ export abstract class Organization {
Organization.all[organizationName] = this
}

abstract domainForName(domainName: string): Domain
domainForName(domainName: string): Domain {
return this.domainsByName[domainName]
}

addDomain(domain: Domain) {
this.domainsByName[domain.domainName] = domain
}

get urlBase(): string {
let base = this._urlBase
Expand All @@ -36,7 +42,7 @@ export abstract class Organization {

}

export const globalOrganization = new Organization("global_organization", true)
export const globalOrganization = new Organization("GlobalOrganization", true)

const globalUrlBase = process.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE

Expand Down

0 comments on commit f2a4eda

Please sign in to comment.