Skip to content

Commit

Permalink
feat: Rename service to console
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrkazik99 committed Aug 21, 2024
1 parent c5cd31f commit 26ca965
Show file tree
Hide file tree
Showing 35 changed files with 221 additions and 235 deletions.
4 changes: 2 additions & 2 deletions idp/src/infra/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const userMessages: { [key: string]: string } = {
[ErrorCode.InvalidPassword]: 'Invalid password.',
[ErrorCode.InvalidUsernameOrPassword]: 'Invalid username or password.',
[ErrorCode.UserSuspended]: 'User suspended.',
[ErrorCode.MissingPermission]: 'You are not an admin',
[ErrorCode.OrphanError]: 'You cannot suspend last admin'
[ErrorCode.MissingPermission]: 'You are not an console',
[ErrorCode.OrphanError]: 'You cannot suspend last console'
}

export type ErrorData = {
Expand Down
2 changes: 1 addition & 1 deletion ui/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PORT=3000
API_URL="http://127.0.0.1:8080"
IDP_URL="http://127.0.0.1:8081"
ADMIN_URL="http://127.0.0.1:8086"
CONSOLE_URL="http://127.0.0.1:8086"
2 changes: 1 addition & 1 deletion ui/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ func GetConfig() Config {
func readURLs(config *Config) {
config.APIURL = os.Getenv("API_URL")
config.IDPURL = os.Getenv("IDP_URL")
config.AdminURL = os.Getenv("ADMIN_URL")
config.ConsoleUrl = os.Getenv("CONSOLE_URL")
}
2 changes: 1 addition & 1 deletion ui/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ type Config struct {
Port int
APIURL string
IDPURL string
AdminURL string
ConsoleUrl string
}
10 changes: 5 additions & 5 deletions ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ func main() {
},
}))

