Skip to content

Commit

Permalink
Merge branch 'Enalean:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofsilva79 authored Dec 29, 2022
2 parents e6c5253 + ad71964 commit f1c454a
Show file tree
Hide file tree
Showing 891 changed files with 21,244 additions and 8,807 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ rnc2rng-exec: src/common/xml/resources/project/project.rng \
plugins/timetracking/resources/timetracking.rng \
plugins/program_management/resources/program_management.rng

src/common/xml/resources/project/project.rng: src/common/xml/resources/project/project.rnc plugins/tracker/resources/tracker-definition.rnc plugins/docman/resources/docman-definition.rnc src/common/xml/resources/ugroups-definition.rnc plugins/svn/resources/svn-definition.rnc src/common/xml/resources/frs-definition.rnc src/common/xml/resources/mediawiki-definition.rnc src/common/xml/resources/project-definition.rnc
src/common/xml/resources/project/project.rng: src/common/xml/resources/project/project.rnc plugins/tracker/resources/tracker-definition.rnc plugins/mediawiki_standalone/resources/mediawiki-definition.rnc plugins/docman/resources/docman-definition.rnc src/common/xml/resources/ugroups-definition.rnc plugins/svn/resources/svn-definition.rnc src/common/xml/resources/frs-definition.rnc src/common/xml/resources/mediawiki-definition.rnc src/common/xml/resources/project-definition.rnc

plugins/svn/resources/svn.rng: plugins/svn/resources/svn.rnc plugins/svn/resources/svn-definition.rnc

Expand Down Expand Up @@ -240,7 +240,7 @@ psalm-with-info: ## Run Psalm (PHP static analysis tool) with INFO findings. Use

.PHONY:psalm-taint-analysis
psalm-taint-analysis: ## Run Psalm (PHP static analysis tool) taint analysis. Use FILES variables to execute on a given set of files or directories.
$(PHP) ./src/vendor/bin/psalm --no-cache --taint-analysis -c=tests/psalm/psalm.xml $(FILES)
$(PHP) ./src/vendor/bin/psalm --memory-limit=4096M --threads=1 --no-cache --taint-analysis -c=tests/psalm/psalm.xml $(FILES)

.PHONY:psalm-unused-code
psalm-unused-code: ## Run Psalm (PHP static analysis tool) detection of unused code. Use FILES variables to execute on a given set of files or directories.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.2.99.122
14.3.99.96
6 changes: 3 additions & 3 deletions adr/0018-js-bundler.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In a [previous decision][2] (before writing ADRs), we chose to use [webpack][3]

## Decision Outcome

[Vite][4] is the default module bundler for new Applications and Libraries (as defined by [ADR-0017][6]). Some contexts will still require [webpack][3]: for example AngularJS applications, legacy concatenated scripts, etc.
[Vite][4] is the default module bundler for new Applications and Libraries (as defined by [ADR-0016][6]). Some contexts will still require [webpack][3]: for example AngularJS applications, legacy concatenated scripts, etc.

### Positive Consequences

Expand Down Expand Up @@ -52,12 +52,12 @@ In a [previous decision][2] (before writing ADRs), we chose to use [webpack][3]
## Links

* Influences [ADR-0014: JS unit test runner][1]
* [ADR-0017: Multiple independent apps per context][6]
* [ADR-0016: Independent libraries for shared frontend code][6]

[0]: https://tuleap.net/plugins/tracker/?aid=23415
[1]: ./0014-js-unit-test-runner.md
[2]: https://tuleap.net/plugins/tracker/?aid=10195
[3]: https://webpack.js.org/
[4]: https://vitejs.dev/
[5]: https://vitejs.dev/team.html
[6]: ./0017-multiple-apps-per-context.md
[6]: ./0016-frontend-libraries.md
42 changes: 42 additions & 0 deletions adr/0019-split-tlp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Split `tlp` global library in small packages

