refactor: deps approvals (#1206)
Reviewed-on: daoyoucloud/tachybase#1206
This commit is contained in:
		
							parent
							
								
									3712280e89
								
							
						
					
					
						commit
						509bcc29a8
					
				@ -1027,6 +1027,9 @@ export class PluginManager {
 | 
			
		||||
      }
 | 
			
		||||
      this.app.log.debug(`upgrade plugin [${plugin.name}]`);
 | 
			
		||||
      await plugin.upgrade();
 | 
			
		||||
      for (const feature of plugin.featureInstances) {
 | 
			
		||||
        await feature.upgrade();
 | 
			
		||||
      }
 | 
			
		||||
      plugin.state.upgraded = true;
 | 
			
		||||
    }
 | 
			
		||||
    await this.repository.update({
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import type { CollectionRepository } from '@tachybase/plugin-collection-manager';
 | 
			
		||||
import { Plugin } from '@tachybase/server';
 | 
			
		||||
import { InstallOptions, Plugin } from '@tachybase/server';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  aggregateSearch,
 | 
			
		||||
@ -32,14 +31,14 @@ export class DepartmentsPlugin extends Plugin {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  async load() {
 | 
			
		||||
    this.app.resource({
 | 
			
		||||
    this.app.resourcer.define({
 | 
			
		||||
      name: 'users',
 | 
			
		||||
      actions: {
 | 
			
		||||
        listExcludeDept: listExcludeDept,
 | 
			
		||||
        setMainDepartment: setMainDepartmentAction,
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
    this.app.resource({
 | 
			
		||||
    this.app.resourcer.define({
 | 
			
		||||
      name: 'departments',
 | 
			
		||||
      actions: {
 | 
			
		||||
        aggregateSearch: aggregateSearch,
 | 
			
		||||
@ -84,7 +83,12 @@ export class DepartmentsPlugin extends Plugin {
 | 
			
		||||
      this.app.cache.del(`departments:${userId}`);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  async install(options) {
 | 
			
		||||
 | 
			
		||||
  async upgrade() {
 | 
			
		||||
    await this.install();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async install(options?: InstallOptions) {
 | 
			
		||||
    const collectionRepo = this.db.getRepository<CollectionRepository>('collections');
 | 
			
		||||
    if (collectionRepo) {
 | 
			
		||||
      await collectionRepo.db2cm('departments');
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import './actions';
 | 
			
		||||
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import Application, { InstallOptions, NoticeLevel, Plugin, type PluginOptions } from '@tachybase/server';
 | 
			
		||||
import { Plugin } from '@tachybase/server';
 | 
			
		||||
import { Container } from '@tachybase/utils';
 | 
			
		||||
 | 
			
		||||
import { DepartmentsPlugin } from './features/departments';
 | 
			
		||||
@ -13,22 +13,14 @@ import { SqlLoader } from './services/sql-loader';
 | 
			
		||||
import { WebControllerService as WebService } from './services/web-service';
 | 
			
		||||
 | 
			
		||||
export class PluginCoreServer extends Plugin {
 | 
			
		||||
  pluginDepartments: DepartmentsPlugin;
 | 
			
		||||
  constructor(app: Application, options?: PluginOptions) {
 | 
			
		||||
    super(app, options);
 | 
			
		||||
    this.pluginDepartments = new DepartmentsPlugin(app, options);
 | 
			
		||||
  }
 | 
			
		||||
  async afterAdd() {
 | 
			
		||||
    this.db.registerFieldTypes({
 | 
			
		||||
      calc: CalcField,
 | 
			
		||||
      tstzrange: TstzrangeField,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  beforeLoad() {
 | 
			
		||||
    this.pluginDepartments.beforeLoad();
 | 
			
		||||
    this.addFeature(DepartmentsPlugin);
 | 
			
		||||
  }
 | 
			
		||||
  async load() {
 | 
			
		||||
    await this.pluginDepartments.load();
 | 
			
		||||
    try {
 | 
			
		||||
      await Container.get(ConnectionManager).load();
 | 
			
		||||
      const fontManger = Container.get(FontManager);
 | 
			
		||||
@ -43,9 +35,6 @@ export class PluginCoreServer extends Plugin {
 | 
			
		||||
      console.warn(err);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  async install(options?: InstallOptions) {
 | 
			
		||||
    await this.pluginDepartments.install(options);
 | 
			
		||||
  }
 | 
			
		||||
  async afterEnable() {}
 | 
			
		||||
  async afterDisable() {}
 | 
			
		||||
  async remove() {}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user