mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
typescript: Migrate connected-org-section.js to typescript.
This commit is contained in:
@@ -1,18 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const BaseSection = require(__dirname + '/base-section.js');
|
||||
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
|
||||
const ServerInfoForm = require(__dirname + '/server-info-form.js');
|
||||
const AddCertificate = require(__dirname + '/add-certificate.js');
|
||||
const FindAccounts = require(__dirname + '/find-accounts.js');
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
import BaseSection = require('./base-section');
|
||||
import DomainUtil = require('../../utils/domain-util');
|
||||
import ServerInfoForm = require('./server-info-form');
|
||||
import AddCertificate = require('./add-certificate');
|
||||
import FindAccounts = require('./find-accounts');
|
||||
|
||||
class ConnectedOrgSection extends BaseSection {
|
||||
constructor(props) {
|
||||
// TODO: TypeScript - Here props should be object type
|
||||
props: any;
|
||||
$serverInfoContainer: Element | null;
|
||||
$existingServers: Element | null;
|
||||
$newOrgButton: HTMLButtonElement | null;
|
||||
$addCertificateContainer: Element | null;
|
||||
$findAccountsContainer: Element | null;
|
||||
constructor(props: any) {
|
||||
super();
|
||||
this.props = props;
|
||||
}
|
||||
|
||||
template() {
|
||||
template(): string {
|
||||
return `
|
||||
<div class="settings-pane" id="server-settings-pane">
|
||||
<div class="page-title">Connected organizations</div>
|
||||
@@ -27,21 +36,21 @@ class ConnectedOrgSection extends BaseSection {
|
||||
`;
|
||||
}
|
||||
|
||||
init() {
|
||||
init(): void {
|
||||
this.initServers();
|
||||
}
|
||||
|
||||
initServers() {
|
||||
initServers(): void {
|
||||
this.props.$root.innerHTML = '';
|
||||
|
||||
const servers = DomainUtil.getDomains();
|
||||
this.props.$root.innerHTML = this.template();
|
||||
|
||||
this.$serverInfoContainer = document.getElementById('server-info-container');
|
||||
this.$existingServers = document.getElementById('existing-servers');
|
||||
this.$newOrgButton = document.getElementById('new-org-button');
|
||||
this.$addCertificateContainer = document.getElementById('add-certificate-container');
|
||||
this.$findAccountsContainer = document.getElementById('find-accounts-container');
|
||||
this.$serverInfoContainer = document.querySelector('#server-info-container');
|
||||
this.$existingServers = document.querySelector('#existing-servers');
|
||||
this.$newOrgButton = document.querySelector('#new-org-button');
|
||||
this.$addCertificateContainer = document.querySelector('#add-certificate-container');
|
||||
this.$findAccountsContainer = document.querySelector('#find-accounts-container');
|
||||
|
||||
const noServerText = 'All the connected orgnizations will appear here';
|
||||
// Show noServerText if no servers are there otherwise hide it
|
||||
@@ -57,8 +66,6 @@ class ConnectedOrgSection extends BaseSection {
|
||||
}
|
||||
|
||||
this.$newOrgButton.addEventListener('click', () => {
|
||||
// We don't need to import this since it's already imported in other files
|
||||
// eslint-disable-next-line no-undef
|
||||
ipcRenderer.send('forward-message', 'open-org-tab');
|
||||
});
|
||||
|
||||
@@ -66,17 +73,17 @@ class ConnectedOrgSection extends BaseSection {
|
||||
this.initFindAccounts();
|
||||
}
|
||||
|
||||
initAddCertificate() {
|
||||
initAddCertificate(): void {
|
||||
new AddCertificate({
|
||||
$root: this.$addCertificateContainer
|
||||
}).init();
|
||||
}
|
||||
|
||||
initFindAccounts() {
|
||||
initFindAccounts(): void {
|
||||
new FindAccounts({
|
||||
$root: this.$findAccountsContainer
|
||||
}).init();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ConnectedOrgSection;
|
||||
export = ConnectedOrgSection;
|
Reference in New Issue
Block a user