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

RavenDB-21797 About page adjustments #18363

Merged
merged 28 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2ac7696
RavenDB-21797 Updated UpgradeInfoHandler
Lwiel Apr 4, 2024
ce1ece0
RavenDB-20603 About page
kwiato Nov 22, 2023
b1d25f3
RavenDB-20603 New about layout
kwiato Nov 24, 2023
6bc51d7
RavenDB-20603 About page
kwiato Nov 29, 2023
eb10e98
RavenDB-20603 About page
kwiato Nov 30, 2023
60ac0f1
RavenDB-20603 About page logic
kwiato Dec 3, 2023
d381a58
RavenDB-20603 - Add modals
kwiato Dec 5, 2023
30daabf
RavenDB-20603 License Table
kwiato Jan 30, 2024
243a514
RavenDB-20603 About page
ml054 Feb 1, 2024
041193b
RavenDB-20603 About page
ml054 Feb 3, 2024
4331864
RavenDB-20603 About page - L&F
ml054 Feb 5, 2024
dbcea37
RavenDB-20603 About page - license parameters
ml054 Feb 5, 2024
dae194c
RavenDB-20603 About page - L&F
ml054 Feb 5, 2024
11043c9
RavenDB-20603 About page - L&F
ml054 Feb 6, 2024
8f6fffc
RavenDB-20603 selector fix
ml054 Feb 6, 2024
f9f42c6
RavenDB-20603 Styling fixes for About page
mateuszbartosik Feb 8, 2024
37fc1b0
RavenDB-20603 after rebase fixes
ml054 Mar 5, 2024
5b2bdc2
RavenDB-20603 About page UI
ml054 Mar 5, 2024
a01147a
RavenDB-20603 About page UI
ml054 Mar 5, 2024
c150848
RavenDB-20603 About page UI
ml054 Mar 5, 2024
437d864
RavenDB-20603 Pagination component
mateuszbartosik Mar 7, 2024
9aedc37
RavenDB-20603 About page fixes
mateuszbartosik Mar 7, 2024
2954089
RavenDB-20603 About page UI
ml054 Mar 12, 2024
c4c0a7a
RavenDB-21797 Fixed paging in studio
Lwiel Mar 12, 2024
58c0784
RavenDB-21797 Fixed paging in Raven server
Lwiel Mar 12, 2024
3f91077
RavenDB-21797 Adjusted studio code to api changes
Lwiel Apr 9, 2024
61c47f0
RavenDB-20603 About page
ml054 Apr 23, 2024
c371af6
RavenDB-21797 About page adjustments - fixed linter
ml054 Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Raven.Server/Web/Studio/UpgradeInfoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@ public async Task GetUpgradeInfo()
return;
}

var pageNumber = GetStart() + 1;
var start = GetStart();
var pageSize = GetPageSize();

using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream()))
{
if (pageNumber <= 0 || pageSize <= 0)
if (start < 0 || pageSize <= 0)
{
HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;

context.Write(writer,
new DynamicJsonValue { [ErrorPropertyName] = $"Incorrect values of query string parameters - '{StartParameter}' cannot be negative, '{PageSizeParameter}' has to be greater than zero." });
return;
}

var pageNumber = (start / pageSize) + 1;

var licenseId = ServerStore.LicenseManager.LicenseStatus.Id.ToString();

Expand Down Expand Up @@ -76,6 +78,7 @@ await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBody
}
catch (Exception e)
{
HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Write(writer, new DynamicJsonValue { [ErrorPropertyName] = e.Message });
}
}
Expand All @@ -96,6 +99,7 @@ public class BuildCompatibilityInfo : IDynamicJsonValueConvertible
public bool CanDowngradeFollowingUpgrade { get; set; }
public string ChangelogHtml { get; set; }
public DateTime? ReleasedAt { get; set; }
public bool CanUpgrade { get; set; }

public DynamicJsonValue ToJson()
{
Expand All @@ -104,7 +108,8 @@ public DynamicJsonValue ToJson()
[nameof(FullVersion)] = FullVersion,
[nameof(CanDowngradeFollowingUpgrade)] = CanDowngradeFollowingUpgrade,
[nameof(ChangelogHtml)] = ChangelogHtml,
[nameof(ReleasedAt)] = ReleasedAt
[nameof(ReleasedAt)] = ReleasedAt,
[nameof(CanUpgrade)] = CanUpgrade
};
}
}
Expand All @@ -115,7 +120,6 @@ public class UpgradeInfoResponse
public List<BuildCompatibilityInfo> BuildCompatibilitiesForLatestMajorMinor { get; set; }
public long TotalBuildsForUserMajorMinor { get; set; }
public long TotalBuildsForLatestMajorMinor { get; set; }
public bool IsLicenseEligibleForUpgrade { get; set; }