* Status: accepted
* Deciders: Thomas GERBET, Romain LORENTZ, Clarck ROBINSON, Thomas GORKA, Joris MASSON, Nicolas TERRAY, Manuel VACELET, Yannis ROSSETTO
* Date: 2022-04-01

Technical Story: [request #29982 Split `tlp` in smaller packages][0]

## Context and Problem Statement

In a previous decision around 2015 (before writing ADRs), we chose to break free of our dependencies on many global libraries ([Prototype][1], [Bootstrap v2][2], [jQuery v1][3], etc.). Tuleap then supported multiple "themes" and users could customize them. The main theme was then called "FlamingParrot" (or "FP"). To do that, we started a new theme called "BurningParrot" (or "BP"). We chose to write our own design system and universal global library, called "tlp" (remove all vowels from Tuleap).

Since that time, ECMAScript modules and [module bundlers][4] appeared. They allowed us to stop relying on "global variable"-style libraries. The global `tlp` library is now causing problems. Because it is a global variable, it is harder to search where it is used. Making changes to basic parts (such as the style of modals) leads to giant reviews that no-one wants to take on. It makes it hard to "swap" components.

## Decision Outcome

We will split `tlp` in smaller modules: `@tuleap/tlp-modal` for the modals, `@tuleap/tlp-fetch` for the `fetch` wrapper API, etc. Each module will be a Library (as defined by [ADR-0016][5]).

### Positive Consequences

* It is much easier to deprecate, replace and eventually delete smaller libraries than even a part of a mega-library. For example, since [ADR-0013](./0013-neverthrow.md), we have an alternative to `@tuleap/tlp-fetch`: `@tuleap/fetch-result`. It is possible to replace usage of the former by the latter progressively, on small-scale refactorings.
* Tracking usage is much easier. We can grep on the package name, for example we can search `@tuleap/tlp-fetch`. It is also mandatory to declare package dependencies in `package.json`, letting us track usage again.
* We may stop loading on every page a lot of code that will probably not be used. However, that requires going to the end of the process and finally removing the big `tlp` global variable.

### Negative Consequences

* On pages with many Applications (as defined by [ADR-0016][5]) such as the Trackers Artifact view, modules that are often used such as `@tuleap/tlp-fetch` will be duplicated for each application. However, since our module bundlers apply tree-shaking, the size increase should be limited. The modules themselves are quite small too. If this becomes a bigger problem, we can explore module bundler features such as "module federation".

## Links

* [ADR-0016: Independent libraries for shared frontend code][5]
* [request #18842 Split TLP into separate smaller libraries](https://tuleap.net/plugins/tracker/?aid=18842)
* [request #20906 Split TLP popovers to its own library](https://tuleap.net/plugins/tracker/?aid=20906)
* [request #26374 Stop exposing @tuleap/tlp-fetch module in tlp module](https://tuleap.net/plugins/tracker/?aid=26374)
* [request #26742 Split TLP dropdowns to its own library](https://tuleap.net/plugins/tracker/?aid=26742)

[0]: https://tuleap.net/plugins/tracker/?aid=29982
[1]: http://prototypejs.org/
[2]: https://getbootstrap.com/2.3.2/
[3]: https://jquery.com/
[4]: ./0018-js-bundler.md
[5]: ./0016-frontend-libraries.md
1 change: 1 addition & 0 deletions adr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This log lists the architectural decisions for Tuleap. You will find bellow the
* [ADR-0016](0016-frontend-libraries.md) - Independent libraries for shared frontend code
* [ADR-0017](0017-multiple-apps-per-context.md) - Multiple independent apps per context
* [ADR-0018](0018-js-bundler.md) - Choice of JavaScript Bundler
* [ADR-0019](0019-split-tlp.md) - Split `tlp` global library in small packages

<!-- adrlogstop -->

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
- gitlab.local

onlyoffice:
image: onlyoffice/documentserver:7.2.0.204
image: onlyoffice/documentserver:7.2.1.34
environment:
- JWT_ENABLED=true
- JWT_SECRET=TULEAP_DO_NOT_USE_THIS_IN_PRODUCTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ type OverloadedUserConfig = UserConfigWithoutBuildAndServerAndTest & {
} & { css?: OverloadedCSSOptions };

export function defineLibConfig(config: OverloadedUserConfig): UserConfigExport {
return defineBaseConfig(config);
const overloaded_build = { ...config.build };
overloaded_build.rollupOptions = {
...overloaded_build.rollupOptions,
// Force output of __esModule property, otherwise Jest mocks of libs are broken
output: { esModule: true },
};
return defineBaseConfig({ ...config, build: overloaded_build });
}

type OverloadedBuildAppOptions = Omit<
Expand Down Expand Up @@ -153,6 +159,7 @@ function defineBaseConfig(config: UserConfig): UserConfigExport {
junit: TEST_OUTPUT_DIRECTORY + "/junit.xml",
},
coverage: test_coverage,
threads: !test_coverage.enabled,
},
});
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"author": "Enalean Team",
"name": "@tuleap/user-group-constants",
"name": "@tuleap/core-constants",
"homepage": "https://tuleap.org",
"license": "GPL-2.0-or-later",
"private": true,
"version": "0.0.0",
"type": "module",
"module": "dist/user-group-constants.js",
"main": "dist/user-group-constants.umd.cjs",
"types": "dist/index.d.ts",
"module": "dist/core-constants.js",
"main": "dist/core-constants.umd.cjs",
"types": "dist/main.d.ts",
"exports": {
".": {
"import": "./dist/user-group-constants.js",
"require": "./dist/user-group-constants.umd.cjs"
"import": "./dist/core-constants.js",
"require": "./dist/core-constants.umd.cjs"
}
},
"devDependencies": {
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions lib/frontend/constants/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) Enalean, 2019-Present. All Rights Reserved.
*
* This file is a part of Tuleap.
*
* Tuleap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tuleap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
*/

export const PROJECT_MEMBERS_ID = 3;
export const PROJECT_ADMINISTRATORS_ID = 4;

type DateFormat = "d/m/Y" | "Y-m-d";
type DateWithTimeFormat = "d/m/Y H:i" | "Y-m-d H:i";
export type DateTimeFormat = DateFormat | DateWithTimeFormat;
export const en_US_DATE_TIME_FORMAT = "Y-m-d H:i";
export const en_US_DATE_FORMAT = "Y-m-d";
export const fr_FR_DATE_TIME_FORMAT = "d/m/Y H:i";
export const fr_FR_DATE_FORMAT = "d/m/Y";

export type LocaleString = "fr_FR" | "en_US" | "pt_BR";
export const en_US_LOCALE = "en_US";
export const fr_FR_LOCALE = "fr_FR";
export const pt_BR_LOCALE = "pt_BR";
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import { vite, viteDtsPlugin } from "@tuleap/build-system-configurator";
import * as path from "path";

export default vite.defineLibConfig({
plugins: [viteDtsPlugin()],
build: {
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: "TuleapUserGroupConstants",
entry: path.resolve(__dirname, "src/main.ts"),
name: "TuleapCoreConstants",
},
},
plugins: [viteDtsPlugin()],
});
4 changes: 3 additions & 1 deletion lib/frontend/date-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"homepage": "https://tuleap.org",
"license": "GPL-2.0-or-later",
"private": true,
"version": "0.0.0",
"type": "module",
"module": "dist/date-helper.js",
"main": "dist/date-helper.umd.cjs",
Expand All @@ -15,6 +14,9 @@
"require": "./dist/date-helper.umd.cjs"
}
},
"dependencies": {
"@tuleap/core-constants": "workspace:*"
},
"devDependencies": {
"@tuleap/build-system-configurator": "workspace:*"
},
Expand Down
4 changes: 4 additions & 0 deletions lib/frontend/date-helper/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions lib/frontend/date-helper/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
*/

