fix integrations service, fix babel config to >.25 + not ie

This commit is contained in:
nick-delirium 2024-09-17 11:41:46 +02:00
parent 6c56567580
commit b9590f702e
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
6 changed files with 43 additions and 33 deletions

1
frontend/.browserslistrc Normal file
View file

@ -0,0 +1 @@
> 0.25% and not dead

View file

@ -52,30 +52,30 @@ class NamedIntegrationStore<T extends Integration> {
makeAutoObservable(this);
}
setInstance(instance: T) {
setInstance(instance: T): void {
this.instance = instance;
}
setList(list: T[]) {
setList(list: T[]): void {
this.list = list;
}
setFetched(fetched: boolean) {
setFetched(fetched: boolean): void {
this.fetched = fetched;
}
setIssuesFetched(issuesFetched: boolean) {
setIssuesFetched(issuesFetched: boolean): void {
this.issuesFetched = issuesFetched;
}
fetchIntegrations = async () => {
fetchIntegrations = async (): Promise<void> => {
const { data } = await integrationsService.fetchList(this.name);
this.setList(
data.map((config: Record<string, any>) => new this.NamedType(config))
);
};
fetchIntegration = async (siteId: string) => {
fetchIntegration = async (siteId: string): void => {
const { data } = await integrationsService.fetchIntegration(
this.name,
siteId
@ -83,7 +83,7 @@ class NamedIntegrationStore<T extends Integration> {
this.setInstance(new this.NamedType(data));
};
saveIntegration(name: string, siteId: string) {
saveIntegration(name: string, siteId: string): void {
if (!this.instance) return;
const response = integrationsService.saveIntegration(
name,
@ -93,16 +93,16 @@ class NamedIntegrationStore<T extends Integration> {
return;
}
edit(data: T) {
edit(data: T): void {
this.setInstance(data);
}
deleteIntegration(siteId: string) {
if (!this.instance) return;
integrationsService.removeIntegration(this.name, siteId);
return integrationsService.removeIntegration(this.name, siteId);
}
init(config: Record<string, any>) {
init(config: Record<string, any>): void {
this.instance = new this.NamedType(config);
}
}

View file

@ -1,7 +1,7 @@
import BaseService from "./BaseService";
export default class IntegrationsService extends BaseService {
fetchList = async (name) => {
fetchList = async (name: string) => {
const r = await this.client.get(`/integrations/${name}`)
const data = await r.json()
@ -30,4 +30,5 @@ export default class IntegrationsService extends BaseService {
const res = await r.json()
return res
}
}

View file

@ -1,20 +1,27 @@
module.exports = {
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'babel-plugin-react-require',
['@babel/plugin-proposal-decorators', { legacy: true }],
[
'prismjs',
{
languages: [
'javascript',
'css',
'bash',
'typescript',
'jsx',
'kotlin',
'swift',
],
theme: 'default',
css: true,
},
],
"plugins": [
"babel-plugin-react-require",
["@babel/plugin-transform-private-property-in-object", { "loose":true } ],
[ "@babel/plugin-transform-runtime", { "regenerator": true } ],
[ "@babel/plugin-proposal-decorators", { "legacy":true } ],
[ "@babel/plugin-transform-class-properties", { "loose":true } ],
[ "@babel/plugin-transform-private-methods", { "loose": true }],
["prismjs", {
"languages": ["javascript", "css", "bash", "typescript", "jsx", "kotlin", "swift"],
"theme": "default",
"css": true
}]
]
}
],
};

View file

@ -9,7 +9,8 @@
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "es6",
"target": "ES2017",
"lib": ["dom", "es2023"],
"allowJs": true,
"isolatedModules": true,
"moduleResolution": "node",

View file

@ -15,9 +15,9 @@ import pathAlias from './path-alias';
interface Configuration extends WebpackConfiguration {
devServer?: WebpackDevServerConfiguration
}
console.log('running in', isDevelopment ? 'development' : 'production');
const config: Configuration = {
// mode: isDevelopment ? "development" : "production",
mode: isDevelopment ? "development" : "production",
output: {
publicPath: "/",
filename: 'app-[contenthash:7].js',
@ -34,7 +34,7 @@ const config: Configuration = {
rules: [
{
test: /\.(ts|js)x?$/i,
exclude: /node_modules/,
exclude: isDevelopment ? /node_modules/ : undefined,
use: ['thread-loader', {
loader: "babel-loader",
options: {