Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Session timeout for Community #2186

Merged
merged 35 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ac48132
completed session timeout for Admin: component to change timeout and …
JordanCampbell1 Aug 16, 2024
39fa76d
updated test files and made adjustments based on github
JordanCampbell1 Aug 17, 2024
b1f4251
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Aug 20, 2024
ae0d10d
update based on github suggestion
JordanCampbell1 Aug 21, 2024
398d995
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Aug 21, 2024
fbc71ef
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Aug 22, 2024
539d0cc
added comments
JordanCampbell1 Aug 22, 2024
471eaa1
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Aug 24, 2024
c05fcc5
test updates
JordanCampbell1 Aug 25, 2024
6e5f8c2
Merge branch 'session-timeout' of https://github.com/JordanCampbell1/…
JordanCampbell1 Aug 25, 2024
2e426e0
made enhancements to session management
JordanCampbell1 Aug 27, 2024
63f7b50
fixed tests for session
JordanCampbell1 Aug 27, 2024
661d6e6
final adjustments for tests and new feature of session management
JordanCampbell1 Sep 3, 2024
9289ee7
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Sep 3, 2024
99283cb
merge with updates from another branch
JordanCampbell1 Sep 7, 2024
5c2f9ee
updated some tests
JordanCampbell1 Sep 12, 2024
ec9c20c
adjusted tests again
JordanCampbell1 Sep 12, 2024
8f24f18
moved version back to 16.0.0
JordanCampbell1 Sep 12, 2024
03cbbfe
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Sep 12, 2024
5701872
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Sep 15, 2024
0f89dc2
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Sep 19, 2024
f0db438
fixed lint issues from previous merge
JordanCampbell1 Sep 20, 2024
c99b9c4
Merge branch 'session-timeout' of https://github.com/JordanCampbell1/…
JordanCampbell1 Sep 23, 2024
0c13a24
added packages
JordanCampbell1 Sep 23, 2024
bf91170
fixed svg lint issues and onlclick lint issue
JordanCampbell1 Sep 29, 2024
e624e67
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Sep 29, 2024
612010d
modified packages due to linting errors
JordanCampbell1 Sep 30, 2024
6d96ae2
fixed package mismatch issues
JordanCampbell1 Sep 30, 2024
0b4ea77
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Oct 10, 2024
a21a99d
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Oct 13, 2024
7d9ca3c
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Oct 13, 2024
635d36e
fixing schema issues
JordanCampbell1 Oct 14, 2024
a19994a
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Oct 14, 2024
c15b338
updated mocks for updated create mutation of action item catergory
JordanCampbell1 Oct 14, 2024
c5ccf4e
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
JordanCampbell1 Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 72 additions & 7 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@mui/x-data-grid": "^7.11.0",
"@mui/x-date-pickers": "^7.11.1",
"@pdfme/generator": "^1.2.6",
"@testing-library/react-hooks": "^8.0.1",
"bootstrap": "^5.3.3",
"customize-cra": "^1.0.0",
"dayjs": "^1.11.11",
Expand Down Expand Up @@ -50,7 +51,7 @@
"react-router-dom": "^6.26.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.3",
"react-tooltip": "^5.27.1",
"react-tooltip": "^5.28.0",
"redux": "^4.1.1",
"redux-thunk": "^2.3.0",
"sanitize-html": "^2.13.0",
Expand Down
10 changes: 10 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ input CommentInput {
text: String!
}

type Community {
_id: ID!
logoUrl: String
name: String!
socialMediaUrls: SocialMediaUrls
timeout: Int
websiteLink: String
}
JordanCampbell1 marked this conversation as resolved.
Show resolved Hide resolved

union ConnectionError = InvalidCursor | MaximumValueError

