Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
(a: IDropDown, b: IDropDown) =>
new Date(b?.created_at)?.getTime() - new Date(a?.created_at)?.getTime()
);

setAllStack(stackArray);
//Set selected Stack
const selectedStackData = validateArray(stackArray)
Expand Down
34 changes: 19 additions & 15 deletions ui/src/components/MainHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Libraries
import { useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useNavigate, useLocation, Link } from 'react-router-dom';
import { cbModal, Dropdown, Tooltip} from '@contentstack/venus-components';
import { useDispatch, useSelector } from 'react-redux';

Expand Down Expand Up @@ -164,9 +164,9 @@ const MainHeader = () => {
{logo?.image?.url ? (
<div className="logo">
<Tooltip position="right" content="Projects" wrapperElementType="div">
{/* <Link to={`${logo?.url}`}> */}
<Link to={`${logo?.url}`}>
<img src={logo?.image?.url} width={32} alt="Contentstack" />
{/* </Link> */}
</Link>
</Tooltip>
</div>
) : (
Expand All @@ -189,18 +189,22 @@ const MainHeader = () => {

{(location.pathname == '/projects' || location.pathname.includes('/projects/')) && <div className="flex-end">
<div className="Dropdown-wrapper">
<Dropdown
list={[
{
default: true,
label: <ProfileCard/>,
}
]}
type="click"
className="Profile_card"
>
<div className="user-short-name flex-v-center flex-h-center">{name}</div>
</Dropdown>
<Tooltip content={'Profile'} position='top'>
<Dropdown
list={[
{
default: true,
label: <ProfileCard/>,
}
]}
type="click"
className="Profile_card"
>
<div className="user-short-name flex-v-center flex-h-center">{name}</div>
</Dropdown>

</Tooltip>

</div>
</div>}
</div>
Expand Down
5 changes: 5 additions & 0 deletions ui/src/components/ProfileHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const ProfileCard = () => {
<div className="profile-card__name">{user?.first_name} {user?.last_name}</div>
<div className="profile-card__email">{user?.email}</div>
</div>

<div className="profile-card__email">Region : {user?.region}</div>
<div>

</div>
<div
className="profile-card__logout"
role="button"
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/ProjectsHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const ProjectsHeader = ({
<Search
placeholder={searchPlaceholder}
type="secondary"
onChange={(search: string) =>
setSearchText(search?.trim())
onChange={(search: string) =>{
setSearchText(search)}
}
width="large"
onClear={true}
Expand All @@ -37,7 +37,7 @@ const ProjectsHeader = ({
debounceSearch={true}
id="search-project-input"
version="v2"
disabled={allProject && allProject?.length <= 0 && searchText?.length <= 0}
//disabled={allProject && allProject?.length <= 0 }
/>
</div>
{/* {allProject && allProject?.length > 0 ? (
Expand Down
8 changes: 5 additions & 3 deletions ui/src/context/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface User {
mobile_number: string;
country_code: string;
organizations: Organization[];
region:string;
}
export interface FileDetails {
isLocalPath?: boolean;
Expand Down Expand Up @@ -221,7 +222,7 @@ export interface IAppContext {
authToken: string;
setAuthToken: (token: string) => void;
user: User;
updateUser: (user: User) => void;
setUser: (user: User) => void;
organisationsList: IDropDown[];
updateOrganisationsList: (list: IDropDown[]) => void;
selectedOrganisation: IDropDown;
Expand Down Expand Up @@ -264,7 +265,8 @@ export const DEFAULT_USER: User = {
last_name: '',
mobile_number: '',
country_code: '',
organizations: []
organizations: [],
region:''
};

export const DEFAULT_FILE: IFile = {
Expand Down Expand Up @@ -413,7 +415,7 @@ export const DEFAULT_APP_CONTEXT: IAppContext = {
return;
},
user: DEFAULT_USER,
updateUser: function (): void {
setUser: function (): void {
return;
},
isAuthenticated: false,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/context/app/app.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const AppContextProvider: FC<IProps> = ({ children }) => {
authToken: authToken,
setAuthToken: (token: string) => setAuthToken(() => token),
user: user,
updateUser: (user: User) => setUser(user),
setUser: (user: User) => setUser(user),
isAuthenticated: isAuthenticated,
setIsAuthenticated: (flag: boolean) => setIsAuthenticated(flag),
newMigrationData: newMigration,
Expand Down
11 changes: 8 additions & 3 deletions ui/src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC,useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';

import { getUserDetails, setAuthToken } from '../../store/slice/authSlice';
import { getUserDetails, setAuthToken, setUser } from '../../store/slice/authSlice';
import {
Button,
Field,
Expand Down Expand Up @@ -36,6 +36,7 @@ import AccountPage from '../../components/AccountPage';

// Styles
import './index.scss';
import { RootState } from '../../store';

const Login: FC<IProps> = () => {
const [data, setData] = useState<LoginType>({});
Expand All @@ -56,7 +57,7 @@ const Login: FC<IProps> = () => {
}, []);

const { login, two_factor_authentication: twoFactorAuthentication } = data;

const user = useSelector((state:RootState)=>state?.authentication?.user);
const accountData = {
heading: data?.heading,
subtitle: data?.subtitle,
Expand Down Expand Up @@ -162,7 +163,11 @@ const Login: FC<IProps> = () => {
authToken: response?.data?.app_token,
isAuthenticated: true
}

const userObj = {
...user,
region : region,
}
dispatch( setUser(userObj));
dispatch(setAuthToken(authenticationObj));

setLoginStates((prev) => ({ ...prev, submitted: true }));
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PageLayout, EmptyState, Button, Icon, cbModal, StackCardSkeleton} from
import { jsonToHtml } from '@contentstack/json-rte-serializer';
import HTMLReactParser from 'html-react-parser';
import { useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import {useSelector } from 'react-redux';

// Redux
import { RootState } from '../../store';
Expand Down
10 changes: 8 additions & 2 deletions ui/src/store/slice/authSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ const authSlice = createSlice({
state.isAuthenticated = action?.payload?.isAuthenticated;
},
setUser : (state, action) => {
state.user = action?.payload;
state.user = {
...state.user,
...action?.payload,
};
},
reInitiliseState: (state) => {
state.authToken = '';
Expand All @@ -101,7 +104,10 @@ const authSlice = createSlice({
},
extraReducers: (builder) => {
builder.addCase(getUserDetails?.fulfilled,(state, action:any)=>{
state.user = action?.payload?.user;
state.user = {
...state.user,
...action.payload.user,
};
state.organisationsList = action?.payload?.organisationsList;
state.selectedOrganisation = action?.payload?.selectedOrganisation ;
state.isAuthenticated = !isEmptyString(state?.authToken || '');
Expand Down