-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add FetchTeams and FetchUsers components; implement label ID ha…
…ndling in IncidentCreate
- Loading branch information
Showing
7 changed files
with
199 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Common/Server/Infrastructure/Postgres/SchemaMigrations/1737997557974-MigrationName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class MigrationName1737997557974 implements MigrationInterface { | ||
public name = 'MigrationName1737997557974' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE INDEX "IDX_4d5e62631b2b63aaecb00950ef" ON "MonitorTest" ("isInQueue") `); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "public"."IDX_4d5e62631b2b63aaecb00950ef"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import Team from "Common/Models/DatabaseModels/Team"; | ||
import React, { FunctionComponent, ReactElement, useEffect } from "react"; | ||
import ObjectID from "Common/Types/ObjectID"; | ||
import API from "Common/UI/Utils/API/API"; | ||
import ModelAPI from "Common/UI/Utils/ModelAPI/ModelAPI"; | ||
import Includes from "Common/Types/BaseDatabase/Includes"; | ||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax"; | ||
import SortOrder from "Common/Types/BaseDatabase/SortOrder"; | ||
import ListResult from "Common/UI/Utils/BaseDatabase/ListResult"; | ||
import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; | ||
import ComponentLoader from "Common/UI/Components/ComponentLoader/ComponentLoader"; | ||
import TeamsElement from "./TeamsElement"; | ||
|
||
export interface ComponentProps { | ||
userIds: Array<ObjectID>; | ||
} | ||
|
||
const FetchTeam: FunctionComponent<ComponentProps> = ( | ||
props: ComponentProps, | ||
): ReactElement => { | ||
|
||
const [isLoading, setIsLoading] = React.useState<boolean>(true); | ||
const [error, setError] = React.useState<string>(""); | ||
const [team, setTeam] = React.useState<Array<Team>>([]); | ||
|
||
|
||
const fetchTeam = async () => { | ||
setIsLoading(true); | ||
setError(""); | ||
|
||
try{ | ||
const team: ListResult<Team> = await ModelAPI.getList({ | ||
modelType: Team, | ||
query: { | ||
_id: new Includes(props.userIds), | ||
}, | ||
skip: 0, | ||
limit: LIMIT_PER_PROJECT, | ||
select: { | ||
name: true, | ||
_id: true | ||
}, | ||
sort: { | ||
name: SortOrder.Ascending | ||
} | ||
}); | ||
|
||
setTeam(team.data); | ||
|
||
}catch(err){ | ||
setError(API.getFriendlyMessage(err)); | ||
} | ||
|
||
setIsLoading(false); | ||
}; | ||
|
||
useEffect(() => { | ||
fetchTeam().catch((err) => { | ||
setError(API.getFriendlyMessage(err)); | ||
}); | ||
|
||
}, []); | ||
|
||
if(error){ | ||
return <ErrorMessage message={error} />; | ||
} | ||
|
||
|
||
if(isLoading){ | ||
return <ComponentLoader />; | ||
} | ||
|
||
return ( | ||
<TeamsElement teams={team} /> | ||
); | ||
}; | ||
|
||
export default FetchTeam; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import User from "Common/Models/DatabaseModels/User"; | ||
import React, { FunctionComponent, ReactElement, useEffect } from "react"; | ||
import ObjectID from "Common/Types/ObjectID"; | ||
import API from "Common/UI/Utils/API/API"; | ||
import ModelAPI from "Common/UI/Utils/ModelAPI/ModelAPI"; | ||
import Includes from "Common/Types/BaseDatabase/Includes"; | ||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax"; | ||
import SortOrder from "Common/Types/BaseDatabase/SortOrder"; | ||
import ListResult from "Common/UI/Utils/BaseDatabase/ListResult"; | ||
import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; | ||
import ComponentLoader from "Common/UI/Components/ComponentLoader/ComponentLoader"; | ||
import UsersElement from "./Users"; | ||
|
||
export interface ComponentProps { | ||
userIds: Array<ObjectID>; | ||
} | ||
|
||
const FetchUsers: FunctionComponent<ComponentProps> = ( | ||
props: ComponentProps, | ||
): ReactElement => { | ||
|
||
const [isLoading, setIsLoading] = React.useState<boolean>(true); | ||
const [error, setError] = React.useState<string>(""); | ||
const [users, setUsers] = React.useState<Array<User>>([]); | ||
|
||
|
||
const fetchUsers = async () => { | ||
setIsLoading(true); | ||
setError(""); | ||
|
||
try{ | ||
const users: ListResult<User> = await ModelAPI.getList({ | ||
modelType: User, | ||
query: { | ||
_id: new Includes(props.userIds), | ||
}, | ||
skip: 0, | ||
limit: LIMIT_PER_PROJECT, | ||
select: { | ||
name: true, | ||
profilePictureId: true, | ||
email: true, | ||
_id: true | ||
}, | ||
sort: { | ||
name: SortOrder.Ascending | ||
} | ||
}); | ||
|
||
setUsers(users.data); | ||
|
||
}catch(err){ | ||
setError(API.getFriendlyMessage(err)); | ||
} | ||
|
||
setIsLoading(false); | ||
}; | ||
|
||
useEffect(() => { | ||
fetchUsers().catch((err) => { | ||
setError(API.getFriendlyMessage(err)); | ||
}); | ||
|
||
}, []); | ||
|
||
if(error){ | ||
return <ErrorMessage message={error} />; | ||
} | ||
|
||
|
||
if(isLoading){ | ||
return <ComponentLoader />; | ||
} | ||
|
||
return ( | ||
<UsersElement users={users} /> | ||
); | ||
}; | ||
|
||
export default FetchUsers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters