This document explains how to do certain coding activities when contributing to the main project. However, if you're instead trying to use Atoll's REST API you should use this document for guidance: DEV_USING_REST_API.md
Sequelize is the ORM used by Atoll. In order to modify that data structures you should not directly add tables. Here are the "rules" for updating the data model:
- When adding a table, modify the code data models.
- When modifying a table, modify the code data models AND add new script to upgrade.sql to allow existing databases to be easily upgraded.
- When removing fields from a table make sure to provide migration scripts that will take existing data and move it to the new structure.
NOTE: Always ensure that the scripts handle accidental re-runs so that someone doesn't accidentally corrupt their database.
The entities can be found in the ./src/server/dataaccess/models folder. It should be pretty easy to figure out how to add these entities to the collection when examning these files.
- Variations on DECIMAL types should be kept to a minimum. The current accepted types are:
- DECIMAL(10, 2) - used for story points (to support 0.25, 0.5, 1.0 etc.) and percentages (to support finer-grained values than exact integer percentages but 10 places are overkill for the percentage because 100% is quite often the max value, but we do this for consistency to avoid introducing a new decimal type)
import React from "react";
import { withTranslation, WithTranslation } from "react-i18next";
const InnerComponent = ({ t }: WithTranslation) => (
<React.Fragment>
<h2>{t("translate-string-name")}</h2>
<ul>
<li>Item with translated text here: {t("more-translated-text-translate-string-name")}</li>
</ul>
</React.Fragment>
);
export const Component = withTranslation()(InnerComponent);
/* exported interfaces */
type Props = {
setLocale: (locale: string) => void;
t: (key: string) => string;
};
/* exported component */
const App = ({ setLocale, t }: Props) => {
const handleLocaleChange = useCallback(
(e: React.FormEvent<HTMLButtonElement>) => {
setLocale(e.currentTarget.value);
},
[setLocale]
);
return (
<div className={css.wrapper}>
<Helmet defaultTitle="Atoll" titleTemplate="Atoll – %s" link={[{ rel: "icon", type: "image/png", href: favicon }]} />
<TopMenuPanel />
</div>
);
};
const mapDispatchToProps = {
setLocale
};
export default connect(
null,
mapDispatchToProps
)(withTranslation()<any>(App));
This app relies on fast rendering of images so they're all in-lined. This should also make it easier for code-splitting, lazy-loading, etc.
- The
atoll-shared
repo contains all the SVG assets and generated components. Use terminal andcd atoll-shared
to execute all commands below in this folder. - The original SVG file should be stored in the
/assets
folder. - Make sure to name components using the convention:
{lowercase-component-name}-icon.svg
, for examplemenu-caret-down-icon.svg
- Use
npm run gen:react-svg -- menu-caret-down-icon
to generate the basic React componentMenuCareDownIcon.tsx
. - The file will be placed in the
/components/atoms/icons
folder. - Affinity places additional SVG elements that aren't needed so you should remove them:
- remove the line with
xmlnsSerif=
- remove the attribute
serifId="{component-title}"
(for example,serifId="Menu Caret"
) - change
const classNameToUse = buildClassName(props.className);
toconst classNameToUse = buildClassName(strokeClass, props.className);
- add
fill="none"
andclassName={classNameToUse}
attributes to the top of thesvg
element. - remove
id
attribute from theg
element and replace it withclassName={fillClass}
, for example,<g id="Menu-Caret" transform=...
becomes<g className={fillClass} transform...
- remove the line with
- Make sure you sort the
index.ts
file (it should have the new component added to it). - Make sure you follow the steps to add this icon component to storybook.
- In all cases before, make sure to add new entries in alphabetical order.
- Find the
allicons.stories.tsx
file (it should be in the/stories/atoms/icons
folder). - Add component by name to the import list under
// components
section. - Add component to
invertableIcons
,icons
object definitions. - Add component to
iconNames
list. - Make sure to build the package (
npm run build
) and then usenpm run storybook
to view the component to ensure that it displays correctly.