Skip to content

Commit

Permalink
Adjust FSD layers
Browse files Browse the repository at this point in the history
  • Loading branch information
pijng committed Mar 8, 2024
1 parent b3921e8 commit 4814ca4
Show file tree
Hide file tree
Showing 68 changed files with 346 additions and 324 deletions.
2 changes: 1 addition & 1 deletion internal/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.4.2
version: 1.4.3
externalDocs:
description: Find out more about spec
url: ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { chainRoute } from "atomic-router";
import { apiTokenCreateRoute, apiTokenEditRoute, apiTokensRoute, chainAuthorized, chainRole } from "@/routing/shared";

import { createEffect } from "effector";
import { apiTokenModel } from "@/entities/api-token";
import { apiTokenCreateRoute, apiTokenEditRoute, apiTokensRoute, chainAuthorized, chainRole } from "@/shared/routing";

chainRoute({
route: chainRole("Admin", chainAuthorized(apiTokensRoute)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forbiddenRoute, homeRoute, loginRoute, notFoundRoute, registerAdminRoute } from "@/routing/shared";
import { forbiddenRoute, homeRoute, loginRoute, notFoundRoute, registerAdminRoute } from "@/shared/routing";
import { $isAuthorized, createInitialAdmin, notAllowedTriggered, notFoundTriggered, unauthorizedTriggered } from "@/shared/auth";
import { redirect } from "atomic-router";
import { sample } from "effector";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logModel } from "@/entities/log";
import { schemaModel } from "@/entities/schema";
import { chainAuthorized, controls, logsRoute, showLogRoute } from "@/routing/shared";
import { chainAuthorized, controls, logsRoute, showLogRoute } from "@/shared/routing";
import { chainRoute, querySync } from "atomic-router";
import { combine, sample } from "effector";
import { debounce } from "patronum";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chainRoute } from "atomic-router";
import { chainAuthorized, profileRoute } from "@/routing/shared";
import { chainAuthorized, profileRoute } from "@/shared/routing";
import { tagModel } from "@/entities/tag";
import { userModel } from "@/entities/user";
import { createEffect } from "effector";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { chainRoute } from "atomic-router";
import { schemaModel } from "@/entities/schema";
import { chainAuthorized, chainRole, homeRoute, schemaCreateRoute, schemaEditRoute } from "@/routing/shared";
import { chainAuthorized, chainRole, homeRoute, schemaCreateRoute, schemaEditRoute } from "@/shared/routing";
import { tagModel } from "@/entities/tag";

chainRoute({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chainRoute } from "atomic-router";
import { chainAuthorized, chainRole, homeRoute, tagCreateRoute, tagEditRoute, tagsRoute } from "@/routing/shared";
import { chainAuthorized, chainRole, homeRoute, tagCreateRoute, tagEditRoute, tagsRoute } from "@/shared/routing";
import { createEffect } from "effector";
import { tagModel } from "@/entities/tag";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chainRoute } from "atomic-router";
import { chainAuthorized, chainRole, memberCreateRoute, memberEditRoute, membersRoute } from "@/routing/shared";
import { chainAuthorized, chainRole, memberCreateRoute, memberEditRoute, membersRoute } from "@/shared/routing";
import { userModel } from "@/entities/user";
import { tagModel } from "@/entities/tag";

Expand Down
65 changes: 65 additions & 0 deletions web/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import "./chains";
import { userModel } from "@/entities/user";
import { notFoundTriggered, obtainSession } from "@/shared/auth";
import { Link, history, router } from "@/shared/routing";
import { sidebarClosed } from "@/shared/ui";
import { linkRouter, onAppMount } from "atomic-router-forest";
import { createEvent, sample } from "effector";
import { h, spec } from "forest";
import { Pages } from "./pages";

export const Application = () => {
h("body", () => {
spec({
classList: {
"w-full": true,
"min-h-screen": true,
"bg-white": true,
"text-slate-700": true,
"dark:bg-slate-900": true,
"dark:text-slate-300": true,
dark: userModel.$currentTheme.map((theme) => theme === "dark"),
},
});

Pages();
onAppMount(appMounted);
});
};

// This event need to setup initial configuration. You can move it into src/shared
export const appMounted = createEvent();

sample({
clock: router.routeNotFound,
target: notFoundTriggered,
});

// Attach history for the router on the app start
sample({
clock: appMounted,
fn: () => history,
target: router.setHistory,
});

// Add router into the Link instance to easily resolve routes paths
linkRouter({
clock: appMounted,
router,
Link: Link,
});