type ConnectionPageInfo {
Expand Down Expand Up @@ -769,6 +778,7 @@ type Mutation {
): Organization!
updatePluginStatus(id: ID!, orgId: ID!): Plugin!
updatePost(data: PostUpdateInput, id: ID!): Post!
updateSessionTimeout(timeout: Int!): Boolean!
JordanCampbell1 marked this conversation as resolved.
Show resolved Hide resolved
updateUserPassword(data: UpdateUserPasswordInput!): UserData!
updateUserProfile(data: UpdateUserInput, file: String): User!
updateUserRoleInOrganization(
Expand Down
6 changes: 6 additions & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ export const UPDATE_COMMUNITY = gql`
}
`;

export const UPDATE_SESSION_TIMEOUT = gql`
mutation updateSessionTimeout($timeout: Int!) {
updateSessionTimeout(timeout: $timeout)
}
`;

export const RESET_COMMUNITY = gql`
mutation resetCommunity {
resetCommunity
Expand Down
8 changes: 8 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ export const GET_COMMUNITY_DATA = gql`
}
`;

export const GET_COMMUNITY_SESSION_TIMEOUT_DATA = gql`
query getCommunityData {
getCommunityData {
timeout
}
}
`;

// get the list of Action Item Categories
export { ACTION_ITEM_CATEGORY_LIST } from './ActionItemCategoryQueries';

Expand Down
17 changes: 17 additions & 0 deletions src/components/ProfileDropdown/ProfileDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';
import { I18nextProvider } from 'react-i18next';
import i18nForTest from 'utils/i18nForTest';
import { GET_COMMUNITY_SESSION_TIMEOUT_DATA } from 'GraphQl/Queries/Queries';

const { setItem } = useLocalStorage();
const MOCKS = [
Expand All @@ -22,6 +23,19 @@ const MOCKS = [
},
},
},
{
request: {
query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
},
result: {
data: {
getCommunityData: {
timeout: 30,
},
},
},
delay: 1000,
},
];

jest.mock('react-toastify', () => ({
Expand Down Expand Up @@ -104,13 +118,16 @@ describe('ProfileDropdown Component', () => {
</BrowserRouter>
</MockedProvider>,
);

await act(async () => {
userEvent.click(screen.getByTestId('togDrop'));
});

userEvent.click(screen.getByTestId('logoutBtn'));

expect(global.window.location.pathname).toBe('/');
});

describe('Member screen routing testing', () => {
test('member screen', async () => {
render(
Expand Down
3 changes: 3 additions & 0 deletions src/components/ProfileDropdown/ProfileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './ProfileDropdown.module.css';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';
import { useTranslation } from 'react-i18next';
import useSession from 'utils/useSession';

/**
* Renders a profile dropdown menu for the user.
Expand All @@ -21,6 +22,7 @@ import { useTranslation } from 'react-i18next';
* @returns JSX.Element - The profile dropdown menu.
*/
const profileDropdown = (): JSX.Element => {
const { endSession } = useSession();
const { t: tCommon } = useTranslation('common');
const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN);
const { getItem } = useLocalStorage();
Expand All @@ -45,6 +47,7 @@ const profileDropdown = (): JSX.Element => {
console.error('Error revoking refresh token:', error);
}
localStorage.clear();
endSession();
navigate('/');
};
const MAX_NAME_LENGTH = 20;
Expand Down
96 changes: 96 additions & 0 deletions src/components/UpdateSession/UpdateSession.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Card styles */
.update-timeout-card {
width: 700px;
background: #ffffff;
border: none;
border-radius: 16px;
filter: drop-shadow(0px 4px 15.3px rgba(0, 0, 0, 0.08));
padding: 20px;
}

.update-timeout-card-header {
background: none;
padding: 16px;
border-bottom: none;
}

.update-timeout-card-title {
font-family: 'Lato', sans-serif;
font-weight: 600;
font-size: 24px;
color: #000000;
}

.update-timeout-card-body {
padding: 20px;
}

.update-timeout-current {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 16px;
color: #000000;
margin-bottom: 20px; /* Increased margin to create more space */
}

.update-timeout-label {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 16px;
color: #000000;
margin-bottom: 10px; /* Keep the same margin to maintain spacing with the slider */
}

.update-timeout-labels-container {
display: flex;
flex-direction: column;
align-items: start;
}

.update-timeout-value {
color: #14ae5c;
font-weight: bold;
}

.update-timeout-slider-labels {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: #757575;
}

.update-timeout-button-container {
display: flex;
justify-content: right;
margin-top: 20px;
}

.update-timeout-button {
width: 112px;
height: 36px;
background: #31bb6b;
border-radius: 6px;
font-family: 'Lato', sans-serif;
font-weight: 500;
font-size: 16px;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
border: none;
box-shadow: none;
}

.update-timeout-button:hover {
background-color: #28a745;
border-color: #28a745;
box-shadow: none;
}

.update-timeout-button:active {
transform: scale(0.98);
}

.update-timeout-slider-container {
position: relative;
}
Loading
Loading