-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1245 from appknox/org-namespace-ts
Organization namespace typescript migration
- Loading branch information
Showing
8 changed files
with
180 additions
and
77 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
app/components/organization-namespace/approval-status/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
app/components/organization-namespace/approval-status/index.js
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
app/components/organization-namespace/approval-status/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
import ENV from 'irene/config/environment'; | ||
import triggerAnalytics from 'irene/utils/trigger-analytics'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import dayjs from 'dayjs'; | ||
import relativeTime from 'dayjs/plugin/relativeTime'; | ||
import IntlService from 'ember-intl/services/intl'; | ||
import MeService from 'irene/services/me'; | ||
import OrganizationNamespaceModel from 'irene/models/organization-namespace'; | ||
|
||
export interface OrganizationNamespaceApprovalStatusSignature { | ||
Args: { | ||
namespace: OrganizationNamespaceModel; | ||
onRejectNamespace: (namespace: OrganizationNamespaceModel) => void; | ||
}; | ||
Element: HTMLElement; | ||
} | ||
|
||
export default class OrganizationNamespaceApprovalStatus extends Component<OrganizationNamespaceApprovalStatusSignature> { | ||
@service declare intl: IntlService; | ||
@service declare me: MeService; | ||
@service('notifications') declare notify: NotificationService; | ||
|
||
@tracked isApprovingNamespace = false; | ||
|
||
/* Approve namespace action */ | ||
approveNamespace = task(async () => { | ||
try { | ||
this.isApprovingNamespace = true; | ||
|
||
const ns = this.args.namespace; | ||
ns.set('isApproved', true); | ||
|
||
await ns.save(); | ||
|
||
this.notify.success(this.intl.t('namespaceApproved')); | ||
|
||
triggerAnalytics( | ||
'feature', | ||
ENV.csb['namespaceAdded'] as CsbAnalyticsFeatureData | ||
); | ||
|
||
this.isApprovingNamespace = false; | ||
} catch (e) { | ||
const err = e as AdapterError; | ||
let errMsg = this.intl.t('pleaseTryAgain'); | ||
|
||
if (err.errors && err.errors.length) { | ||
errMsg = err.errors[0]?.detail || errMsg; | ||
} else if (err.message) { | ||
errMsg = err.message; | ||
} | ||
|
||
this.notify.error(errMsg); | ||
this.isApprovingNamespace = false; | ||
} | ||
}); | ||
|
||
get approvedOnDate() { | ||
dayjs.extend(relativeTime); | ||
return dayjs(this.args.namespace.approvedOn).fromNow(); | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'OrganizationNamespace::ApprovalStatus': typeof OrganizationNamespaceApprovalStatus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/components/organization-namespace/namespace-value/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Component from '@glimmer/component'; | ||
import OrganizationNamespaceModel from 'irene/models/organization-namespace'; | ||
|
||
export interface OrganizationNamespaceComponentSignature { | ||
Args: { | ||
namespace: OrganizationNamespaceModel; | ||
}; | ||
Element: HTMLElement; | ||
} | ||
|
||
export default class OrganizationNamespaceValueComponent extends Component<OrganizationNamespaceComponentSignature> {} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'OrganizationNamespace::NamespaceValue': typeof OrganizationNamespaceValueComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/components/organization-namespace/request-status/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Component from '@glimmer/component'; | ||
import OrganizationNamespaceModel from 'irene/models/organization-namespace'; | ||
import dayjs from 'dayjs'; | ||
import relativeTime from 'dayjs/plugin/relativeTime'; | ||
|
||
export interface OrganizationNamespaceRequestStatusSignature { | ||
Args: { | ||
namespace: OrganizationNamespaceModel; | ||
}; | ||
Element: HTMLElement; | ||
} | ||
|
||
export default class OrganizationNamespaceComponent extends Component<OrganizationNamespaceRequestStatusSignature> { | ||
get createdOnDate() { | ||
dayjs.extend(relativeTime); | ||
return dayjs(this.args.namespace.createdOn).fromNow(); | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'OrganizationNamespace::RequestStatus': typeof OrganizationNamespaceComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters