Skip to content

Commit 2bd7f5c

Browse files
authored
Merge pull request #777 from Real-Dev-Squad/develop
Sync Dev to main
2 parents cbc3db6 + 16d900a commit 2bd7f5c

File tree

10 files changed

+827
-40
lines changed

10 files changed

+827
-40
lines changed

__tests__/groups/group.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,13 @@ describe('Discord Groups Page', () => {
202202
const groupTitle = await groupCreationModal.$(
203203
`.input__field[name="title"]`,
204204
);
205+
const groupDescription = await groupCreationModal.$(
206+
`.input__field[name="description"]`,
207+
);
205208
const submitBtn = await groupCreationModal.$('.submit__button');
206209

207210
expect(groupTitle).toBeTruthy();
211+
expect(groupDescription).toBeTruthy();
208212
expect(submitBtn).toBeTruthy();
209213
});
210214

groups/createElements.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const createGroupCreationModal = (onClose = () => {}, onSubmit = () => {}) => {
109109
</span>
110110
</div>
111111
<form class="form">
112-
<div class="input">
112+
<div class="input" id="title">
113113
<label for="title" class="input__label">@group</label>
114114
<div class="input__container">
115115
<input
@@ -123,28 +123,40 @@ const createGroupCreationModal = (onClose = () => {}, onSubmit = () => {}) => {
123123
</button>
124124
</div>
125125
</div>
126+
<div class="input" id="description">
127+
<label for="description" class="input__label">Description</label>
128+
<div class="input__container">
129+
<textarea
130+
class="input__field"
131+
name="description"
132+
placeholder="This group is for..."
133+
></textarea>
134+
</div>
135+
</div>
126136
127137
<div class="spacer"></div>
128138
<button type="submit" class="submit__button submit__button--disabled button">Create</button>
129139
</form>
130140
`;
131-
const inputField = modalElement.querySelector('.input__field');
141+
const titleField = modalElement.querySelector('#title .input__field');
142+
const descriptionField = modalElement.querySelector(
143+
'#description .input__field',
144+
);
132145
const submitButton = modalElement.querySelector('.submit__button');
133146
modalElement.onclick = (e) => e.stopPropagation();
134147
modalElement.querySelector('#close-button').onclick = onClose;
135148
modalElement.querySelector('#clear-input').onclick = () => {
136-
inputField.value = '';
149+
titleField.value = '';
137150
toggle({ enabled: false });
138151
};
139152

140-
function getInput() {
141-
return inputField.value.trim().toLowerCase();
153+
function getTitle() {
154+
return titleField.value.trim().toLowerCase();
142155
}
143156

144-
inputField.addEventListener('input', () => {
145-
const inputValue = getInput();
146-
const shouldDisableSubmit =
147-
inputValue.length === 0 || inputValue.includes('group');
157+
titleField.addEventListener('input', () => {
158+
const title = getTitle();
159+
const shouldDisableSubmit = title.length === 0 || title.includes('group');
148160

149161
toggle({ enabled: !shouldDisableSubmit });
150162
});
@@ -161,13 +173,17 @@ const createGroupCreationModal = (onClose = () => {}, onSubmit = () => {}) => {
161173

162174
form.onsubmit = (e) => {
163175
e.preventDefault();
164-
const inputValue = getInput();
165-
if (inputValue.length === 0 || inputValue.includes('group')) {
176+
const title = getTitle();
177+
const description = descriptionField.value.trim();
178+
if (title.length === 0 || title.includes('group')) {
166179
throw new Error('Invalid group name');
167180
}
168181

169182
toggle({ enabled: false });
170-
onSubmit(inputField.value).then(() => {
183+
onSubmit({
184+
title,
185+
description,
186+
}).then(() => {
171187
toggle({ enabled: true });
172188
});
173189
};

groups/script.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ const handler = {
7272
if (value) {
7373
renderGroupCreationModal({
7474
onClose: () => (dataStore.isGroupCreationModalOpen = false),
75-
onSubmit: (inputValue) => {
75+
onSubmit: ({ title, description }) => {
7676
return createDiscordGroupRole({
77-
rolename: inputValue,
77+
rolename: title,
78+
...(description && { description }),
7879
}).then(() => {
7980
showToaster('Group created successfully');
8081
dataStore.isGroupCreationModalOpen = false;

groups/style.css

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@
3131
--color-group-btn-hover: var(--color-secondary-darker);
3232
}
3333

34-
input:focus {
34+
input:focus,
35+
button:focus,
36+
textarea:focus {
3537
outline: none;
3638
}
3739

40+
textarea {
41+
resize: none;
42+
}
43+
3844
.button {
3945
border: none;
4046
border-radius: 8px;
@@ -130,7 +136,7 @@ body {
130136
*/
131137

132138
.group-creation-modal {
133-
height: 380px;
139+
height: 450px;
134140
width: clamp(300px, 100%, 350px);
135141
background-color: var(--color-white);
136142
border-radius: 8px;
@@ -170,11 +176,13 @@ body {
170176
flex-direction: column;
171177
flex-grow: 1;
172178
margin: 1rem 2rem 2rem 2rem;
179+
gap: 1rem;
173180

174181
.input {
175182
display: flex;
176183
align-items: center;
177184
gap: 8px;
185+
flex-grow: 1;
178186

179187
.input__label {
180188
font-size: 0.9rem;
@@ -188,36 +196,52 @@ body {
188196
background: rgb(245, 246, 246);
189197
border-radius: 8px;
190198
flex-grow: 1;
199+
}
191200

192-
.input__field {
193-
padding-left: 1rem;
194-
width: calc(100% - 1rem);
195-
box-sizing: border-box;
196-
flex-grow: 1;
197-
border: none;
198-
background-color: transparent;
199-
}
201+
.input__field {
202+
padding: 0.7rem;
203+
box-sizing: border-box;
204+
flex-grow: 1;
205+
border: none;
206+
background-color: transparent;
207+
}
208+
209+
.input__field::placeholder {
210+
font-size: 14px;
211+
font-weight: 400;
212+
line-height: 17.5px;
213+
text-align: left;
214+
color: hsla(220, 9%, 46%, 0.5);
215+
}
200216

201-
.input__field::placeholder {
202-
font-size: 14px;
203-
font-weight: 400;
204-
line-height: 17.5px;
205-
text-align: left;
217+
#clear-input {
218+
padding: 0.7rem 1rem;
219+
border: none;
220+
display: grid;
221+
place-content: center;
222+
background-color: transparent;
206223

207-
color: hsla(220, 9%, 46%, 0.5);
224+
img {
225+
height: 1.1rem;
208226
}
227+
}
228+
}
209229

210-
#clear-input {
211-
padding: 0.7rem 1rem;
212-
border: none;
213-
display: grid;
214-
place-content: center;
215-
background-color: transparent;
230+
#description {
231+
flex-direction: column;
232+
align-items: flex-start;
233+
gap: 0px;
216234

217-
img {
218-
height: 1.1rem;
219-
}
220-
}
235+
.input__container {
236+
width: 100%;
237+
}
238+
239+
.input__label {
240+
color: rgb(90, 96, 107);
241+
}
242+
243+
.input__field {
244+
height: 100px;
221245
}
222246
}
223247

identity-service-logs/constants.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export const SUPER_USER = 'super_user';
2+
export const BORDER_COLOR = {
3+
PROFILE_VERIFIED: 'blue',
4+
PROFILE_BLOCKED: 'orangered',
5+
PROFILE_DIFF_REJECTED: 'red',
6+
PROFILE_DIFF_APPROVED: 'green',
7+
PROFILE_DIFF_STORED: '#ADD8E6',
8+
};
9+
10+
export const TYPE_NAME = {
11+
PROFILE_VERIFIED: 'PROFILE SERVICE VERIFIED',
12+
PROFILE_BLOCKED: 'PROFILE SERVICE BLOCKED',
13+
PROFILE_DIFF_REJECTED: 'PROFILE DIFFERENCE REJECTED',
14+
PROFILE_DIFF_APPROVED: 'PROFILE DIFFERENCE APPROVED',
15+
PROFILE_DIFF_STORED: 'PROFILE DIFFERENCE STORED',
16+
};
17+
18+
export const TYPE_DESCRIPTION = {
19+
PROFILE_VERIFIED: ({ username }) =>
20+
`${username}'s profile has been verified and is now officially authenticated.`,
21+
PROFILE_BLOCKED: ({ username, reason }) =>
22+
`${username}'s profile has been blocked. ${
23+
reason ? `Reason provided: "${reason}."` : 'No reason provided!'
24+
}`,
25+
PROFILE_DIFF_REJECTED: ({ username, adminUserName, profileDiffId, reason }) =>
26+
`${adminUserName} rejected a profile update request for ${username}. The request with Profile Diff ID ${profileDiffId} was declined due to: "${
27+
reason || ''
28+
}"`,
29+
PROFILE_DIFF_APPROVED: ({ username, adminUserName, profileDiffId, reason }) =>
30+
`${adminUserName} approved a profile update request for ${username}. The changes are now live. The request has a Profile Diff ID ${profileDiffId}. Message: "${
31+
reason || ''
32+
}"`,
33+
PROFILE_DIFF_STORED: ({ username }) =>
34+
`${username}'s profile changes have been saved for further review.`,
35+
};
36+
37+
export const BACKGROUND_COLOR = {
38+
PROFILE_VERIFIED: 'rgba(0,0,255,0.2)',
39+
PROFILE_BLOCKED: 'rgba(255,69,0,0.2)',
40+
PROFILE_DIFF_REJECTED: 'rgba(255,0,0,0.2)',
41+
PROFILE_DIFF_APPROVED: 'rgba(0,128,0,0.2)',
42+
PROFILE_DIFF_STORED: 'rgb(173,216,230,0.2)',
43+
};

identity-service-logs/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="icon" href="/images/index.ico" type="image/x-icon" />
8+
<title>Identity Service Logs | Real Dev Squad</title>
9+
<link rel="stylesheet" href="/global.css" />
10+
<link rel="stylesheet" href="/identity-service-logs/style.css" />
11+
<script src="/helpers/loadENV.js"></script>
12+
<script src="/constants.js"></script>
13+
<script type="module" src="/identity-service-logs/script.js" defer></script>
14+
</head>
15+
16+
<body>
17+
<div id="cover-spin"></div>
18+
<nav>
19+
<h1>Identity Service Logs</h1>
20+
</nav>
21+
22+
<div class="toast">
23+
<div class="toast__message"></div>
24+
</div>
25+
26+
<div class="stats">
27+
<div>Verified Users: <span id="verified" class="stats-value"></span></div>
28+
<div>Blocked Users: <span id="blocked" class="stats-value"></span></div>
29+
<div>
30+
Total Developers: <span id="developers" class="stats-value"></span>
31+
</div>
32+
<div>
33+
Verified Developers:
34+
<span id="verifiedDevelopers" class="stats-value"></span>
35+
</div>
36+
<div>
37+
Blocked Developers:
38+
<span id="blockedDevelopers" class="stats-value"></span>
39+
</div>
40+
<div>
41+
Developers Left: <span id="developersLeft" class="stats-value"></span>
42+
</div>
43+
</div>
44+
45+
<p id="loader">Loading...</p>
46+
47+
<footer id="footer">
48+
<p class="info-repo">
49+
The contents of this website are deployed from this
50+
<a
51+
href="https://github.com/Real-Dev-Squad/website-dashboard"
52+
target="_blank"
53+
rel="noopener noreferrer"
54+
>
55+
open sourced repo
56+
</a>
57+
</p>
58+
</footer>
59+
</body>
60+
</html>

identity-service-logs/script.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { SUPER_USER } from './constants.js';
2+
3+
import {
4+
getIdentityLogs,
5+
getIsSuperUser,
6+
fillData,
7+
getUserCount,
8+
} from './utils.js';
9+
10+
const { isSuperUser } = await getIsSuperUser();
11+
12+
if (isSuperUser) {
13+
const {
14+
verifiedUsersCount,
15+
blockedUsersCount,
16+
verifiedDeveloperCount,
17+
blockedDeveloperCount,
18+
developersLeftToVerifyCount,
19+
developersCount,
20+
} = await getUserCount();
21+
document.getElementById('verified').innerText = verifiedUsersCount;
22+
document.getElementById('blocked').innerText = blockedUsersCount;
23+
document.getElementById('developers').innerText = developersCount;
24+
document.getElementById('verifiedDevelopers').innerText =
25+
verifiedDeveloperCount;
26+
document.getElementById('blockedDevelopers').innerText =
27+
blockedDeveloperCount;
28+
document.getElementById('developersLeft').innerText =
29+
developersLeftToVerifyCount;
30+
const { identityLogs, next, prev } = await getIdentityLogs(
31+
'/logs?dev=true&type=PROFILE_BLOCKED,PROFILE_VERIFIED,PROFILE_DIFF_REJECTED,PROFILE_DIFF_APPROVED,PROFILE_DIFF_STORED&size=10',
32+
);
33+
fillData(identityLogs, next, prev);
34+
} else {
35+
document.getElementById('loader').innerHTML = 'You are not authorized !';
36+
}

0 commit comments

Comments
 (0)