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

refactor: UI adjustments and refactoring #297

Merged
merged 2 commits into from
Sep 2, 2024
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
40 changes: 0 additions & 40 deletions api/errorpkg/error_creators.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,6 @@ func NewInvitationNotFoundError(err error) *ErrorResponse {
)
}

func NewSnapshotLanguageNotSetError(err error) *ErrorResponse {
return NewErrorResponse(
"snapshot_language_not_set",
http.StatusBadRequest,
"Snapshot language is not set.",
"Snapshot language is not set.",
err,
)
}

func NewSnapshotTextLengthExceedsLimitError(err error) *ErrorResponse {
return NewErrorResponse(
"snapshot_text_length_exceeds_limit",
http.StatusBadRequest,
"Snapshot text length exceeds limit.",
"Snapshot text length exceeds limit.",
err,
)
}

func NewSnapshotCannotBePatchedError(err error) *ErrorResponse {
return NewErrorResponse(
"snapshot_cannot_be_patched",
Expand All @@ -180,16 +160,6 @@ func NewSnapshotHasPendingTaskError(err error) *ErrorResponse {
)
}

func NewUnsupportedFileTypeError(err error) *ErrorResponse {
return NewErrorResponse(
"unsupported_file_type",
http.StatusBadRequest,
"File type is not supported.",
"File type is not supported.",
err,
)
}

func NewTaskIsRunningError(err error) *ErrorResponse {
return NewErrorResponse(
"task_is_running",
Expand All @@ -210,16 +180,6 @@ func NewTaskBelongsToAnotherUserError(err error) *ErrorResponse {
)
}

func NewCannotDeletePendingTaskError(err error) *ErrorResponse {
return NewErrorResponse(
"cannot_delete_pending_task",
http.StatusBadRequest,
"Cannot delete a pending task.",
"Cannot delete a pending task.",
err,
)
}

func NewInternalServerError(err error) *ErrorResponse {
return NewErrorResponse(
"internal_server_error",
Expand Down
113 changes: 61 additions & 52 deletions ui/src/pages/group/group-settings-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,62 +59,71 @@ const GroupSettingsPage = () => {
<Helmet>
<title>{group.name}</title>
</Helmet>
<div className={sectionClassName}>
<div className={rowClassName}>
<span>Name</span>
<Spacer />
<span>{truncateEnd(group.name, 60)}</span>
<IconButton
icon={<IconEdit />}
isDisabled={!hasEditPermission}
aria-label=""
onClick={() => {
setIsNameModalOpen(true)
}}
/>
<div className={cx('flex', 'flex-col', 'gap-0')}>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Basics</span>
<div className={rowClassName}>
<span>Name</span>
<Spacer />
<span>{truncateEnd(group.name, 60)}</span>
<IconButton
icon={<IconEdit />}
isDisabled={!hasEditPermission}
aria-label=""
onClick={() => {
setIsNameModalOpen(true)
}}
/>
</div>
<Divider />
</div>
<Divider />
<div className={rowClassName}>
<span>Add members</span>
<Spacer />
<IconButton
icon={<IconPersonAdd />}
isDisabled={!hasOwnerPermission}
aria-label=""
onClick={() => {
setIsAddMembersModalOpen(true)
}}
/>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Membership</span>
<div className={rowClassName}>
<span>Add members</span>
<Spacer />
<IconButton
icon={<IconPersonAdd />}
isDisabled={!hasOwnerPermission}
aria-label=""
onClick={() => {
setIsAddMembersModalOpen(true)
}}
/>
</div>
<Divider />
</div>
<Divider />
<div className={rowClassName}>
<span>Delete permanently</span>
<Spacer />
<IconButton
icon={<IconDelete />}
variant="solid"
colorScheme="red"
isDisabled={!hasOwnerPermission}
aria-label=""
onClick={() => setDeleteModalOpen(true)}
/>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Advanced</span>
<div className={rowClassName}>
<span>Delete group</span>
<Spacer />
<IconButton
icon={<IconDelete />}
variant="solid"
colorScheme="red"
isDisabled={!hasOwnerPermission}
aria-label=""
onClick={() => setDeleteModalOpen(true)}
/>
</div>
</div>
<GroupEditName
open={isNameModalOpen}
group={group}
onClose={() => setIsNameModalOpen(false)}
/>
<GroupAddMember
open={isAddMembersModalOpen}
group={group}
onClose={() => setIsAddMembersModalOpen(false)}
/>
<GroupDelete
open={deleteModalOpen}
group={group}
onClose={() => setDeleteModalOpen(false)}
/>
</div>
<GroupEditName
open={isNameModalOpen}
group={group}
onClose={() => setIsNameModalOpen(false)}
/>
<GroupAddMember
open={isAddMembersModalOpen}
group={group}
onClose={() => setIsAddMembersModalOpen(false)}
/>
<GroupDelete
open={deleteModalOpen}
group={group}
onClose={() => setDeleteModalOpen(false)}
/>
</>
)
}
Expand Down
145 changes: 77 additions & 68 deletions ui/src/pages/organization/organization-settings-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,78 +60,87 @@ const OrganizationSettingsPage = () => {
<Helmet>
<title>{org.name}</title>
</Helmet>
<div className={sectionClassName}>
<div className={rowClassName}>
<span>Name</span>
<Spacer />
<span>{truncateEnd(org.name, 60)}</span>
<IconButton
icon={<IconEdit />}
isDisabled={!geEditorPermission(org.permission)}
aria-label=""
onClick={() => {
setIsNameModalOpen(true)
}}
/>
<div className={cx('flex', 'flex-col', 'gap-0')}>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Basics</span>
<div className={rowClassName}>
<span>Name</span>
<Spacer />
<span>{truncateEnd(org.name, 60)}</span>
<IconButton
icon={<IconEdit />}
isDisabled={!geEditorPermission(org.permission)}
aria-label=""
onClick={() => {
setIsNameModalOpen(true)
}}
/>
</div>
<Divider />
</div>
<Divider />
<div className={rowClassName}>
<span>Invite members</span>
<Spacer />
<IconButton
icon={<IconPersonAdd />}
isDisabled={!geOwnerPermission(org.permission)}
aria-label=""
onClick={() => {
setIsInviteMembersModalOpen(true)
}}
/>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Membership</span>
<div className={rowClassName}>
<span>Invite members</span>
<Spacer />
<IconButton
icon={<IconPersonAdd />}
isDisabled={!geOwnerPermission(org.permission)}
aria-label=""
onClick={() => {
setIsInviteMembersModalOpen(true)
}}
/>
</div>
<div className={rowClassName}>
<span>Leave</span>
<Spacer />
<IconButton
icon={<IconLogout />}
variant="solid"
colorScheme="red"
aria-label=""
onClick={() => setIsLeaveModalOpen(true)}
/>
</div>
<Divider />
</div>
<div className={rowClassName}>
<span>Leave</span>
<Spacer />
<IconButton
icon={<IconLogout />}
variant="solid"
colorScheme="red"
aria-label=""
onClick={() => setIsLeaveModalOpen(true)}
/>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Advanced</span>
<div className={rowClassName}>
<span>Delete organization</span>
<Spacer />
<IconButton
icon={<IconDelete />}
variant="solid"
colorScheme="red"
isDisabled={!geEditorPermission(org.permission)}
aria-label=""
onClick={() => setIsDeleteModalOpen(true)}
/>
</div>
</div>
<Divider />
<div className={rowClassName}>
<span>Delete permanently</span>
<Spacer />
<IconButton
icon={<IconDelete />}
variant="solid"
colorScheme="red"
isDisabled={!geEditorPermission(org.permission)}
aria-label=""
onClick={() => setIsDeleteModalOpen(true)}
/>
</div>
<OrganizationEditName
open={isNameModalOpen}
organization={org}
onClose={() => setIsNameModalOpen(false)}
/>
<OrganizationInviteMembers
open={isInviteMembersModalOpen}
id={org.id}
onClose={() => setIsInviteMembersModalOpen(false)}
/>
<OrganizationLeave
open={isLeaveModalOpen}
id={org.id}
onClose={() => setIsLeaveModalOpen(false)}
/>
<OrganizationDelete
open={isDeleteModalOpen}
organization={org}
onClose={() => setIsDeleteModalOpen(false)}
/>
</div>
<OrganizationEditName
open={isNameModalOpen}
organization={org}
onClose={() => setIsNameModalOpen(false)}
/>
<OrganizationInviteMembers
open={isInviteMembersModalOpen}
id={org.id}
onClose={() => setIsInviteMembersModalOpen(false)}
/>
<OrganizationLeave
open={isLeaveModalOpen}
id={org.id}
onClose={() => setIsLeaveModalOpen(false)}
/>
<OrganizationDelete
open={isDeleteModalOpen}
organization={org}
onClose={() => setIsDeleteModalOpen(false)}
/>
</>
)
}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/pages/workspace/workspace-settings-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ const WorkspaceSettingsPage = () => {
<Progress value={0} hasStripe />
</>
) : null}
<Divider />
<div className={rowClassName}>
<span>Storage capacity</span>
<span>Capacity</span>
<Spacer />
<span>{prettyBytes(workspace.storageCapacity)}</span>
<EditButton
Expand All @@ -135,11 +134,12 @@ const WorkspaceSettingsPage = () => {
}}
/>
</div>
<Divider />
</div>
<div className={sectionClassName}>
<span className={cx('font-bold')}>Advanced</span>
<div className={rowClassName}>
<span>Delete permanently</span>
<span>Delete workspace</span>
<Spacer />
<IconButton
icon={<IconDelete />}
Expand Down