Skip to content

Commit b19e836

Browse files
author
ahmetkuslular
committed
FIX: client js packages fixes and welcome screen style
1 parent 43b4a2e commit b19e836

File tree

13 files changed

+161
-69
lines changed

13 files changed

+161
-69
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"compression": "^1.7.4",
4747
"cookie-parser": "1.4.3",
4848
"copy-webpack-plugin": "4.5.2",
49-
"core-js": "3.20.3",
5049
"css-loader": "6.5.1",
5150
"css-minimizer-webpack-plugin": "3.4.1",
5251
"eev": "0.1.5",

src/universal/core/apiService/apiManager/BaseApiManager.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,44 @@ import {
44
JSON_CONTENT_TYPE,
55
REQUEST_TYPES_WITH_BODY
66
} from '../../../utils/constants';
7-
import voltranConfig from '../../../../../voltran.config';
87
import CookieService from '../../../service/CookieService';
8+
import pickByIndexOf from '../../../utils/lodash/pickByIndexOf';
9+
import omitByIndexOf from '../../../utils/lodash/omitByIndexOf';
910

1011
function createBaseConfig() {
1112
return {};
1213
}
1314

1415
class BaseApiManager {
15-
constructor(customConfig) {
16+
constructor(config) {
1617
const headers = {
1718
common: {
1819
...createBaseConfig.headers,
19-
...(customConfig ? customConfig.headers : null)
20+
...(config ? config.headers : null)
2021
}
2122
};
2223

2324
if (!process.env.BROWSER) {
2425
headers['Accept-Encoding'] = 'gzip, deflate';
2526
}
2627

27-
if (process.env.BROWSER && voltranConfig.setCookiesToHeader) {
28-
const cookieMap = CookieService.getAllItems();
29-
30-
Object.keys(cookieMap).forEach(key => {
31-
if (voltranConfig.setCookiesToHeaderKeys.length > 0) {
32-
voltranConfig.setCookiesToHeaderKeys.map(item => {
33-
if (key.indexOf(item) === 0) {
34-
headers[key] = cookieMap[key];
35-
}
36-
});
37-
} else {
38-
headers[key] = cookieMap[key];
39-
}
28+
if (process.env.BROWSER && config?.addCookiesToHeader) {
29+
let cookies = CookieService.getAllItems();
30+
if (config?.includeCookies?.length > 0) {
31+
cookies = pickByIndexOf(cookies, config?.includeCookies);
32+
}
33+
if (config?.excludeCookies?.length > 0) {
34+
cookies = omitByIndexOf(cookies, config?.excludeCookies);
35+
}
36+
37+
Object.keys(cookies).forEach(key => {
38+
headers[key] = cookies[key];
4039
});
4140
}
4241

4342
this.api = this.createInstance({
4443
...createBaseConfig(),
45-
...customConfig,
44+
...config,
4645
headers
4746
});
4847
}

src/universal/core/apiService/apiManagerCache/ClientApiManagerCache.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import createCache from '../utils/createCache';
55
const { services, serviceConfigs } = require('__APP_CONFIG__');
66

77
const getCache = func => {
8-
const cache = createCache(ClientApiManager, services, serviceConfigs?.client, func);
8+
const { client, defaultConfig } = serviceConfigs;
9+
const config = {
10+
...defaultConfig,
11+
...client
12+
};
13+
const cache = createCache(ClientApiManager, services, config, func);
914

1015
return cache;
1116
};

src/universal/core/apiService/apiManagerCache/ServerApiManagerCache.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import createCache from '../utils/createCache';
55
const { services, serviceConfigs } = require('__APP_CONFIG__');
66

77
const getCache = func => {
8-
const cache = createCache(ServerApiManager, services, serviceConfigs?.server, func);
8+
const { server, defaultConfig } = serviceConfigs;
9+
const config = {
10+
...defaultConfig,
11+
...server
12+
};
13+
const cache = createCache(ServerApiManager, services, config, func);
914

1015
return cache;
1116
};

src/universal/partials/Welcome/PartialCards.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ import { ServerStyleSheet } from 'styled-components';
55
import partials from './partials';
66
import groupBy from '../../utils/lodash/groupBy';
77

8-
const STATUS_COLOR = {
9-
live: '#8dc63f',
10-
dev: '#FF6000',
11-
page: '#00abff',
12-
1: '#9b59b6',
13-
2: '#c0392b',
14-
3: '#16a085'
15-
};
16-
178
const sheet = new ServerStyleSheet();
189

1910
const Welcome = () => {
@@ -26,10 +17,8 @@ const Welcome = () => {
2617
className="link"
2718
>
2819
<div className="card">
29-
<div className="card-header">
30-
<div className="badge" style={{ backgroundColor: STATUS_COLOR[status] }}>
31-
{title}
32-
</div>
20+
<div className="ribbon-wrapper">
21+
<div className={`ribbon color-${status}`}> {title}</div>
3322
</div>
3423
<div className="card-title">{item.name}</div>
3524
<div className="card-subtitle">

src/universal/partials/Welcome/welcomeStyle.js

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const welcomeStyle = () => {
1010
--theme-bg-color: #fafafb;
1111
--body-font: "Poppins", sans-serif;
1212
--body-color: #2f2f33;
13-
--active-color: #0162ff;
14-
--active-light-color: #e1ebfb;
13+
--active-color: #4e4e4e;
14+
--active-light-color: #f1f1f1;
1515
--header-bg-color: #fff;
1616
--border-color: #d8d8d8;
1717
--alert-bg-color: #e8f2ff;
@@ -157,7 +157,7 @@ const welcomeStyle = () => {
157157
}
158158
.group-title {
159159
font-size: 24px;
160-
font-weight: 600;
160+
font-weight: 700;
161161
}
162162
.link {
163163
color: inherit;
@@ -190,12 +190,13 @@ const welcomeStyle = () => {
190190
}
191191
192192
.card {
193-
padding: 20px 16px;
193+
padding: 16px 16px;
194194
background-color: var(--header-bg-color);
195195
border-radius: 8px;
196196
cursor: pointer;
197197
transition: 0.2s;
198198
text-decoration: none;
199+
position: relative;
199200
}
200201
.card:hover {
201202
transform: scale(1.02);
@@ -207,8 +208,7 @@ const welcomeStyle = () => {
207208
}
208209
.card-title {
209210
font-weight: 600;
210-
margin-top: 16px;
211-
font-size: 14px;
211+
font-size: 16px;
212212
}
213213
.card-subtitle {
214214
color: var(--subtitle-color);
@@ -220,14 +220,62 @@ const welcomeStyle = () => {
220220
display: flex;
221221
align-items: flex-start;
222222
}
223+
224+
.ribbon-wrapper {
225+
width: 85px;
226+
height: 88px;
227+
overflow: hidden;
228+
position: absolute;
229+
top: 0;
230+
right: 0;
231+
}
232+
233+
.ribbon {
234+
font-size: 10px;
235+
font-weight: bold;
236+
color: var(--header-bg-color);;
237+
text-align: center;
238+
-webkit-transform: rotate(45deg);
239+
-moz-transform: rotate(45deg);
240+
-ms-transform: rotate(45deg);
241+
-o-transform: rotate(45deg);
242+
position: relative;
243+
padding: 0;
244+
left: 26px;
245+
top: 14px;
246+
width: 80px;
247+
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
248+
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
249+
box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
250+
}
251+
252+
.color-live{
253+
background-color: #badc58;
254+
}
255+
.color-dev{
256+
background-color: #f0932b;
257+
}
258+
.color-page{
259+
background-color: #00abff;
260+
}
261+
.color-1{
262+
background-color: #9b59b6;
263+
}
264+
.color-2{
265+
background-color: #c0392b;
266+
}
267+
.color-3{
268+
background-color: #16a085;
269+
}
270+
223271
.badge{
224272
display: flex;
225273
align-items: center;
226274
justify-content: center;
227275
background-color: #f50;
228276
font-weight: 600;
229277
margin-top: 16px;
230-
font-size: 14px;
278+
font-size: 10px;
231279
padding: 5px 10px;
232280
color: white;
233281
border-radius: 5px;

src/universal/utils/lodash/omit.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const keyControl = (keys, key) => {
1414
};
1515

1616
function omit(obj, ...keys) {
17-
return Object.fromEntries(Object.entries(obj).filter(([k]) => keyControl(keys, k)));
17+
return obj == null
18+
? {}
19+
: Object?.fromEntries(Object.entries(obj).filter(([k]) => keyControl(keys, k)));
1820
}
1921

2022
export default omit;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function omitByIndexOf(object, keys) {
2+
if (object == null) {
3+
return {};
4+
}
5+
6+
const result = Object.keys(object).reduce((result, cookiesKey) => {
7+
if (object[cookiesKey]) {
8+
if (keys.some(item => cookiesKey.indexOf(item) === -1)) {
9+
return {
10+
...result,
11+
[cookiesKey]: object[cookiesKey]
12+
};
13+
}
14+
return result;
15+
}
16+
return result;
17+
}, {});
18+
19+
return result;
20+
}
21+
22+
export default omitByIndexOf;

src/universal/utils/lodash/pick.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function pickObject(object, keys) {
2+
return keys.reduce((obj, key) => {
3+
if (Array.isArray(key)) {
4+
return {
5+
...obj,
6+
...pickObject(object, key)
7+
};
8+
}
9+
10+
if (object && Object.prototype.hasOwnProperty.call(object, key)) {
11+
return {
12+
...obj,
13+
[key]: object[key]
14+
};
15+
}
16+
return obj;
17+
}, {});
18+
}
19+
20+
function pick(object, ...keys) {
21+
return object == null ? {} : pickObject(object, keys);
22+
}
23+
24+
export default pick;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function pickByIndexOf(object, keys) {
2+
if (object == null) {
3+
return {};
4+
}
5+
6+
const result = Object.keys(object).reduce((result, cookiesKey) => {
7+
if (object[cookiesKey]) {
8+
if (keys.some(item => cookiesKey.indexOf(item) !== -1)) {
9+
return {
10+
...result,
11+
[cookiesKey]: object[cookiesKey]
12+
};
13+
}
14+
return result;
15+
}
16+
return result;
17+
}, {});
18+
19+
return result;
20+
}
21+
22+
export default pickByIndexOf;

0 commit comments

Comments
 (0)