sample({
clock: appMounted,
target: obtainSession,
});

sample({
clock: appMounted,
target: [userModel.effects.loadThemeFromStorageFx, userModel.effects.loadLocaleFromStorageFx],
});

sample({
clock: router.$path,
target: sidebarClosed,
});
56 changes: 56 additions & 0 deletions web/src/app/pages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ApiTokenCreatePage } from "@/pages/api-token-create";
import { ApiTokenEditPage } from "@/pages/api-token-edit";
import { ApiTokensListPage } from "@/pages/api-tokens-list";
import { ForbiddenPage } from "@/pages/forbidden";
import { HomePage } from "@/pages/home";
import { ShowLogPage } from "@/pages/log";
import { LoginPage } from "@/pages/login";
import { LogsListPage } from "@/pages/logs-list";
import { NotFoundPage } from "@/pages/not-found";
import { ProfilePage } from "@/pages/profile";
import { RegisterAdminPage } from "@/pages/register-admin";
import { SchemaCreatePage } from "@/pages/schema-create";
import { SchemaEditPage } from "@/pages/schema-edit";
import { TagCreatePage } from "@/pages/tag-create";
import { TagEditPage } from "@/pages/tag-edit";
import { TagsListPage } from "@/pages/tags-list";
import { UserCreatePage } from "@/pages/user-create";
import { UserEditPage } from "@/pages/user-edit";
import { UsersListPage } from "@/pages/users-list";
import { forbiddenRoute, loginRoute, notFoundRoute, registerAdminRoute } from "@/shared/routing";
import { Layout } from "@/shared/ui";
import { combine } from "effector";

export const Pages = () => {
const $layoutVisible = combine(
[loginRoute.$isOpened, registerAdminRoute.$isOpened, forbiddenRoute.$isOpened, notFoundRoute.$isOpened],
([loginOpened, registerOpened, forbiddenOpened, notFoundOpened]) => {
return !loginOpened && !registerOpened && !forbiddenOpened && !notFoundOpened;
},
);

Layout({
content: () => {
LoginPage();
RegisterAdminPage();
ForbiddenPage();
NotFoundPage();
ProfilePage();
HomePage();
LogsListPage();
ShowLogPage();
UsersListPage();
UserCreatePage();
UserEditPage();
SchemaCreatePage();
SchemaEditPage();
ApiTokensListPage();
ApiTokenCreatePage();
ApiTokenEditPage();
TagsListPage();
TagCreatePage();
TagEditPage();
},
layoutVisible: $layoutVisible,
});
};
2 changes: 1 addition & 1 deletion web/src/entities/schema/ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logsRoute } from "@/routing/shared";
import { logsRoute } from "@/shared/routing";
import { CardLink } from "@/shared/ui";
import { Store } from "effector";

Expand Down
6 changes: 6 additions & 0 deletions web/src/entities/user/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { User, getUsers } from "@/shared/api";
import { getUser } from "@/shared/api/users";
import { setCurrentAccount } from "@/shared/auth";
import { setLanguage } from "@/shared/lib/i18n";
import { createEffect, createEvent, createStore, sample } from "effector";

Expand Down Expand Up @@ -36,6 +37,11 @@ export const $currentAccount = createStore<User>({
is_revoked: false,
});

sample({
source: $currentAccount,
target: setCurrentAccount,
});