public DynamicJsonValue ToJson()
{
Expand All @@ -124,8 +128,7 @@ public DynamicJsonValue ToJson()
[nameof(BuildCompatibilitiesForUserMajorMinor)] = BuildCompatibilitiesForUserMajorMinor,
[nameof(BuildCompatibilitiesForLatestMajorMinor)] = BuildCompatibilitiesForLatestMajorMinor,
[nameof(TotalBuildsForUserMajorMinor)] = TotalBuildsForUserMajorMinor,
[nameof(TotalBuildsForLatestMajorMinor)] = TotalBuildsForLatestMajorMinor,
[nameof(IsLicenseEligibleForUpgrade)] = IsLicenseEligibleForUpgrade,
[nameof(TotalBuildsForLatestMajorMinor)] = TotalBuildsForLatestMajorMinor
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import commandBase = require("commands/commandBase");
import endpoints = require("endpoints");

class getChangeLogCommand extends commandBase {

private readonly start: number;
private readonly pageSize: number;

public constructor(start: number, pageSize: number) {
super();

this.start = start;
this.pageSize = pageSize;
}

execute(): JQueryPromise<Raven.Server.Web.Studio.UpgradeInfoHandler.UpgradeInfoResponse> {
const args = {
start: this.start,
pageSize: this.pageSize
}
const url = endpoints.global.upgradeInfo.studioUpgradeInfo + this.urlEncodeArgs(args);

return this.query<Raven.Server.Web.Studio.UpgradeInfoHandler.UpgradeInfoResponse>(url, null)
.fail((response: JQueryXHR) => this.reportError("Failed to get change log", response.responseText));
}
}

export = getChangeLogCommand;
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import endpoints = require("endpoints");
type VersionInfoDto = Raven.Server.ServerWide.BackgroundTasks.LatestVersionCheck.VersionInfo;

class getLatestVersionInfoCommand extends commandBase {
constructor(private refresh?: boolean) {
private readonly refresh?: boolean;

constructor(refresh?: boolean) {
super();
this.refresh = refresh;
}

execute(): JQueryPromise<VersionInfoDto> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class icomoonHelpers {
"corax-backward": 0xf14F,
"corax-sort-az": 0xf150,
"corax-sort-za": 0xf151,
"close": 0xf162,
} as const;

static getCodePointForCanvas(iconName: keyof typeof icomoonHelpers.fixedCodepoints): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import appUrl = require("common/appUrl");
import { bridgeToReact } from "common/reactUtils";
import { BootstrapPlaygroundPage } from "components/pages/BootstrapPlaygroundPage";
import { AboutPage } from "components/pages/resources/about/AboutPage";

function aboutItem() {
return new leafMenuItem({
route: 'about',
moduleId: require('viewmodels/shell/about'),
moduleId: bridgeToReact(AboutPage, "nonShardedView"),
title: 'About',
tooltip: "About",
nav: true,
Expand Down
56 changes: 56 additions & 0 deletions src/Raven.Studio/typescript/components/common/Pagination.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@use "Content/scss/bs5variables";
@use "Content/scss/colors";
@use "Content/scss/sizes";

.pagination {
.page-item {
width: 32px;
height: 32px;
text-align: center;
.page-link {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
transition:
color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
border-radius: sizes.$border-radius !important;
&.nav-arrow-btn {
background: transparent;
border: none;
color: colors.$border-color-light-var !important;
border-radius: 50% !important;
box-shadow: none;
i {
top: 1px;
}
&:hover,
&:focus {
background-color: colors.$panel-bg-1-var;
color: colors.$text-color-var !important;
}
}
}
&.disabled {
pointer-events: none;
.page-link {
background: transparent;
border: none;
&.nav-arrow-btn {
opacity: 0.5;
}
}
}
&:hover {
filter: colors.$hover-filter-var;
}
&.active {
.page-link {
background-color: colors.$primary-var;
color: colors.$text-emphasis-var;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Meta } from "@storybook/react";
import DefaultPagination from "./Pagination";
import React, { useState } from "react";
import { withBootstrap5, withStorybookContexts } from "test/storybookTestUtils";

export default {
title: "Bits/Pagination",
decorators: [withStorybookContexts, withBootstrap5],
component: DefaultPagination,
} satisfies Meta<typeof DefaultPagination>;

export function Pagination() {
const [page, setPage] = useState(1);
return <DefaultPagination totalPages={12} page={page} onPageChange={setPage} />;
}
119 changes: 119 additions & 0 deletions src/Raven.Studio/typescript/components/common/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from "react";
import { Pagination, PaginationItem, PaginationLink } from "reactstrap";
import "./Pagination.scss";
import { Icon } from "components/common/Icon";
import { withPreventDefault } from "components/utils/common";

interface CustomPaginationProps {
page: number;
totalPages: number;
showOnSinglePage?: number;
onPageChange: (page: number) => void;
}

export default function CustomPagination(props: CustomPaginationProps) {
const { totalPages, onPageChange, showOnSinglePage, page } = props;

const getPaginationItems = () => {
const pages: React.ReactNode[] = [];
let startRange = page - 1;
let endRange = page + 1;

if (startRange <= 2) {
startRange = 1;
endRange = 5;
}

if (endRange >= totalPages - 1) {
startRange = totalPages - 4;
endRange = totalPages;
}

for (let i = startRange; i <= endRange; i++) {
if (i > 0 && i <= totalPages) {
pages.push(
<PaginationItem active={i === page} key={i}>
<PaginationLink
href="#"
onClick={withPreventDefault(() => onPageChange(i))}
className="no-decor"
>
{i}
</PaginationLink>
</PaginationItem>
);
}
}

if (startRange > 1) {
pages.unshift(
<PaginationItem key="start-ellipsis" disabled>
<PaginationLink href="#" className="no-decor">
...
</PaginationLink>
</PaginationItem>
);
pages.unshift(
<PaginationItem key="1">
<PaginationLink href="#" onClick={withPreventDefault(() => onPageChange(1))} className="no-decor">
1
</PaginationLink>
</PaginationItem>
);
}

if (endRange < totalPages) {
pages.push(
<PaginationItem key="end-ellipsis" disabled>
<PaginationLink href="#" className="no-decor">
...
</PaginationLink>
</PaginationItem>
);
pages.push(
<PaginationItem key={totalPages}>
<PaginationLink
href="#"
onClick={withPreventDefault(() => onPageChange(totalPages))}
className="no-decor"
>
{totalPages}
</PaginationLink>
</PaginationItem>
);
}

return pages;
};

if (totalPages <= 1 && !showOnSinglePage) {
return;
}

return (
<Pagination size="sm">
<div className="d-flex gap-1">
<PaginationItem disabled={page === 1}>
<PaginationLink
href="#"
onClick={withPreventDefault(() => onPageChange(Math.max(1, page - 1)))}
className="no-decor nav-arrow-btn"
>
<Icon icon="arrow-thin-left" margin="m-0" />
</PaginationLink>
</PaginationItem>
{getPaginationItems()}
<PaginationItem disabled={page === totalPages}>
<PaginationLink
next
href="#"
onClick={withPreventDefault(() => onPageChange(Math.min(totalPages, page + 1)))}
className="no-decor nav-arrow-btn"
>
<Icon icon="arrow-thin-right" margin="m-0" />
</PaginationLink>
</PaginationItem>
</div>
</Pagination>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { ReactNode, useEffect } from "react";
import classNames from "classnames";
import { Icon } from "./Icon";
import IconName from "typings/server/icons";
import "./Toggles.scss";

export interface RadioToggleWithIconInputItem<T extends string | number | boolean = string> {
label: string | ReactNode | ReactNode[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ClusterState {
nodes: EntityState<ClusterNode, string>;
clientVersion: string;
serverVersion: serverBuildVersionDto;
passive: boolean;
}

const clusterNodesAdapter = createEntityAdapter<ClusterNode, string>({
Expand All @@ -33,12 +34,16 @@ const initialState: ClusterState = {
nodes: clusterNodesAdapter.getInitialState(),
clientVersion: null,
serverVersion: null,
passive: true,
};

export const clusterSlice = createSlice({
initialState,
name: "cluster",
reducers: {
serverStateLoaded: (state, action: PayloadAction<{ passive: boolean }>) => {
state.passive = action.payload.passive;
},
nodesLoaded: (state, action: PayloadAction<ClusterNode[]>) => {
const bootstrapped = !action.payload.some((x) => x.nodeTag === "?");
clusterNodesAdapter.setAll(state.nodes, bootstrapped ? action.payload : []);
Expand All @@ -65,4 +70,5 @@ export const clusterSelectors = {
localNodeTag: selectLocalNodeTag,
clientVersion: (store: RootState) => store.cluster.clientVersion,
serverVersion: (store: RootState) => store.cluster.serverVersion,
isPassive: (store: RootState) => store.cluster.passive,
};