Skip to content

Commit

Permalink
feat(JobDetailPage): add breadcrumb component
Browse files Browse the repository at this point in the history
Closes DCOS-38481
  • Loading branch information
Daniel Schmidt authored and juliangieseke committed Jun 29, 2018
1 parent 3e2eeaa commit ded4d5a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 4 additions & 1 deletion plugins/jobs/src/js/components/Breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default function Breadcrumbs({ item, children, states }) {
}

Breadcrumbs.propTypes = {
states: PropTypes.element,
states: PropTypes.oneOfType([
PropTypes.element,
PropTypes.arrayOf(PropTypes.element)
]),
item: PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.arrayOf(PropTypes.string).isRequired
Expand Down
36 changes: 35 additions & 1 deletion plugins/jobs/src/js/pages/JobDetailPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ import mixin from "reactjs-mixin";
import Page from "#SRC/js/components/Page";
import TabsMixin from "#SRC/js/mixins/TabsMixin";
import Job from "#SRC/js/structs/Job";
import Util from "#SRC/js/utils/Util";

import JobFormModalContainer from "../JobFormModalContainer";
import JobConfiguration from "./JobConfiguration";
import { DIALOGS } from "../JobDetailPageContainer";
import JobRunHistoryTable from "./JobRunHistoryTable";
import ItemSchedule from "../components/breadcrumbs/Schedule";
import ItemStatus from "../components/breadcrumbs/Status";
import Breadcrumbs from "../components/Breadcrumbs";

class JobDetailPage extends mixin(TabsMixin) {
constructor() {
super(...arguments);
this.renderBreadcrumbStates = this.renderBreadcrumbStates.bind(this);

this.tabs_tabs = {
runHistory: "Run History",
Expand Down Expand Up @@ -45,6 +50,27 @@ class JobDetailPage extends mixin(TabsMixin) {
return <JobRunHistoryTable job={job} />;
}

renderBreadcrumbStates(item) {
const status = Util.findNestedPropertyInObject(
item,
"jobRuns.longestRunningActiveRun.tasks.longestRunningTask.status"
);

let schedule = null;
if (
item.schedules &&
item.schedules.nodes.length &&
item.schedules.nodes[0].enabled
) {
schedule = item.schedules.nodes[0];
}

return [
schedule ? <ItemSchedule key="schedule" schedule={schedule} /> : null,
status ? <ItemStatus key="status" status={status} /> : null
];
}

getActions() {
return [
{
Expand Down Expand Up @@ -82,11 +108,19 @@ class JobDetailPage extends mixin(TabsMixin) {

const { job } = this.props;

// TODO: wait for https://github.com/dcos/dcos-ui/pull/3029 to be merged and remove this line
const breadcrumbJob = { ...job, path: [] };

return (
<Page>
<Page.Header
actions={this.getActions()}
breadcrumbs={null}
breadcrumbs={
<Breadcrumbs
states={this.renderBreadcrumbStates(breadcrumbJob)}
item={breadcrumbJob}
/>
}
tabs={this.getTabs()}
/>
{this.tabs_getTabView(job)}
Expand Down

0 comments on commit ded4d5a

Please sign in to comment.