const loadThemeFromStorageFx = createEffect(() => {
return localStorage.getItem(THEME_KEY) || "light";
});
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/api-token-create/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { router } from "@/routing";
import { router } from "@/shared/routing";
import { ApiTokenToCreate, createApiToken } from "@/shared/api";
import { rules } from "@/shared/lib";
import { createEffect, createEvent, createStore, sample } from "effector";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/api-token-edit/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiTokenModel } from "@/entities/api-token";
import { apiTokensRoute } from "@/routing/shared";
import { apiTokensRoute } from "@/shared/routing";
import { ApiTokenToUpdate, deleteApiToken, editApiToken } from "@/shared/api";
import { rules } from "@/shared/lib";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/auth/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { userModel } from "@/entities/user";
import { homeRoute } from "@/routing/shared";
import { homeRoute } from "@/shared/routing";
import { postSession } from "@/shared/api";
import { getSessionFx, tokenReceived } from "@/shared/auth";
import { rules } from "@/shared/lib";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/register-admin/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginRoute } from "@/routing/shared";
import { loginRoute } from "@/shared/routing";
import { registerAdmin } from "@/shared/api";
import { rules } from "@/shared/lib";
import { createEffect, createEvent, createStore, sample } from "effector";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/schema-create/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tagModel } from "@/entities/tag";
import { homeRoute } from "@/routing/shared";
import { homeRoute } from "@/shared/routing";
import { SchemaField, SchemaKind, SchemaToCreate, createSchema } from "@/shared/api";
import { rules } from "@/shared/lib";
import { createEffect, createEvent, createStore, sample } from "effector";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/schema-edit/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { schemaModel } from "@/entities/schema";
import { tagModel } from "@/entities/tag";
import { homeRoute } from "@/routing/shared";
import { homeRoute } from "@/shared/routing";
import { SchemaField, SchemaKind, SchemaToUpdate, deleteSchema, editSchema } from "@/shared/api";
import { rules } from "@/shared/lib";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/tag-create/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tagsRoute } from "@/routing/shared";
import { tagsRoute } from "@/shared/routing";
import { TagToCreate, createTag } from "@/shared/api";
import { rules } from "@/shared/lib";
import { createEffect, createStore, sample } from "effector";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/tag-edit/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tagModel } from "@/entities/tag";
import { tagsRoute } from "@/routing/shared";
import { tagsRoute } from "@/shared/routing";
import { TagToUpdate, deleteTag, editTag } from "@/shared/api";
import { rules } from "@/shared/lib";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/user-create/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { membersRoute } from "@/routing/shared";
import { membersRoute } from "@/shared/routing";
import { UserToCreate, createUser } from "@/shared/api";
import { rules } from "@/shared/lib";
import { createEffect, createEvent, createStore, sample } from "effector";
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/user-edit/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { userModel } from "@/entities/user";
import { membersRoute } from "@/routing/shared";
import { membersRoute } from "@/shared/routing";
import { UserToUpdate, editUser } from "@/shared/api";
import { deleteUser } from "@/shared/api/users";
import { rules } from "@/shared/lib";
Expand Down
28 changes: 2 additions & 26 deletions web/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
import { h, spec, using } from "forest";
import { onAppMount } from "atomic-router-forest";
import "@/routing";

import { Pages } from "@/pages";
import { appMounted } from "@/routing";
import { userModel } from "./entities/user";

function Application() {
h("body", () => {
spec({
classList: {
"w-full": true,
"min-h-screen": true,
"bg-white": true,
"text-slate-700": true,
"dark:bg-slate-900": true,
"dark:text-slate-300": true,
dark: userModel.$currentTheme.map((theme) => theme === "dark"),
},
});

Pages();
onAppMount(appMounted);
});
}
import { using } from "forest";
import { Application } from "@/app";

using(document.querySelector("html")!, Application);
2 changes: 1 addition & 1 deletion web/src/pages/api-token-create/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withRoute } from "atomic-router-forest";
import { h, spec } from "forest";

import { apiTokenCreateRoute } from "@/routing/shared";
import { apiTokenCreateRoute } from "@/shared/routing";
import { Header } from "@/shared/ui";
import { NewApiTokenForm } from "@/features";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/api-token-edit/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withRoute } from "atomic-router-forest";
import { h, spec } from "forest";

import { apiTokenEditRoute } from "@/routing/shared";
import { apiTokenEditRoute } from "@/shared/routing";
import { Header } from "@/shared/ui";
import { EditApiTokenForm } from "@/features";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/api-tokens-list/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withRoute } from "atomic-router-forest";
import { h, spec } from "forest";

import { apiTokenCreateRoute, apiTokensRoute } from "@/routing/shared";
import { apiTokenCreateRoute, apiTokensRoute } from "@/shared/routing";
import { HeaderWithCreation } from "@/widgets";
import { ApiTokensList } from "@/widgets";
import { i18n } from "@/shared/lib/i18n";
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/forbidden/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, spec } from "forest";
import { withRoute } from "atomic-router-forest";

import { forbiddenRoute, homeRoute } from "@/routing/shared";
import { forbiddenRoute, homeRoute } from "@/shared/routing";
import { Header, Link } from "@/shared/ui";
import { i18n } from "@/shared/lib/i18n";

Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/home/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h } from "forest";
import { withRoute } from "atomic-router-forest";

import { homeRoute, schemaCreateRoute } from "@/routing/shared";
import { homeRoute, schemaCreateRoute } from "@/shared/routing";
import { HeaderWithCreation, SchemasList } from "@/widgets";
import { i18n } from "@/shared/lib/i18n";

Expand Down
Loading

0 comments on commit 4814ca4

Please sign in to comment.