MCPcopy
hub / github.com/cockpit-project/cockpit / render

Method render

pkg/shell/topnav.tsx:96–317  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94 };
95
96 render() {
97 const Dialogs = this.context!;
98 const {
99 current_machine,
100 current_manifest_item,
101 current_manifest,
102 current_frame,
103 } = this.props.state;
104
105 cockpit.assert(current_machine && current_manifest && current_manifest_item);
106
107 const connected = current_machine.state === "connected";
108
109 let docs: ManifestDocs[] = [];
110
111 if (!this.superuser_connection || (this.superuser_connection.options.host !=
112 current_machine.connection_string)) {
113 if (this.superuser_connection) {
114 this.superuser_connection.close();
115 this.superuser_connection = null;
116 }
117
118 if (connected) {
119 this.superuser_connection = cockpit.dbus(null, { bus: "internal", host: current_machine.connection_string });
120 this.superuser = superuser_proxy(this.superuser_connection);
121 }
122 }
123
124 // Check first whether we have docs in the "parent" section of
125 // the manifest.
126 const parent = (current_manifest.parent || {}) as ManifestParentSection;
127 if (parent.docs)
128 docs = parent.docs;
129 else if (current_manifest_item.docs)
130 docs = current_manifest_item.docs;
131
132 const docItems = [];
133
134 if (typeof this.state.osRelease?.DOCUMENTATION_URL == "string")
135 docItems.push(<DropdownItem key="os-doc" to={this.state.osRelease.DOCUMENTATION_URL} target="blank" rel="noopener noreferrer" icon={<ExternalLinkAltIcon />}>
136 {cockpit.format(_("$0 documentation"), this.state.osRelease.NAME)}
137 </DropdownItem>);
138
139 const shell_manifest = this.props.state.config.manifest;
140
141 // global documentation for cockpit as a whole
142 (shell_manifest.docs ?? []).forEach(doc => {
143 docItems.push(<DropdownItem key={doc.label} to={doc.url} target="blank" rel="noopener noreferrer" icon={<ExternalLinkAltIcon />}>
144 {doc.label}
145 </DropdownItem>);
146 });
147
148 if (docs.length > 0)
149 docItems.push(<Divider key="separator" />);
150
151 docs.forEach(e => {
152 docItems.push(<DropdownItem key={e.label} to={e.url} target="blank" rel="noopener noreferrer" icon={<ExternalLinkAltIcon />}>
153 {_(e.label)}

Callers 4

initFunction · 0.45
initFunction · 0.45
initFunction · 0.45
sosreport.jsxFile · 0.45

Calls 5

superuser_proxyFunction · 0.90
forEachMethod · 0.80
closeMethod · 0.65
runMethod · 0.65
focusMethod · 0.45

Tested by

no test coverage detected