import {
en_US_DATE_FORMAT,
en_US_DATE_TIME_FORMAT,
fr_FR_DATE_FORMAT,
fr_FR_DATE_TIME_FORMAT,
} from "@tuleap/core-constants";
import { describe, it, expect } from "vitest";
import { formatFromPhpToMoment, formatDateYearMonthDay } from "./index";

describe("formatFromPhpToMoment", () => {
it.each([
["french date", "d/m/Y", "DD/MM/YYYY"],
["english date", "Y-m-d", "YYYY-MM-DD"],
["french time", "d/m/Y H:i", "DD/MM/YYYY HH:mm"],
["english time", "Y-m-d H:i", "YYYY-MM-DD HH:mm"],
["french date", fr_FR_DATE_FORMAT, "DD/MM/YYYY"],
["english date", en_US_DATE_FORMAT, "YYYY-MM-DD"],
["french time", fr_FR_DATE_TIME_FORMAT, "DD/MM/YYYY HH:mm"],
["english time", en_US_DATE_TIME_FORMAT, "YYYY-MM-DD HH:mm"],
])(
`Given %s is provided, then it returns the moment format`,
(format_title, php_date_format, expected_moment_format) => {
expect(formatFromPhpToMoment(php_date_format)).toEqual(expected_moment_format);
expect(formatFromPhpToMoment(php_date_format)).toBe(expected_moment_format);
}
);

Expand Down
15 changes: 11 additions & 4 deletions lib/frontend/date-helper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
*/

import {
en_US_DATE_FORMAT,
en_US_DATE_TIME_FORMAT,
fr_FR_DATE_FORMAT,
fr_FR_DATE_TIME_FORMAT,
} from "@tuleap/core-constants";

export function formatFromPhpToMoment(php_date_format: string): string {
switch (php_date_format) {
case "d/m/Y":
case fr_FR_DATE_FORMAT:
return "DD/MM/YYYY";
case "d/m/Y H:i":
case fr_FR_DATE_TIME_FORMAT:
return "DD/MM/YYYY HH:mm";
case "Y-m-d":
case en_US_DATE_FORMAT:
return "YYYY-MM-DD";
case "Y-m-d H:i":
case en_US_DATE_TIME_FORMAT:
return "YYYY-MM-DD HH:mm";
default:
throw new Error("Only french and english date are supported for display");
Expand Down
12 changes: 7 additions & 5 deletions lib/frontend/link-selector/src/dropdown/DropdownManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { ScrollingManager } from "../events/ScrollingManager";
import type { FieldFocusManager } from "../navigation/FieldFocusManager";

describe("dropdown-manager", () => {
let doc: HTMLDocument,
let doc: Document,
wrapper: HTMLElement,
link_selector: Element,
dropdown: HTMLElement,
Expand All @@ -45,9 +45,11 @@ describe("dropdown-manager", () => {
disconnect,
};
});
});
vi.spyOn(window, "requestAnimationFrame").mockImplementation((callback): number => {
callback(1);
return 1;
});

beforeEach(() => {
doc = document.implementation.createHTMLDocument();
const source_select_box = document.createElement("select");
const {
Expand All @@ -56,7 +58,7 @@ describe("dropdown-manager", () => {
dropdown_element,
dropdown_list_element,
selection_element,
} = new BaseComponentRenderer(doc, source_select_box, "").renderBaseComponent();
} = new BaseComponentRenderer(doc, source_select_box, "", "").renderBaseComponent();

scroll_manager = {
lockScrolling: vi.fn(),
Expand Down Expand Up @@ -162,7 +164,7 @@ describe("dropdown-manager", () => {
clientHeight: document_client_height,
},
body: document.createElement("body"),
} as unknown as HTMLDocument;
} as unknown as Document;

return new DropdownManager(
mocked_doc,
Expand Down
Loading

0 comments on commit f1c454a

Please sign in to comment.