Skip to content

Commit

Permalink
add description and styles on route wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Dec 6, 2024
1 parent b0c2d9d commit 9832d59
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 62 deletions.
1 change: 0 additions & 1 deletion otoroshi/javascript/src/components/inputs/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ export class Table extends Component {
: []
}
onFetchData={(state, instance) => {
// console.log('onFetchData')
this.update(state);
}}
onFilteredChange={(column, value) => {
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/javascript/src/pages/JwtVerifiersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class JwtVerifiersPage extends Component {
<PageTitle title={title} {...this.props}>
{isEditPage && (
<Dropdown>
<YAMLExportButton value={verifier} entityKind="JwtVerifier" />
<YAMLExportButton value={verifier} entityKind="security.otoroshi.io/JwtVerifier" />
<JsonExportButton value={verifier} entityKind="security.otoroshi.io/JwtVerifier" />
<SquareButton
level="danger"
Expand Down
50 changes: 27 additions & 23 deletions otoroshi/javascript/src/pages/RouteDesigner/Informations.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,33 @@ export const Informations = forwardRef(
},
enabled: {
renderer: props => {
return <div className='d-flex align-items-baseline'>
<p className='ms-2'>Exposition of the route</p>
<span className={`mx-2 badge bg-${props.value ? 'success' : 'danger'}`}>
{props.value ? 'Exposed' : 'Disabled'}
</span>
{props.value ?
<Button type="danger" className="btn-sm" text="Disable this route"
onClick={() => {
window
.newConfirm('Are you sure you disable this route ? Traffic will be stop immediately.')
.then((ok) => {
if (ok) {
saveRoute({ ...value, enabled: false })
.then(() => window.location.reload())
}
})
}} /> :
<Button type="success" className="btn-sm" text="Publish this route"
onClick={() => {
saveRoute({ ...value, enabled: true })
.then(() => window.location.reload())
}} />}
</div>
return <>
<div className='d-flex align-items-baseline'>
<p className='ms-2'>Exposition of the route</p>
<div className='d-flex flex-column gap-3 ms-3'>
<span className={`badge bg-${props.value ? 'success' : 'danger'}`} style={{ width: 'fit-content' }}>
{props.value ? 'Exposed' : 'Disabled'}
</span>
{props.value ?
<Button type="danger" className="btn-sm mb-3" text="Disable this route"
onClick={() => {
window
.newConfirm('Are you sure you disable this route ? Traffic will be stop immediately.')
.then((ok) => {
if (ok) {
saveRoute({ ...value, enabled: false })
.then(() => window.location.reload())
}
})
}} /> :
<Button type="success" className="btn-sm mb-3" text="Publish this route"
onClick={() => {
saveRoute({ ...value, enabled: true })
.then(() => window.location.reload())
}} />}
</div>
</div>
</>
}
},
capture: {
Expand Down
64 changes: 30 additions & 34 deletions otoroshi/javascript/src/pages/RouteDesigner/RouteWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
nextClient,
} from "../../services/BackOfficeServices";
import { Plugins } from "../../forms/ng_plugins";
import Loader from "../../components/Loader";
import { Button } from "../../components/Button";

const RouteNameStep = ({ state, onChange }) => (
Expand Down Expand Up @@ -75,9 +74,8 @@ const RouteChooser = ({ state, onChange }) => (
].map(({ kind, title, text }) => (
<button
type="button"
className={`btn py-3 wizard-route-chooser ${
state.route.kind === kind ? "btn-primaryColor" : "btn-quiet"
}`}
className={`btn py-3 wizard-route-chooser ${state.route.kind === kind ? "btn-primaryColor" : "btn-quiet"
}`}
onClick={() => onChange(kind)}
key={kind}
>
Expand Down Expand Up @@ -162,7 +160,6 @@ const BackendStep = ({ state, onChange, onError, error }) => {
};

const ProcessStep = ({ state, history }) => {
const [loading, setLoading] = useState(true);
const [createdRoute, setCreatedRoute] = useState({});

const API_PLUGINS = [
Expand Down Expand Up @@ -204,10 +201,10 @@ const ProcessStep = ({ state, history }) => {
]).then(([plugins, oldPlugins, metadataPlugins, template]) => {
const url = ["mock", "graphql"].includes(state.route.kind)
? {
pahtname: "/",
hostname: "",
protocol: "https://",
}
pahtname: "/",
hostname: "",
protocol: "https://",
}
: new URL(state.route.url);
const secured = url.protocol.includes("https");

Expand Down Expand Up @@ -261,14 +258,11 @@ const ProcessStep = ({ state, history }) => {
},
})
.then((r) => {
setLoading(false);
setCreatedRoute(r);
});
});
}, []);

const pluginsLength = PLUGINS[state.route.kind].length;

const timers = [...PLUGINS[state.route.kind], {}, {}].reduce((acc, _, i) => {
if (i === 0) return [100 + Math.floor(Math.random() * 250)];
return [...acc, acc[i - 1] + 100 + Math.floor(Math.random() * 250)];
Expand Down Expand Up @@ -300,22 +294,22 @@ const ProcessStep = ({ state, history }) => {
</div>

<LoaderItem timeout={timers[timers.length - 1]}>
<div className="d-flex">
<div className="d-flex justify-content-center">
<div className="cards mx-3">
<div className="cards-header d-flex align-items-center justify-content-center">
<h4 className="mt-3" style={{ color: "var(--text)" }}>
{state.route.kind === "mock"
? "Creating mocks"
: state.route.kind === "graphql"
? "Creating schema"
: "Editing plugins"}
? "Creating schema"
: "Editing plugins"}
</h4>
</div>
<div className="cards-body">
<div className="cards-title">lorem50</div>
<div className="cards-description">
<p>ma petite description</p>
<div className="d-flex justify-content-end">
<div className="cards-title">Draft way</div>
<div className="cards-description d-flex flex-column" style={{ flex: 1 }}>
<p>Continue to edit your route before publishing it</p>
<div className="d-flex justify-content-end mt-auto">
<button
className="btn btn-primaryColor"
onClick={() => {
Expand All @@ -332,8 +326,8 @@ const ProcessStep = ({ state, history }) => {
{state.route.kind === "mock"
? "Start creating mocks"
: state.route.kind === "graphql"
? "Start creating schema"
: "Start editing plugins"}
? "Start creating schema"
: "Start editing plugins"}
</button>
</div>
</div>
Expand All @@ -342,22 +336,25 @@ const ProcessStep = ({ state, history }) => {
<div className="cards mx-3 cursor-pointer">
<div className="cards-header d-flex align-items-center justify-content-center">
<h4 className="mt-3" style={{ color: "var(--text)" }}>
Publish your route
Road to production
</h4>
</div>
<div className="cards-body">
<div className="cards-title">
lorem50
Publish way
</div>
<div className="cards-description">
<p>ma petite description</p>
<div className="d-flex justify-content-end">
<div className="cards-description d-flex flex-column" style={{ flex: 1 }}>
<p>Expose the generate route to the world</p>
<div className="d-flex justify-content-end mt-auto">
<button
className="ms-2 btn btn-primaryColor"
onClick={() => {
history.push(
`/routes/${createdRoute.id}?tab=informations`
);
nextClient.forEntityNext(nextClient.ENTITIES.ROUTES).update({
...createdRoute,
enabled: true
}).then(() => {
history.push(`/routes/${createdRoute.id}?tab=informations`);
})
}}
>
Publish
Expand Down Expand Up @@ -527,11 +524,10 @@ export class RouteWizard extends React.Component {

{step <= 4 && (
<div
className={`mt-auto d-flex align-items-center ${
step !== 1
? "justify-content-between"
: "justify-content-end"
}`}
className={`mt-auto d-flex align-items-center ${step !== 1
? "justify-content-between"
: "justify-content-end"
}`}
>
{step !== 1 && (
<Button
Expand Down
4 changes: 2 additions & 2 deletions otoroshi/javascript/src/pages/RouteDesigner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ function MoreActionsButton({ value, menu, history }) {
return (
<div className="mb-1 d-flex" style={{ gap: '.5rem' }}>
<DuplicateButton value={value} history={history} />
<YAMLExportButton value={value} entityKind="JwtVerifier" />
<JsonExportButton value={value} entityKind="JwtVerifier" />
<YAMLExportButton value={value} entityKind="proxy.otoroshi.io/Route" />
<JsonExportButton value={value} entityKind="proxy.otoroshi.io/Route" />
{menu}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/javascript/src/style/components/_card.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.cards {
background-color: var(--bg-color_level2);
margin: 5px 0px;
height: 100%;
flex: 1;
border-radius: 12px;
max-width: 300px;
min-width: 300px;
Expand Down

0 comments on commit 9832d59

Please sign in to comment.