adminProxy := e.Group("proxy/admin")
adminURL, err := url.Parse(cfg.AdminURL)
consoleProxy := e.Group("proxy/console")
consoleUrl, err := url.Parse(cfg.ConsoleUrl)
if err != nil {
e.Logger.Fatal(err)
}
adminProxy.Use(middleware.ProxyWithConfig(middleware.ProxyConfig{
Balancer: middleware.NewRoundRobinBalancer([]*middleware.ProxyTarget{{URL: adminURL}}),
consoleProxy.Use(middleware.ProxyWithConfig(middleware.ProxyConfig{
Balancer: middleware.NewRoundRobinBalancer([]*middleware.ProxyTarget{{URL: consoleUrl}}),
Rewrite: map[string]string{
"^/proxy/admin/*": "/$1",
"^/proxy/console/*": "/$1",
},
}))

Expand Down
38 changes: 19 additions & 19 deletions ui/src/client/admin/admin.ts → ui/src/client/console/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// licenses/AGPL.txt.
import useSWR, { SWRConfiguration } from 'swr'
import { PermissionType } from '@/client/api/permission'
import { adminFetcher } from '@/client/fetcher'
import { consoleFetcher } from '@/client/fetcher'
import { getConfig } from '@/config/config'

export interface ListResponse {
Expand Down Expand Up @@ -197,9 +197,9 @@ export const emptyListResponseValue: emptyListResponse = {
data: [],
}

export default class AdminApi {
export default class ConsoleApi {
static async checkIndexesAvailability() {
const response = await fetch(`${getConfig().adminURL}/index/all`, {
const response = await fetch(`${getConfig().consoleURL}/index/all`, {
method: 'GET',
})
if (response) {
Expand All @@ -214,7 +214,7 @@ export default class AdminApi {
return useSWR<IndexManagementList>(
url,
() =>
adminFetcher({
consoleFetcher({
url,
method: 'GET',
}) as Promise<IndexManagementList>,
Expand All @@ -223,106 +223,106 @@ export default class AdminApi {
}

static async getUsersByOrganization(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/organization/users?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<UserOrganizationManagementList>
}

static async listGroups(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/group/all?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<GroupManagementList>
}

static async getGroupsByUser(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/user/groups?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<GroupUserManagementList>
}

static async getGroupsByOrganization(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/organization/groups?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<GroupManagementList>
}

static async listOrganizations(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/organization/all?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<OrganizationManagementList>
}

static async getOrganizationsByUser(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/user/organizations?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<OrganizationUserManagementList>
}

static async getOrganizationById(options: baseIdRequest) {
return adminFetcher({
return consoleFetcher({
url: `/organization?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<OrganizationManagement>
}

static async listWorkspaces(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/workspace/all?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<WorkspaceManagementList>
}

static async getWorkspacesByUser(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/user/workspaces?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<WorkspaceUserManagementList>
}

static async getWorkspacesByOrganization(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/organization/workspaces?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<WorkspaceManagementList>
}

static async listInvitations(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/invitation/all?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<InvitationManagementList>
}

static async countObject(object: string) {
return adminFetcher({
return consoleFetcher({
url: `/${object}/count`,
method: 'GET',
}) as Promise<CountResponse>
}

static async getComponentsVersions(options: ListOptions) {
return adminFetcher({
return consoleFetcher({
url: `/overview/version/internal?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<ComponentVersion>
}

static async renameObject(options: baseIdNameRequest, object: string) {
return adminFetcher({
return consoleFetcher({
url: `/${object}`,
method: 'PATCH',
body: JSON.stringify(options),
}) as Promise<void>
}

static async invitationChangeStatus(options: invitationStatusRequest) {
return adminFetcher({
return consoleFetcher({
url: `/invitation`,
method: 'PATCH',
body: JSON.stringify(options),
Expand Down
4 changes: 2 additions & 2 deletions ui/src/client/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export function idpFetcher<T>(options: FetcherOptions) {
})
}

export function adminFetcher<T>(options: FetcherOptions) {
export function consoleFetcher<T>(options: FetcherOptions) {
return fetcher<T>({
...options,
url: `${getConfig().adminURL}${options.url}`,
url: `${getConfig().consoleURL}${options.url}`,
})
}

Expand Down
10 changes: 5 additions & 5 deletions ui/src/client/idp/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export type User = {
pendingEmail?: string
}

export interface AdminUser extends User {
export interface ConsoleUser extends User {
isEmailConfirmed: boolean
createTime: Date
updateTime: Date
isAdmin: boolean
isActive: boolean
}

export interface AdminUsersResponse {
data: AdminUser[]
export interface ConsoleUsersResponse {
data: ConsoleUser[]
totalElements: number
page: number
size: number
Expand Down Expand Up @@ -93,14 +93,14 @@ export default class UserAPI {
return idpFetcher({
url: `/user/by_id?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<AdminUser>
}) as Promise<ConsoleUser>
}

static async getAllUsers(options: ListOptions) {
return idpFetcher({
url: `/user/all?${this.paramsFromListOptions(options)}`,
method: 'GET',
}) as Promise<AdminUsersResponse>
}) as Promise<ConsoleUsersResponse>
}

static async updateFullName(options: UpdateFullNameOptions) {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/app-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import cx from 'classnames'
import AccountMenu from '@/components/account/menu'
import AdminButton from '@/components/admin/admin-button'
import ConsoleButton from '@/components/console/console-button'
import TaskDrawer from '@/components/task/task-drawer'
import { getAdminStatus } from '@/infra/token'
import { useAppDispatch, useAppSelector } from '@/store/hook'
Expand Down Expand Up @@ -42,8 +42,8 @@ const AppBar = () => {
if (location.pathname.startsWith('/workspace')) {
dispatch(activeNavChanged(NavType.Workspaces))
}
if (location.pathname.startsWith('/admin')) {
dispatch(activeNavChanged(NavType.Admin))
if (location.pathname.startsWith('/console')) {
dispatch(activeNavChanged(NavType.Console))
}
}, [location, dispatch])

Expand All @@ -68,7 +68,7 @@ const AppBar = () => {
{activeNav === NavType.Organizations ? (
<CreateOrganizationButton />
) : null}
{getAdminStatus() ? <AdminButton /> : null}
{getAdminStatus() ? <ConsoleButton /> : null}
<UploadDrawer />
<TaskDrawer />
<AccountMenu />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import { Link } from 'react-router-dom'
import { IconButton } from '@chakra-ui/react'
import { IconAdmin, IconDeAdmin } from '@/lib/components/icons'

const AdminButton = () => {
const ConsoleButton = () => {
const buttonRef = useRef<HTMLButtonElement>(null)
return (
<>
{location.pathname.startsWith('/admin') ? (
{location.pathname.startsWith('/console') ? (
<Link to="/" title="User dashbaord">
<IconButton ref={buttonRef} icon={<IconDeAdmin />} aria-label="" />
</Link>
) : (
<Link to="/admin/dashboard" title="Admin dashbaord">
<Link to="/console/dashboard" title="Cloud console dashbaord">
<IconButton ref={buttonRef} icon={<IconAdmin />} aria-label="" />
</Link>
)}
</>
)
}

export default AdminButton
export default ConsoleButton
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ModalOverlay,
} from '@chakra-ui/react'

interface AdminConfirmationModalProps {
interface ConsoleConfirmationModalProps {
action: string | undefined
closeConfirmationWindow: () => void
isOpen: boolean
Expand All @@ -34,7 +34,7 @@ interface AdminConfirmationModalProps {
target: string | undefined
}

const AdminConfirmationModal = (props: AdminConfirmationModalProps) => {
const ConsoleConfirmationModal = (props: ConsoleConfirmationModalProps) => {
useEffect(() => {
if (
props.isOpen &&
Expand Down Expand Up @@ -95,4 +95,4 @@ const AdminConfirmationModal = (props: AdminConfirmationModalProps) => {
)
}

export default AdminConfirmationModal
export default ConsoleConfirmationModal
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { CSSProperties, MouseEvent, ReactNode } from 'react'
import { Tr } from '@chakra-ui/react'
import { useColorModeValue } from '@chakra-ui/system'

export interface AdminHighlightableProps {
export interface ConsoleHighlightableProps {
onClick: (event: MouseEvent) => void
style?: CSSProperties
children: ReactNode
}

const AdminHighlightableTr = (props: AdminHighlightableProps) => {
const ConsoleHighlightableTr = (props: ConsoleHighlightableProps) => {
const hoverBg = useColorModeValue('gray.300', 'gray.700')

return (
Expand All @@ -24,4 +24,4 @@ const AdminHighlightableTr = (props: AdminHighlightableProps) => {
)
}

export default AdminHighlightableTr
export default ConsoleHighlightableTr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { Field, FieldAttributes, FieldProps, Form, Formik } from 'formik'
import * as Yup from 'yup'

interface AdminRenameModalProps {
interface ConsoleRenameModalProps {
closeConfirmationWindow: () => void
isOpen: boolean
isSubmitting: boolean
Expand All @@ -42,7 +42,7 @@ interface AdminRenameModalProps {
confirm: boolean,
) => Promise<void>
}
const AdminRenameModal = (props: AdminRenameModalProps) => {
const ConsoleRenameModal = (props: ConsoleRenameModalProps) => {
const inputRef = useRef<HTMLInputElement>(null)
useEffect(() => {
if (
Expand Down Expand Up @@ -126,4 +126,4 @@ const AdminRenameModal = (props: AdminRenameModalProps) => {
)
}

export default AdminRenameModal
export default ConsoleRenameModal
File renamed without changes.
Loading

0 comments on commit 26ca965

Please sign in to comment.