mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-03 13:33:18 +00:00
Using `import * as` import syntax causes some problem if the module exports a class or function. Because the whole point of star import is to import every property the module exports. It turns out we have been using it incorrectly in many places which this commit fixes. Then we fix a linting error by adding a eslint disable rule to solve it along with a TODO because the way we currently do it is wrong. Finally, to conclude this cleanup, we merge all the .gitignore paths into once now that we can.
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { remote } from 'electron';
|
|
import SendFeedback from '@electron-elements/send-feedback';
|
|
|
|
import path = require('path');
|
|
import fs = require('fs');
|
|
|
|
const { app } = remote;
|
|
|
|
interface SendFeedback extends HTMLElement {
|
|
[key: string]: any;
|
|
}
|
|
|
|
type SendFeedbackType = SendFeedback;
|
|
|
|
// make the button color match zulip app's theme
|
|
SendFeedback.customStyles = `
|
|
button:hover, button:focus {
|
|
border-color: #4EBFAC;
|
|
color: #4EBFAC;
|
|
}
|
|
|
|
button:active {
|
|
background-color: #f1f1f1;
|
|
color: #4EBFAC;
|
|
}
|
|
|
|
button {
|
|
background-color: #4EBFAC;
|
|
border-color: #4EBFAC;
|
|
}
|
|
`;
|
|
|
|
customElements.define('send-feedback', SendFeedback);
|
|
export const sendFeedback: SendFeedbackType = document.querySelector('send-feedback');
|
|
export const feedbackHolder = sendFeedback.parentElement;
|
|
|
|
// customize the fields of custom elements
|
|
sendFeedback.title = 'Report Issue';
|
|
sendFeedback.titleLabel = 'Issue title:';
|
|
sendFeedback.titlePlaceholder = 'Enter issue title';
|
|
sendFeedback.textareaLabel = 'Describe the issue:';
|
|
sendFeedback.textareaPlaceholder = 'Succinctly describe your issue and steps to reproduce it...';
|
|
sendFeedback.buttonLabel = 'Report Issue';
|
|
sendFeedback.loaderSuccessText = '';
|
|
|
|
sendFeedback.useReporter('emailReporter', {
|
|
email: 'akash@zulipchat.com'
|
|
});
|
|
|
|
feedbackHolder.addEventListener('click', (e: Event) => {
|
|
// only remove the class if the grey out faded
|
|
// part is clicked and not the feedback element itself
|
|
if (e.target === e.currentTarget) {
|
|
feedbackHolder.classList.remove('show');
|
|
}
|
|
});
|
|
|
|
sendFeedback.addEventListener('feedback-submitted', () => {
|
|
setTimeout(() => {
|
|
feedbackHolder.classList.remove('show');
|
|
}, 1000);
|
|
});
|
|
|
|
const dataDir = app.getPath('userData');
|
|
const logsDir = path.join(dataDir, '/Logs');
|
|
sendFeedback.logs.push(...fs.readdirSync(logsDir).map(file => path.join(logsDir, file)));
|