Skip to content

Commit

Permalink
CB-5918 Add new plugin (#3081)
Browse files Browse the repository at this point in the history
* CB-5918 add holidays plugin

* CB-5918 add plugin-holidays as a reference to product default

* CB-5918 fix holidays plugin, add icons

* CB-5918 fix: don't run many renders simultaneously

* CB-5918 fix: flakes respawn

previously flakes kept x position that looked weird especially when user resize the window making it bigger

* CB-5918 refactor: adjust flakes size and speed

make flakes bigger and a little bit slower, reduce amount of flakes

* CB-5918 refactor: make flakes look like flakes

add shape prop to create different shapes of snowflakes

add drawSnowflake to render snowflakes

* CB-5918 Extract Logo registration to separate plugin

In order to customize Logo for different occasions without creating circular dependencies with other plugins

* CB-5918 refactor: update exports in holiday plugin

* CB-5918 feat: make logo src a prop

use holidays service to set custom logo

* CB-5918 refactor: update logos

* CB-5918 refactor: snowflakes removing faster if more flakes

* CB-5918 refactor: reduce action icon rotation on click

* CB-5918 fix: deps

* CB-5918 fix: ts-config reference

* CB-5918 refactor: use debounce for resizing

* CB-5918 refactor: add throttle to handleMouseMove

* CB-5918 refactor: update logo

* CB-5918 fix: start date

* CB-5918 feat: add rotation to snowflakes

* CB-5918 fix: dep version

* CB-5918: refactor: split up app logo plugin to public and admin parts

* CB-5918 refactor: split holidays plugin up to two parts: admin and public

* CB-5918 refactor: avoid using anonymous functions in Christmas class

* CB-5918 refactor: HolidayActionButton

* CB-5918 refactor: IHoliday interface naming

* CB-5918 fix: update TS refs

* CB-5918 fix: legacy color notation and lost this

* CB-5918 refactor: remove redundant plugin bootstrap export

* CB-5918 refactor: rename private property

* CB-5918 refactor: use IconButton core block inside HolidayActionButton

* CB-5918 refactor: add check in addHoliday method

* CB-5918 refactor: simplify logoSrc condition

* CB-5918 refactor: remove redundant styles

* CB-5918 refactor: use descriptive names for plugins bootstrap

* CB-5918 refactor:  specify dep version

* CB-5918 refactor: improve Christmas class readability

* CB-5918 refactor: use lazy import for logo

* CB-5918 refactor: export lazy components properly

* CB-5918 fix: holiday end date

---------

Co-authored-by: Daria Marutkina <[email protected]>
Co-authored-by: Evgenia <[email protected]>
Co-authored-by: mr-anton-t <[email protected]>
  • Loading branch information
4 people authored Nov 25, 2024
1 parent 285a216 commit b2a0a88
Show file tree
Hide file tree
Showing 43 changed files with 1,093 additions and 20 deletions.
5 changes: 3 additions & 2 deletions webapp/packages/core-blocks/src/layout/AppLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import styles from './AppLogo.module.css';
interface Props {
title: string;
onClick?: () => void;
iconSrc?: string;
}

export const AppLogo: React.FC<Props> = function AppLogo({ title, onClick }) {
export const AppLogo: React.FC<Props> = function AppLogo({ title, onClick, iconSrc = '/icons/logo_sm.svg' }) {
const style = useS(styles);
return (
<div tabIndex={0} className={s(style, { container: true, active: onClick !== undefined })} onClick={onClick}>
<IconOrImage title={title} className={s(style, { logo: true })} icon="/icons/logo_sm.svg" />
<IconOrImage title={title} className={s(style, { logo: true })} icon={iconSrc} />
</div>
);
};
17 changes: 17 additions & 0 deletions webapp/packages/plugin-app-logo-administration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# dependencies
/node_modules

# testing
/coverage

# production
/lib

# misc
.DS_Store
.env*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
30 changes: 30 additions & 0 deletions webapp/packages/plugin-app-logo-administration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@cloudbeaver/plugin-app-logo-administration",
"type": "module",
"sideEffects": [
"src/**/*.css",
"src/**/*.scss",
"public/**/*"
],
"version": "0.1.0",
"description": "",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
"build": "tsc -b",
"clean": "rimraf --glob dist",
"lint": "eslint ./src/ --ext .ts,.tsx",
"validate-dependencies": "core-cli-validate-dependencies",
"update-ts-references": "yarn run clean && typescript-resolve-references"
},
"dependencies": {
"@cloudbeaver/core-blocks": "^0",
"@cloudbeaver/core-di": "^0",
"@cloudbeaver/plugin-administration": "^0",
"@cloudbeaver/plugin-app-logo": "^0"
},
"peerDependencies": {},
"devDependencies": {
"typescript": "^5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
*/
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
import { AdministrationTopAppBarService, WizardTopAppBarService } from '@cloudbeaver/plugin-administration';
import { Logo } from '@cloudbeaver/plugin-top-app-bar';
import { LogoLazy } from '@cloudbeaver/plugin-app-logo';

@injectable()
export class AdministrationTopAppBarBootstrap extends Bootstrap {
export class AppLogoAdministrationPluginBootstrap extends Bootstrap {
constructor(
private readonly administrationTopAppBarService: AdministrationTopAppBarService,
private readonly wizardTopAppBarService: WizardTopAppBarService,
) {
super();
}

override register(): void | Promise<void> {
this.administrationTopAppBarService.placeholder.add(Logo, 0);
this.wizardTopAppBarService.placeholder.add(Logo, 0);
override register() {
this.administrationTopAppBarService.placeholder.add(LogoLazy, 0);
this.wizardTopAppBarService.placeholder.add(LogoLazy, 0);
}
}
11 changes: 11 additions & 0 deletions webapp/packages/plugin-app-logo-administration/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { appLogoAdministrationPlugin } from './manifest.js';

export { appLogoAdministrationPlugin };
export default appLogoAdministrationPlugin;
15 changes: 15 additions & 0 deletions webapp/packages/plugin-app-logo-administration/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { PluginManifest } from '@cloudbeaver/core-di';

export const appLogoAdministrationPlugin: PluginManifest = {
info: {
name: 'App Logo Administration plugin',
},
providers: [() => import('./PluginBootstrap.js').then(m => m.AppLogoAdministrationPluginBootstrap)],
};
24 changes: 24 additions & 0 deletions webapp/packages/plugin-app-logo-administration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
},
"references": [
{
"path": "../core-blocks/tsconfig.json"
},
{
"path": "../core-di/tsconfig.json"
},
{
"path": "../plugin-administration/tsconfig.json"
},
{
"path": "../plugin-app-logo/tsconfig.json"
}
],
"include": ["__custom_mocks__/**/*", "src/**/*", "src/**/*.json", "src/**/*.css", "src/**/*.scss"],
"exclude": ["**/node_modules", "lib/**/*", "dist/**/*"]
}
17 changes: 17 additions & 0 deletions webapp/packages/plugin-app-logo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# dependencies
/node_modules

# testing
/coverage

# production
/lib

# misc
.DS_Store
.env*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
39 changes: 39 additions & 0 deletions webapp/packages/plugin-app-logo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@cloudbeaver/plugin-app-logo",
"type": "module",
"sideEffects": [
"src/**/*.css",
"src/**/*.scss",
"public/**/*"
],
"version": "0.1.0",
"description": "",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
"build": "tsc -b",
"clean": "rimraf --glob dist",
"lint": "eslint ./src/ --ext .ts,.tsx",
"validate-dependencies": "core-cli-validate-dependencies",
"update-ts-references": "yarn run clean && typescript-resolve-references"
},
"dependencies": {
"@cloudbeaver/core-blocks": "^0",
"@cloudbeaver/core-di": "^0",
"@cloudbeaver/core-root": "^0",
"@cloudbeaver/core-routing": "^0",
"@cloudbeaver/core-version": "^0",
"@cloudbeaver/core-view": "^0",
"@cloudbeaver/plugin-holidays": "^0",
"@cloudbeaver/plugin-top-app-bar": "^0",
"mobx": "^6",
"mobx-react-lite": "^4",
"react": "^18"
},
"peerDependencies": {},
"devDependencies": {
"@types/react": "^18",
"typescript": "^5",
"typescript-plugin-css-modules": "^5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import { useService } from '@cloudbeaver/core-di';
import { PermissionsService, ProductInfoResource } from '@cloudbeaver/core-root';
import { ScreenService } from '@cloudbeaver/core-routing';
import { useAppVersion } from '@cloudbeaver/core-version';
import { HolidaysService } from '@cloudbeaver/plugin-holidays';

export const Logo = observer(function Logo() {
const productInfoResource = useResource(Logo, ProductInfoResource, undefined);
const screenService = useService(ScreenService);
const permissionsService = useService(PermissionsService);
const { backendVersion, frontendVersion } = useAppVersion(true);
const { holiday } = useService(HolidaysService);

const isSameVersion = backendVersion === frontendVersion;

Expand All @@ -27,5 +29,5 @@ export const Logo = observer(function Logo() {

const title = isSameVersion ? backendVersionTitle : commonVersionTitle;

return <AppLogo title={title} onClick={permissionsService.publicDisabled ? undefined : screenService.navigateToRoot} />;
return <AppLogo title={title} iconSrc={holiday?.logoSrc} onClick={permissionsService.publicDisabled ? undefined : screenService.navigateToRoot} />;
});
10 changes: 10 additions & 0 deletions webapp/packages/plugin-app-logo/src/LogoLazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { importLazyComponent } from '@cloudbeaver/core-blocks';

export const LogoLazy = importLazyComponent(() => import('./Logo.js').then(m => m.Logo));
21 changes: 21 additions & 0 deletions webapp/packages/plugin-app-logo/src/PluginBootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
import { TopNavService } from '@cloudbeaver/plugin-top-app-bar';
import { LogoLazy } from './LogoLazy.js';

@injectable()
export class AppLogoPluginBootstrap extends Bootstrap {
constructor(private readonly topNavService: TopNavService) {
super();
}

override register() {
this.topNavService.placeholder.add(LogoLazy, 0);
}
}
13 changes: 13 additions & 0 deletions webapp/packages/plugin-app-logo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { appLogoPlugin } from './manifest.js';

export * from './LogoLazy.js';

export { appLogoPlugin };
export default appLogoPlugin;
15 changes: 15 additions & 0 deletions webapp/packages/plugin-app-logo/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { PluginManifest } from '@cloudbeaver/core-di';

export const appLogoPlugin: PluginManifest = {
info: {
name: 'App Logo plugin',
},
providers: [() => import('./PluginBootstrap.js').then(m => m.AppLogoPluginBootstrap)],
};
46 changes: 46 additions & 0 deletions webapp/packages/plugin-app-logo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
},
"references": [
{
"path": "../core-blocks/tsconfig.json"
},
{
"path": "../core-di/tsconfig.json"
},
{
"path": "../core-root/tsconfig.json"
},
{
"path": "../core-routing/tsconfig.json"
},
{
"path": "../core-version/tsconfig.json"
},
{
"path": "../core-view/tsconfig.json"
},
{
"path": "../plugin-holidays/tsconfig.json"
},
{
"path": "../plugin-top-app-bar/tsconfig.json"
}
],
"include": [
"__custom_mocks__/**/*",
"src/**/*",
"src/**/*.json",
"src/**/*.css",
"src/**/*.scss"
],
"exclude": [
"**/node_modules",
"lib/**/*",
"dist/**/*"
]
}
17 changes: 17 additions & 0 deletions webapp/packages/plugin-holidays-administration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# dependencies
/node_modules

# testing
/coverage

# production
/lib

# misc
.DS_Store
.env*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
30 changes: 30 additions & 0 deletions webapp/packages/plugin-holidays-administration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@cloudbeaver/plugin-holidays-administration",
"type": "module",
"sideEffects": [
"src/**/*.css",
"src/**/*.scss",
"public/**/*"
],
"version": "0.1.0",
"description": "",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
"build": "tsc -b",
"clean": "rimraf --glob dist",
"lint": "eslint ./src/ --ext .ts,.tsx",
"validate-dependencies": "core-cli-validate-dependencies",
"update-ts-references": "yarn run clean && typescript-resolve-references"
},
"dependencies": {
"@cloudbeaver/core-blocks": "^0",
"@cloudbeaver/core-di": "^0",
"@cloudbeaver/plugin-administration": "^0",
"@cloudbeaver/plugin-holidays": "^0"
},
"peerDependencies": {},
"devDependencies": {
"typescript": "^5"
}
}
Loading

0 comments on commit b2a0a88

Please sign in to comment.